8000 feature #21654 [PropertyInfo] Use iterators for PropertyInfoExtractor… · symfony/symfony@8c6ad5b · GitHub
[go: up one dir, main page]

Skip to content

Commit 8c6ad5b

Browse files
feature #21654 [PropertyInfo] Use iterators for PropertyInfoExtractor (GuilhemN)
This PR was merged into the 3.3-dev branch. Discussion ---------- [PropertyInfo] Use iterators for PropertyInfoExtractor | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Most of the time, when using the cache, the property info extractors are not used: the new iterator feature looks perfect to prevent their instantiation. Commits ------- 38523a9 [PropertyInfo] Use iterators for PropertyInfoExtractor
2 parents aaa4376 + 38523a9 commit 8c6ad5b

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
@@ -20,33 +20,18 @@
2020
*/
2121
class PropertyInfoExtractor implements PropertyInfoExtractorInterface
2222
{
23-
/**
24-
* @var PropertyListExtractorInterface[]
25-
*/
2623
private $listExtractors;
27-
28-
/**
29-
* @var PropertyTypeExtractorInterface[]
30-
*/
3124
private $typeExtractors;
32-
33-
/**
34-
* @var PropertyDescriptionExtractorInterface[]
35-
*/
3625
private $descriptionExtractors;
37-
38-
/**
39-
* @var PropertyAccessExtractorInterface[]
40-
*/
4126
private $accessExtractors;
4227

4328
/**
44-
* @param PropertyListExtractorInterface[] $listExtractors
45-
* @param PropertyTypeExtractorInterface[] $typeExtractors
46-
* @param PropertyDescriptionExtractorInterface[] $descriptionExtractors
47-
* @param PropertyAccessExtractorInterface[] $accessExtractors
29+
* @param iterable|PropertyListExtractorInterface[] $listExtractors
30+
* @param iterable|PropertyTypeExtractorInterface[] $typeExtractors
31+
* @param iterable|PropertyDescriptionExtractorInterface[] $descriptionExtractors
32+
* @param iterable|PropertyAccessExtractorInterface[] $accessExtractors
4833
*/
49-
public function __construct(array $listExtractors = array(), array $typeExtractors = array(), array $descriptionExtractors = array(), array $accessExtractors = array())
34+
public function __construct($listExtractors = array(), $typeExtractors = array(), $descriptionExtractors = array(), $accessExtractors = array())
5035
{
5136
$this->listExtractors = $listExtractors;
5237
$this->typeExtractors = $typeExtractors;
@@ -105,13 +90,13 @@ public function isWritable($class, $property, array $context = array())
10590
/**
10691
* Iterates over registered extractors and return the first value found.
10792
*
108-
* @param array $extractors
109-
* @param string $method
110-
* @param array $arguments
93+
* @param iterable $extractors
94+
* @param string $method
95+
* @param array $arguments
11196
*
11297
* @return mixed
11398
*/
114-
private function extract(array $extractors, $method, array $arguments)
99+
private function extract($extractors, $method, array $arguments)
115100
{
116101
foreach ($extractors as $extractor) {
117102
$value = call_user_func_array(array($extractor, $method), $arguments);

0 commit comments

Comments
 (0)
0