Skip to content

Commit 12339f4

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

26 files changed

+56
-220
lines changed

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

+4-3
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

+8-6
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

+5-1
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

+1-1
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

+2
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

+11-12
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
* This file is part of the Symfony package.
55
*
66
* (c) Fabien Potencier <fabien@symfony.com>
7-
* (c) Kévin Dunglas <dunglas@gmail.com>
87
*
98
* For the full copyright and license information, please view the LICENSE
109
* file that was distributed with this source code.
1110
*/
1211

13-
namespace Symfony\Component\PropertyInfo\Extractors;
12+
namespace Symfony\Component\PropertyInfo\Extractor;
1413

1514
use phpDocumentor\Reflection\ClassReflector;
1615
use phpDocumentor\Reflection\DocBlock;
@@ -33,11 +32,11 @@ class PhpDocExtractor implements PropertyDescriptionInfoInterface, PropertyTypeI
3332
/**
3433
* @var FileReflector[]
3534
*/
36-
private static $fileReflectors = array();
35+
private $fileReflectors = array();
3736
/**
3837
* @var DocBlock[]
3938
*/
40-
private static $docBlocks = array();
39+
private $docBlocks = array();
4140

4241
/**
4342
* {@inheritdoc}
@@ -147,14 +146,14 @@ private function getFileReflector(\ReflectionClass $reflectionClass)
147146
return;
148147
}
149148

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

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

157-
return self::$fileReflectors[$fileName];
156+
return $this->fileReflectors[$fileName];
158157
}
159158

160159
/**
@@ -169,8 +168,8 @@ private function getDocBlock($class, $property)
169168
{
170169
$propertyHash = sprintf('%s::%s', $class, $property);
171170

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

176175
$ucFirstProperty = ucfirst($property);
@@ -192,7 +191,7 @@ private function getDocBlock($class, $property)
192191
$data = array(null, null);
193192
}
194193

195-
return self::$docBlocks[$propertyHash] = $data;
194+
return $this->docBlocks[$propertyHash] = $data;
196195
}
197196

198197
/**

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
* This file is part of the Symfony package.
55
*
66
* (c) Fabien Potencier <fabien@symfony.com>
7-
* (c) Kévin Dunglas <dunglas@gmail.com>
87
*
98
* For the full copyright and license information, please view the LICENSE
109
* file that was distributed with this source code.
1110
*/
1211

13-
namespace Symfony\Component\PropertyInfo\Extractors;
12+
namespace Symfony\Component\PropertyInfo\Extractor;
1413

1514
use Symfony\Component\PropertyInfo\PropertyAccessInfoInterface;
1615
use Symfony\Component\PropertyInfo\PropertyListRetrieverInterface;

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
* This file is part of the Symfony package.
55
*
66
* (c) Fabien Potencier <fabien@symfony.com>
7-
* (c) Kévin Dunglas <dunglas@gmail.com>
87
*
98
* For the full copyright and license information, please view the LICENSE
109
* file that was distributed with this source code.
1110
*/
1211

13-
namespace Symfony\Component\PropertyInfo\Extractors;
12+
namespace Symfony\Component\PropertyInfo\Extractor;
1413

1514
use Symfony\Component\PropertyInfo\PropertyListRetrieverInterface;
1615
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;

src/Symfony/Component/PropertyInfo/PropertyAccessInfoInterface.php

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* This file is part of the Symfony package.
55
*
66
* (c) Fabien Potencier <fabien@symfony.com>
7-
* (c) Kévin Dunglas <dunglas@gmail.com>
87
*
98
* For the full copyright and license information, please view the LICENSE
109
* file that was distributed with this source code.

src/Symfony/Component/PropertyInfo/PropertyDescriptionInfoInterface.php

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* This file is part of the Symfony package.
55
*
66
* (c) Fabien Potencier <fabien@symfony.com>
7-
* (c) Kévin Dunglas <dunglas@gmail.com>
87
*
98
* For the full copyright and license information, please view the LICENSE
109
* file that was distributed with this source code.

src/Symfony/Component/PropertyInfo/PropertyInfo.php

+2-7
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* This file is part of the Symfony package.
55
*
66
* (c) Fabien Potencier <fabien@symfony.com>
7-
* (c) Kévin Dunglas <dunglas@gmail.com>
87
*
98
* For the full copyright and license information, please view the LICENSE
109
* file that was distributed with this source code.
@@ -42,12 +41,8 @@ class PropertyInfo implements PropertyInfoInterface
4241
* @param PropertyDescriptionInfoInterface[] $descriptionExtractors
4342
* @param PropertyAccessInfoInterface[] $accessExtractors
4443
*/
45-
public function __construct(
46-
array $listExtractors = array(),
47-
array $typeExtractors = array(),
48-
array $descriptionExtractors = array(),
49-
array $accessExtractors = array()
50-
) {
44+
public function __construct(array $listExtractors = array(), array $typeExtractors = array(), array $descriptionExtractors = array(), array $accessExtractors = array())
45+
{
5146
$this->listExtractors = $listExtractors;
5247
$this->typeExtractors = $typeExtractors;
5348
$this->descriptionExtractors = $descriptionExtractors;

src/Symfony/Component/PropertyInfo/PropertyInfoInterface.php

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* This file is part of the Symfony package.
55
*
66
* (c) Fabien Potencier <fabien@symfony.com>
7-
* (c) Kévin Dunglas <dunglas@gmail.com>
87
*
98
* For the full copyright and license information, please view the LICENSE
109
* file that was distributed with this source code.

src/Symfony/Component/PropertyInfo/PropertyListRetrieverInterface.php

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* This file is part of the Symfony package.
55
*
66
* (c) Fabien Potencier <fabien@symfony.com>
7-
* (c) Kévin Dunglas <dunglas@gmail.com>
87
*
98
* For the full copyright and license information, please view the LICENSE
109
* file that was distributed with this source code.

src/Symfony/Component/PropertyInfo/PropertyTypeInfoInterface.php

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* This file is part of the Symfony package.
55
*
66
* (c) Fabien Potencier <fabien@symfony.com>
7-
* (c) Kévin Dunglas <dunglas@gmail.com>
87
*
98
* For the full copyright and license information, please view the LICENSE
109
* file that was distributed with this source code.

0 commit comments

Comments
 (0)