File tree Expand file tree Collapse file tree 6 files changed +14
-27
lines changed Expand file tree Collapse file tree 6 files changed +14
-27
lines changed Original file line number Diff line number Diff line change @@ -24,20 +24,20 @@ require 'vendor/autoload.php';
24
24
25
25
use ODM\DBAL;
26
26
use ODM\Document\Document;
27
- use ODM\DocumentMapper \DocumentManagerFactory;
27
+ use ODM\DocumentManager \DocumentManagerFactory;
28
28
29
29
/**
30
- * @ODM\Mapping\Annotator\ Collection(name="alphabet")
30
+ * @Collection(name="alphabet")
31
31
*/
32
32
class Alphabet extends Document {
33
33
34
34
/**
35
- * @ODM\Mapping\Annotator\ Field(name="language", type="string")
35
+ * @Field(name="language", type="string")
36
36
*/
37
37
private $language;
38
38
39
39
/**
40
- * @ODM\Mapping\Annotator\ Field(name="words", type="Tests\Word[]")
40
+ * @Field(name="words", type="Tests\Word[]")
41
41
*/
42
42
private $words;
43
43
@@ -91,7 +91,7 @@ class Alphabet extends Document {
91
91
class Word {
92
92
93
93
/**
94
- * @ODM\Mapping\Annotator\ Field(name="name", type="string")
94
+ * @Field(name="name", type="string")
95
95
*/
96
96
private $name;
97
97
Original file line number Diff line number Diff line change 5
5
class Document
6
6
{
7
7
/**
8
- * @ODM\Mapping\Annotator\ Field(name="_id", type="string")
8
+ * @Field(name="_id", type="string")
9
9
*/
10
- private $ id ;
10
+ protected $ id ;
11
11
12
12
/**
13
13
* @return mixed
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ public function __construct(Metadata $metadata)
38
38
$ this ->parseCollection ($ metadata ->getReflectionClass ());
39
39
40
40
foreach ($ metadata ->getReflectionProperties () as $ property ) {
41
- $ this ->parseFields ($ property );
41
+ $ this ->parseField ($ property );
42
42
}
43
43
}
44
44
@@ -48,7 +48,7 @@ public function __construct(Metadata $metadata)
48
48
*/
49
49
private function parseCollection (\ReflectionClass $ reflection_class )
50
50
{
51
- $ pattern = '/@ ' . preg_quote ( Collection::class) . ' \((.*)\)/ ' ;
51
+ $ pattern = '/@Collection\((.*)\)/ ' ;
52
52
preg_match ($ pattern , $ reflection_class ->getDocComment (), $ matches );
53
53
54
54
$ doc = array_key_exists (1 , $ matches ) ? $ matches [1 ] : '' ;
@@ -64,9 +64,9 @@ private function parseCollection(\ReflectionClass $reflection_class)
64
64
* @param \ReflectionProperty $reflection_property
65
65
* @return bool
66
66
*/
67
- private function parseFields (\ReflectionProperty $ reflection_property )
67
+ private function parseField (\ReflectionProperty $ reflection_property )
68
68
{
69
- $ pattern = '/@ ' . preg_quote ( Field::class) . ' \((.*)\)/ ' ;
69
+ $ pattern = '/@Field\((.*)\)/ ' ;
70
70
preg_match ($ pattern , $ reflection_property ->getDocComment (), $ matches );
71
71
72
72
$ doc = array_key_exists (1 , $ matches ) ? $ matches [1 ] : '' ;
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -137,6 +137,9 @@ public function objectToArray($obj)
137
137
private function typeCast (string $ type , $ value , int $ to )
138
138
{
139
139
switch ($ type ) {
140
+ case 'bool ' :
141
+ $ value = (bool )$ value ;
142
+ break ;
140
143
case 'integer ' :
141
144
$ value = (integer )$ value ;
142
145
break ;
You can’t perform that action at this time.
0 commit comments