Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 03922ec

Browse filesBrowse files
committed
[FrameworkBundle][PropertyInfo] Wire the ConstructorExtractor class
1 parent 2bac801 commit 03922ec
Copy full SHA for 03922ec

13 files changed

+74
-4
lines changed

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ CHANGELOG
2424
* Deprecate not setting the `framework.validation.email_validation_mode` config option; it will default to `html5` in 7.0
2525
* Deprecate `framework.validation.enable_annotations`, use `framework.validation.enable_attributes` instead
2626
* Deprecate `framework.serializer.enable_annotations`, use `framework.serializer.enable_attributes` instead
27+
* Wire the `Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor` class
28+
* Add new `framework.property_info.with_constructor_extractor` option to
29+
allow enabling or disabling the constructor extractor integration
2730

2831
6.3
2932
---

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class UnusedTagsPass implements CompilerPassInterface
7373
'monolog.logger',
7474
'notifier.channel',
7575
'property_info.access_extractor',
76+
'property_info.constructor_extractor',
7677
'property_info.initializable_extractor',
7778
'property_info.list_extractor',
7879
'property_info.type_extractor',

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,14 @@ private function addPropertyInfoSection(ArrayNodeDefinition $rootNode, callable
12271227
->children()
12281228
->arrayNode('property_info')
12291229
->info('Property info configuration')
1230+
->addDefaultsIfNotSet()
12301231
->{$enableIfStandalone('symfony/property-info', PropertyInfoExtractorInterface::class)}()
1232+
->children()
1233+
->booleanNode('with_constructor_extractor')
1234+
->info('Registers the constructor extractor.')
1235+
->defaultFalse()
1236+
->end()
1237+
->end()
12311238
->end()
12321239
->end()
12331240
;

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+11-2Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
use Symfony\Component\Notifier\Transport\TransportFactoryInterface as NotifierTransportFactoryInterface;
135135
use Symfony\Component\Process\Messenger\RunProcessMessageHandler;
136136
use Symfony\Component\PropertyAccess\PropertyAccessor;
137+
use Symfony\Component\PropertyInfo\Extractor\ConstructorArgumentTypeExtractorInterface;
137138
use Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor;
138139
use Symfony\Component\PropertyInfo\Extractor\PhpStanExtractor;
139140
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
@@ -411,7 +412,7 @@ public function load(array $configs, ContainerBuilder $container)
411412
}
412413

413414
if ($propertyInfoEnabled) {
414-
$this->registerPropertyInfoConfiguration($container, $loader);
415+
$this->registerPropertyInfoConfiguration($config['property_info'], $container, $loader);
415416
}
416417

417418
if ($this->readConfigEnabled('lock', $container, $config['lock'])) {
@@ -653,6 +654,8 @@ public function load(array $configs, ContainerBuilder $container)
653654
->addTag('property_info.list_extractor');
654655
$container->registerForAutoconfiguration(PropertyTypeExtractorInterface::class)
655656
->addTag('property_info.type_extractor');
657+
$container->registerForAutoconfiguration(ConstructorArgumentTypeExtractorInterface::class)
658+
->addTag('property_info.constructor_extractor');
656659
$container->registerForAutoconfiguration(PropertyDescriptionExtractorInterface::class)
657660
->addTag('property_info.description_extractor');
658661
$container->registerForAutoconfiguration(PropertyAccessExtractorInterface::class)
@@ -1999,26 +2002,32 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
19992002
}
20002003
}
20012004

