Skip to content

Commit 73c1c46

Browse files
committed
annotations
1 parent 1b0bd01 commit 73c1c46

File tree

6 files changed

+14
-27
lines changed

6 files changed

+14
-27
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ require 'vendor/autoload.php';
2424

2525
use ODM\DBAL;
2626
use ODM\Document\Document;
27-
use ODM\DocumentMapper\DocumentManagerFactory;
27+
use ODM\DocumentManager\DocumentManagerFactory;
2828

2929
/**
30-
* @ODM\Mapping\Annotator\Collection(name="alphabet")
30+
* @Collection(name="alphabet")
3131
*/
3232
class Alphabet extends Document {
3333

3434
/**
35-
* @ODM\Mapping\Annotator\Field(name="language", type="string")
35+
* @Field(name="language", type="string")
3636
*/
3737
private $language;
3838

3939
/**
40-
* @ODM\Mapping\Annotator\Field(name="words", type="Tests\Word[]")
40+
* @Field(name="words", type="Tests\Word[]")
4141
*/
4242
private $words;
4343

@@ -91,7 +91,7 @@ class Alphabet extends Document {
9191
class Word {
9292

9393
/**
94-
* @ODM\Mapping\Annotator\Field(name="name", type="string")
94+
* @Field(name="name", type="string")
9595
*/
9696
private $name;
9797

src/Document/Document.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
class Document
66
{
77
/**
8-
* @ODM\Mapping\Annotator\Field(name="_id", type="string")
8+
* @Field(name="_id", type="string")
99
*/
10-
private $id;
10+
protected $id;
1111

1212
/**
1313
* @return mixed

src/Mapping/Annotator/Annotator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(Metadata $metadata)
3838
$this->parseCollection($metadata->getReflectionClass());
3939

4040
foreach($metadata->getReflectionProperties() as $property) {
41-
$this->parseFields($property);
41+
$this->parseField($property);
4242
}
4343
}
4444

@@ -48,7 +48,7 @@ public function __construct(Metadata $metadata)
4848
*/
4949
private function parseCollection(\ReflectionClass $reflection_class)
5050
{
51-
$pattern = '/@' . preg_quote(Collection::class) . '\((.*)\)/';
51+
$pattern = '/@Collection\((.*)\)/';
5252
preg_match($pattern, $reflection_class->getDocComment(), $matches);
5353

5454
$doc = array_key_exists(1, $matches) ? $matches[1] : '';
@@ -64,9 +64,9 @@ private function parseCollection(\ReflectionClass $reflection_class)
6464
* @param \ReflectionProperty $reflection_property
6565
* @return bool
6666
*/
67-
private function parseFields(\ReflectionProperty $reflection_property)
67+
private function parseField(\ReflectionProperty $reflection_property)
6868
{
69-
$pattern = '/@' . preg_quote(Field::class) . '\((.*)\)/';
69+
$pattern = '/@Field\((.*)\)/';
7070
preg_match($pattern, $reflection_property->getDocComment(), $matches);
7171

7272
$doc = array_key_exists(1, $matches) ? $matches[1] : '';

src/Mapping/Annotator/Collection.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/Mapping/Annotator/Field.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/Mapping/DataMapper.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ public function objectToArray($obj)
137137
private function typeCast(string $type, $value, int $to)
138138
{
139139
switch ($type) {
140+
case 'bool':
141+
$value = (bool)$value;
142+
break;
140143
case 'integer':
141144
$value = (integer)$value;
142145
break;

0 commit comments

Comments
 (0)