8000 [DoctrineBridge] Move Doctrine extractor from PropertyInfo · symfony/symfony@a8f643c · GitHub
[go: up one dir, main page]

Skip to content

Commit a8f643c

Browse files
committed
[DoctrineBridge] Move Doctrine extractor from PropertyInfo
1 parent e16db41 commit a8f643c

File tree

12 files changed

+42
-33
lines changed

12 files changed

+42
-33
lines changed

src/Symfony/Component/PropertyInfo/Extractors/DoctrineExtractor.php renamed to src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* file that was distributed with this source code.
1111
*/
1212

13-
namespace Symfony\Component\PropertyInfo\Extractors;
13+
namespace Symfony\Bridge\Doctrine\PropertyInfo;
1414

1515
use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory;
1616
use Doctrine\Common\Persistence\Mapping\MappingException;
@@ -103,9 +103,10 @@ public function getTypes($class, $property, array $context = array())
103103
return array(new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, 'DateTime'));
104104

105105
case 'array':
106-
// No break
106+
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true));
107+
107108
case 'simple_array':
108-
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, new Type(Type::BUILTIN_TYPE_INT)));
109+
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)));
109110

110111
case 'json_array':
111112
return array(new Type(Type::BUILTIN_TYPE_ARRAY, $nullable, null, true));

src/Symfony/Component/PropertyInfo/Tests/Extractors/DoctrineExtractorTest.php renamed to src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/DoctrineExtractorTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
* file that was distributed with this source code.
1111
*/
1212

13-
namespace Symfony\Component\PropertyInfo\Tests\Extractors;
13+
namespace Symfony\Bridge\Doctrine\PropertyInfo\Tests;
1414

1515
use Doctrine\ORM\EntityManager;
1616
use Doctrine\ORM\Tools\Setup;
17-
use Symfony\Component\PropertyInfo\Extractors\DoctrineExtractor;
17+
use Symfony\Bridge\Doctrine\PropertyInfo\DoctrineExtractor;
1818
use Symfony\Component\PropertyInfo\Type;
1919

2020
/**
@@ -43,12 +43,13 @@ public function testGetProperties()
4343
'guid',
4444
'time',
4545
'json',
46+
'simpleArray',
4647
'bool',
4748
'binary',
4849
'foo',
4950
'bar',
5051
),
51-
$this->extractor->getProperties('Symfony\Component\PropertyInfo\Tests\Fixtures\DoctrineDummy')
52+
$this->extractor->getProperties('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy')
5253
);
5354
}
5455

@@ -57,7 +58,7 @@ public function testGetProperties()
5758
*/
5859
public function testExtract($property, array $type = null)
5960
{
60-
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Component\PropertyInfo\Tests\Fixtures\DoctrineDummy', $property, array()));
61+
$this->assertEquals($type, $this->extractor->getTypes('Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineDummy', $property, array()));
6162
}
6263

6364
public function typesProvider()
@@ -68,15 +69,16 @@ public function typesProvider()
6869
array('bool', array(new Type(Type::BUILTIN_TYPE_BOOL))),
6970
array('binary', array(new Type(Type::BUILTIN_TYPE_RESOURCE))),
7071
array('json', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true))),
71-
array('foo', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Component\PropertyInfo\Tests\Fixtures\DoctrineRelation'))),
72+
array('foo', array(new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation'))),
7273
array('bar', array(new Type(
7374
Type::BUILTIN_TYPE_OBJECT,
7475
false,
7576
'Doctrine\Common\Collections\Collection',
7677
true,
7778
new Type(Type::BUILTIN_TYPE_INT),
78-
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Component\PropertyInfo\Tests\Fixtures\DoctrineRelation')
79+
new Type(Type::BUILTIN_TYPE_OBJECT, false, 'Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures\DoctrineRelation')
7980
))),
81+
array('simpleArray', array(new Type(Type::BUILTIN_TYPE_ARRAY, false, null, true, new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)))),
8082
array('notMapped', null),
8183
);
8284
}

src/Symfony/Component/PropertyInfo/Tests/Fixtures/DoctrineDummy.php renamed to src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* file that was distributed with this source code.
1111
*/
1212

13-
namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
13+
namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
1414

1515
use Doctrine\ORM\Mapping\Column;
1616
use Doctrine\ORM\Mapping\Entity;
@@ -50,6 +50,10 @@ class DoctrineDummy
5050
* @Column(type="json_array")
5151
*/
5252
private $json;
53+
/**
54+
* @Column(type="simple_array")
55+
*/
56+
private $simpleArray;
5357
/**
5458
* @Column(type="boolean")
5559
*/

src/Symfony/Component/PropertyInfo/Tests/Fixtures/DoctrineRelation.php renamed to src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineRelation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* file that was distributed with this source code.
1111
*/
1212

13-
namespace Symfony\Component\PropertyInfo\Tests\Fixtures;
13+
namespace Symfony\Bridge\Doctrine\Tests\PropertyInfo\Fixtures;
1414

