8000 [PropertyInfo] Use iterators for PropertyInfoExtractor · symfony/symfony@38523a9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 38523a9

Browse files
committed
[PropertyInfo] Use iterators for PropertyInfoExtractor
1 parent c3230f0 commit 38523a9

File tree

3 files changed

+17
-30
lines changed

3 files changed

+17
-30
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/PropertyInfoPass.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;
1313

14+
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1415
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1516
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
1617
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -36,15 +37,15 @@ public function process(ContainerBuilder $container)
3637
$definition = $container->getDefinition('property_info');
3738

3839
$listExtractors = $this->findAndSortTaggedServices('property_info.list_extractor', $container);
39-
$definition->replaceArgument(0, $listExtractors);
40+
$definition->replaceArgument(0, new IteratorArgument($listExtractors));
4041

4142
$typeExtractors = $this->findAndSortTaggedServices('property_info.type_extractor', $container);
42-
$definition->replaceArgument(1, $typeExtractors);
43+
$definition->replaceArgument(1, new IteratorArgument($typeExtractors));
4344

4445
$descriptionExtractors = $this->findAndSortTaggedServices('property_info.description_extractor', $container);
45-
$definition->replaceArgument(2, $descriptionExtractors);
46+
$definition->replaceArgument(2, new IteratorArgument($descriptionExtractors));
4647

4748
$accessExtractors = $this->findAndSortTaggedServices('property_info.access_extractor', $container);
48-
$definition->replaceArgument(3, $accessExtractors);
49+
$definition->replaceArgument(3, new IteratorArgument($accessExtractors));
4950
}
5051
}

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"symfony/templating": "~2.8|~3.0",
5252
"symfony/validator": "~3.2",
5353
"symfony/yaml": "~3.2",
54-
"symfony/property-info": "~3.1",
54+
"symfony/property-info": "~3.3",
5555
"doctrine/annotations": "~1.0",
5656
"phpdocumentor/reflection-docblock": "^3.0",
5757
"twig/twig": "~1.26|~2.0",
@@ -62,7 +62,8 @@
6262
"phpdocumentor/type-resolver": "<0.2.0",
6363
"symfony/console": "<3.3",
6464
"symfony/serializer": "<3.3",
65-
"symfony/form": "<3.3"
65+
"symfony/form": "<3.3",
66+
"symfony/property-info": "<3.3"
6667
},
6768
"suggest": {
6869
"ext-apcu": "For best performance of the system caches",

src/Symfony/Component/PropertyInfo/PropertyInfoExtractor.php

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,18 @@
1818
*/
1919
class PropertyInfoExtractor implements PropertyInfoExtractorInterface
2020
{
21-
/**
22-
* @var PropertyListExtractorInterface[]
23-
*/
2421
private $listExtractors;
25-
26-
/**
27-
* @var PropertyTypeExtractorInterface[]
28-
*/
2922
private $typeExtractors;
30-
31-
/**
32-
* @var PropertyDescriptionExtractorInterface[]
33-
*/
3423
private $descriptionExtractors;
35-
36-
/**
37-
* @var PropertyAccessExtractorInterface[]
38-
*/
3924
private $accessExtractors;
4025

4126
/**
42-
* @param PropertyListExtractorInterface[] $listExtractors
43-
* @param PropertyTypeExtractorInterface[] $typeExtractors
44-
* @param PropertyDescriptionExtractorInterface[] $descriptionExtractors
45-
* @param PropertyAccessExtractorInterface[] $accessExtractors
27+
* @param iterable|PropertyListExtractorInterface[] $listExtractors
28+
* @param iterable|PropertyTypeExtractorInterface[] $typeExtractors
29+
* @param iterable|PropertyDescriptionExtractorInterface[] $descriptionExtractors
30+
* @param iterable|PropertyAccessExtractorInterface[] $accessExtractors
4631
*/
47-
public function __construct(array $listExtractors = array(), array $typeExtractors = array(), array $descriptionExtractors = array(), array $accessExtractors = array())
32+
public function __construct($listExtractors = array(), $typeExtractors = array(), $descriptionExtractors = array(), $accessExtractors = array())
4833
{
4934
$this->listExtractors = $listExtractors;
5035
$this->typeExtractors = $typeExtractors;
@@ -103,13 +88,13 @@ public function isWritable($class, $property, array $context = array())
10388
/**
10489
* Iterates over registered extractors and return the first value found.
10590
*
106-
* @param array $extractors
107-
* @param string $method
108-
* @param array $arguments
91+
* @param iterable $extractors
92+
* @param string $method
93+
* @param array $arguments
10994
*
11095
* @return mixed
11196
*/
112-
private function extract(array $extractors, $method, array $arguments)
97+
private function extract($extractors, $method, array $arguments)
11398
{
11499
foreach ($extractors as $extractor) {
115100
$value = call_user_func_array(array($extractor, $method), $arguments);

0 commit comments

Comments
 (0)
0