2002-
private function registerPropertyInfoConfiguration(ContainerBuilder $container, PhpFileLoader $loader): void
2005+
private function registerPropertyInfoConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader): void
20032006
{
20042007
if (!interface_exists(PropertyInfoExtractorInterface::class)) {
20052008
throw new LogicException('PropertyInfo support cannot be enabled as the PropertyInfo component is not installed. Try running "composer require symfony/property-info".');
20062009
}
20072010

20082011
$loader->load('property_info.php');
20092012

2013+
if (!$config['with_constructor_extractor']) {
2014+
$container->removeDefinition('property_info.constructor_extractor');
2015+
}
2016+
20102017
if (
20112018
ContainerBuilder::willBeAvailable('phpstan/phpdoc-parser', PhpDocParser::class, ['symfony/framework-bundle', 'symfony/property-info'])
20122019
&& ContainerBuilder::willBeAvailable('phpdocumentor/type-resolver', ContextFactory::class, ['symfony/framework-bundle', 'symfony/property-info'])
20132020
) {
20142021
$definition = $container->register('property_info.phpstan_extractor', PhpStanExtractor::class);
20152022
$definition->addTag('property_info.type_extractor', ['priority' => -1000]);
2023+
$definition->addTag('property_info.constructor_extractor', ['priority' => -1000]);
20162024
}
20172025

20182026
if (ContainerBuilder::willBeAvailable('phpdocumentor/reflection-docblock', DocBlockFactoryInterface::class, ['symfony/framework-bundle', 'symfony/property-info'], true)) {
20192027
$definition = $container->register('property_info.php_doc_extractor', PhpDocExtractor::class);
20202028
$definition->addTag('property_info.description_extractor', ['priority' => -1000]);
20212029
$definition->addTag('property_info.type_extractor', ['priority' => -1001]);
2030+
$definition->addTag('property_info.constructor_extractor', ['priority' => -1001]);
20222031
}
20232032

20242033
if ($container->getParameter('kernel.debug')) {

‎src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
use Symfony\Component\HttpKernel\KernelEvents;
5858
use Symfony\Component\Messenger\DependencyInjection\MessengerPass;
5959
use Symfony\Component\Mime\DependencyInjection\AddMimeTypeGuesserPass;
60+
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoConstructorPass;
6061
use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass;
6162
use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass;
6263
use Symfony\Component\Scheduler\DependencyInjection\AddScheduleMessengerPass;
@@ -162,6 +163,7 @@ public function build(ContainerBuilder $container)
162163
$container->addCompilerPass(new FragmentRendererPass());
163164
$this->addCompilerPassIfExists($container, SerializerPass::class);
164165
$this->addCompilerPassIfExists($container, PropertyInfoPass::class);
166+
$this->addCompilerPassIfExists($container, PropertyInfoConstructorPass::class);
165167
$container->addCompilerPass(new ControllerArgumentValueResolverPass());
166168
$container->addCompilerPass(new CachePoolPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 32);
167169
$container->addCompilerPass(new CachePoolClearerPass(), PassConfig::TYPE_AFTER_REMOVING);

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/property_info.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/property_info.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

14+
use Symfony\Component\PropertyInfo\Extractor\ConstructorExtractor;
1415
use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor;
1516
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
1617
use Symfony\Component\PropertyInfo\PropertyDescriptionExtractorInterface;
@@ -43,9 +44,14 @@
4344
->set('property_info.reflection_extractor', ReflectionExtractor::class)
4445
->tag('property_info.list_extractor', ['priority' => -1000])
4546
->tag('property_info.type_extractor', ['priority' => -1002])
47+
->tag('property_info.constructor_extractor', ['priority' => -1002])
4648
->tag('property_info.access_extractor', ['priority' => -1000])
4749
->tag('property_info.initializable_extractor', ['priority' => -1000])
4850

51+
->set('property_info.constructor_extractor', ConstructorExtractor::class)
52+
->args([[]])
53+
->tag('property_info.type_extractor', ['priority' => -999])
54+
4955
->alias(PropertyReadInfoExtractorInterface::class, 'property_info.reflection_extractor')
5056
->alias(PropertyWriteInfoExtractorInterface::class, 'property_info.reflection_extractor')
5157
;

‎src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@
331331

332332
<xsd:complexType name="property_info">
333333
<xsd:attribute name="enabled" type="xsd:boolean" />
334+
<xsd:attribute name="with-constructor-extractor" type="xsd:boolean" />
334335
</xsd:complexType>
335336

336337
<xsd:complexType name="cache">

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ protected static function getBundleDefaultConfig()
625625
],
626626
'property_info' => [
627627
'enabled' => !class_exists(FullStack::class),
628+
'with_constructor_extractor' => false,
628629
],
629630
'router' => [
630631
'enabled' => false,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', [
4+
'annotations' => false,
5+
'http_method_override' => false,
6+
'handle_all_throwables' => true,
7+
'php_errors' => ['log' => true],
8+
'property_info' => [
9+
'enabled' => true,
10+
'with_constructor_extractor' => true,
11+
],
12+
]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config http-method-override="false" handle-all-throwables="true">
9+
<framework:annotations enabled="false" />
10+
<framework:php-errors log="true" />
11+
<framework:property-info enabled="true" with-constructor-extractor="true" />
12+
</framework:config>
13+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
framework:
2+
annotations: false
3+
http_method_override: false
4+
handle_all_throwables: true
5+
php_errors:
6+
log: true
7+
property_info:
8+
enabled: true
9+
with_constructor_extractor: true

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTestCase.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,6 +1669,14 @@ public function testPropertyInfoEnabled()
16691669
{
16701670
$container = $this->createContainerFromFile('property_info');
16711671
$this->assertTrue($container->has('property_info'));
1672+
$this->assertFalse($container->has('property_info.constructor_extractor'));
1673+
}
1674+
1675+
public function testPropertyInfoWithConstructorExtractorEnabled()
1676+
{
1677+
$container = $this->createContainerFromFile('property_info_with_constructor_extractor');
1678+
$this->assertTrue($container->has('property_info'));
1679+
$this->assertTrue($container->has('property_info.constructor_extractor'));
16721680
}
16731681

16741682
public function testPropertyInfoCacheActivated()

‎src/Symfony/Component/PropertyInfo/Extractor/ConstructorArgumentTypeExtractorInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/ConstructorArgumentTypeExtractorInterface.php
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
* Infers the constructor argument type.
1818
*
1919
* @author Dmitrii Poddubnyi <dpoddubny@gmail.com>
20-
*
21-
* @internal
2220
*/
2321
interface ConstructorArgumentTypeExtractorInterface
2422
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.