1515
use Doctrine\ORM\Mapping\Column;
1616
use Doctrine\ORM\Mapping\Id;

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"symfony/form": "~2.8|~3.0.0",
2727
"symfony/http-kernel": "~2.2|~3.0.0",
2828
"symfony/property-access": "~2.3|~3.0.0",
29+
"symfony/property-info": "~2.8|3.0",
2930
"symfony/security": "~2.2|~3.0.0",
3031
"symfony/expression-language": "~2.2|~3.0.0",
3132
"symfony/validator": "~2.5,>=2.5.5|~3.0.0",
@@ -37,6 +38,7 @@
3738
"suggest": {
3839
"symfony/form": "",
3940
"symfony/validator": "",
41+
"symfony/property-info": "",
4042
"doctrine/data-fixtures": "",
4143
"doctrine/dbal": "",
4244
"doctrine/orm": ""

src/Symfony/Component/PropertyInfo/Extractors/PhpDocExtractor.php renamed to src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* file that was distributed with this source code.
1111
*/
1212

13-
namespace Symfony\Component\PropertyInfo\Extractors;
13+
namespace Symfony\Component\PropertyInfo\Extractor;
1414

1515
use phpDocumentor\Reflection\ClassReflector;
1616
use phpDocumentor\Reflection\DocBlock;
@@ -33,11 +33,11 @@ class PhpDocExtractor implements PropertyDescriptionInfoInterface, PropertyTypeI
3333
/**
3434
* @var FileReflector[]
3535
*/
36-
private static $fileReflectors = array();
36+
private $fileReflectors = array();
3737
/**
3838
* @var DocBlock[]
3939
*/
40-
private static $docBlocks = array();
40+
private $docBlocks = array();
4141

4242
/**
4343
* {@inheritdoc}
@@ -147,14 +147,14 @@ private function getFileReflector(\ReflectionClass $reflectionClass)
147147
return;
148148
}
149149

150-
if (isset(self::$fileReflectors[$fileName])) {
151-
return self::$fileReflectors[$fileName];
150+
if (isset($this->fileReflectors[$fileName])) {
151+
return $this->fileReflectors[$fileName];
152152
}
153153

154-
self::$fileReflectors[$fileName] = new FileReflector($fileName);
155-
self::$fileReflectors[$fileName]->process();
154+
$this->fileReflectors[$fileName] = new FileReflector($fileName);
155+
$this->fileReflectors[$fileName]->process();
156156

157-
return self::$fileReflectors[$fileName];
157+
return $this->fileReflectors[$fileName];
158158
}
159159

160160
/**
@@ -169,8 +169,8 @@ private function getDocBlock($class, $property)
169169
{
170170
$propertyHash = sprintf('%s::%s', $class, $property);
171171

172-
if (isset(self::$docBlocks[$propertyHash])) {
173-
return self::$docBlocks[$propertyHash];
172+
if (isset($this->docBlocks[$propertyHash])) {
173+
return $this->docBlocks[$propertyHash];
174174
}
175175

176176
$ucFirstProperty = ucfirst($property);
@@ -192,7 +192,7 @@ private function getDocBlock($class, $property)
192192
$data = array(null, null);
193193
}
194194

195-
return self::$docBlocks[$propertyHash] = $data;
195+
return $this->docBlocks[$propertyHash] = $data;
196196
}
197197

198198
/**

src/Symfony/Component/PropertyInfo/Extractors/ReflectionExtractor.php renamed to src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* file that was distributed with this source code.
1111
*/
1212

13-
namespace Symfony\Component\PropertyInfo\Extractors;
13+
namespace Symfony\Component\PropertyInfo\Extractor;
1414

1515
use Symfony\Component\PropertyInfo\PropertyAccessInfoInterface;
1616
use Symfony\Component\PropertyInfo\PropertyListRetrieverInterface;

src/Symfony/Component/PropertyInfo/Extractors/SerializerExtractor.php renamed to src/Symfony/Component/PropertyInfo/Extractor/SerializerExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* file that was distributed with this source code.
1111
*/
1212

13-
namespace Symfony\Component\PropertyInfo\Extractors;
13+
namespace Symfony\Component\PropertyInfo\Extractor;
1414

1515
use Symfony\Component\PropertyInfo\PropertyListRetrieverInterface;
1616
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;

src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace Symfony\Component\PropertyInfo\Tests\PhpDocExtractors;
1414

15-
use Symfony\Component\PropertyInfo\Extractors\PhpDocExtractor;
15+
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
1616
use Symfony\Component\PropertyInfo\Type;
1717

1818
/**

src/Symfony/Component/PropertyInfo/Tests/Extractors/ReflectionExtractorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
* file that was distributed with this source code.
1111
*/
1212

13-
namespace Symfony\Component\PropertyInfo\Tests\Extractors;
13+
namespace Symfony\Component\PropertyInfo\Tests\Extractor;
1414

15-
use Symfony\Component\PropertyInfo\Extractors\ReflectionExtractor;
15+
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
1616
use Symfony\Component\PropertyInfo\Type;
1717

1818
/**

0 commit comments

Comments
 (0)
0