8000 feature #40457 [PropertyInfo] Add `PhpStanExtractor` (Korbeil) · symfony/framework-bundle@e8596dd · GitHub
[go: up one dir, main page]

Skip to content
10000

Commit e8596dd

Browse files
committed
feature #40457 [PropertyInfo] Add PhpStanExtractor (Korbeil)
This PR was merged into the 5.4 branch. Discussion ---------- [PropertyInfo] Add `PhpStanExtractor` | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #38093 | License | MIT | Doc PR | symfony/symfony-docs#... This PR will add a PhpStanExtractor that is based on `phpstan/phpdoc-parser` library. The PhpStan library allows us to manage union types in collection key values that we don't manage today. ### Todo - [x] PhpStanExtractor - [x] Add tests for unions types - [x] Add FrameworkBundle glue (use this extractor if `phpstan/phpdoc-parser` is present) - [x] Update CHANGELOG Related PR: - symfony/serializer-pack#3 put the PhpStanExtractor as default extractor to use on the `serializer-pack` package. Commits ------- 9931c3705d Add PhpStanExtractor
2 parents bccee1d + 89303fb commit e8596dd

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CHANGELOG
1919
* Bind the `default_context` parameter onto serializer's encoders and normalizers
2020
* Add support for `statusCode` default parameter when loading a template directly from route using the `Symfony\Bundle\FrameworkBundle\Controller\TemplateController` controller
2121
* Deprecate `translation:update` command, use `translation:extract` instead
22+
* Add `PhpStanExtractor` support for the PropertyInfo component
2223

2324
5.3
2425
---

DependencyInjection/FrameworkExtension.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Doctrine\Common\Annotations\Reader;
1717
use Http\Client\HttpClient;
1818
use phpDocumentor\Reflection\DocBlockFactoryInterface;
19+
use PHPStan\PhpDocParser\Parser\PhpDocParser;
1920
use Psr\Cache\CacheItemPoolInterface;
2021
use Psr\Container\ContainerInterface as PsrContainerInterface;
2122
use Psr\EventDispatcher\EventDispatcherInterface as PsrEventDispatcherInterface;
@@ -160,6 +161,7 @@
160161
use Symfony\Component\Notifier\Recipient\Recipient;
161162
use Symfony\Component\Notifier\Transport\TransportFactoryInterface as NotifierTransportFactoryInterface;
162163
use Symfony\Component\PropertyAccess\PropertyAccessor;
164+
use Symfony\Component\PropertyInfo\Extractor\PhpStanExtractor;
163165
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
164166
use Symfony\Component\PropertyInfo\PropertyDescriptionExtractorInterface;
165167
use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
@@ -1833,6 +1835,14 @@ private function registerPropertyInfoConfiguration(ContainerBuilder $container,
18331835

18341836
$loader->load('property_info.php');
18351837

1838+
if (
1839+
ContainerBuilder::willBeAvailable('phpstan/phpdoc-parser', PhpDocParser::class, ['symfony/framework-bundle', 'symfony/property-info'], true)
1840+
&& ContainerBuilder::willBeAvailable('phpdocumentor/type-resolver', PhpDocParser::class, ['symfony/framework-bundle', 'symfony/property-info'], true)
1841+
) {
1842+
$definition = $container->register('property_info.phpstan_extractor', PhpStanExtractor::class);
1843+
$definition->addTag('property_info.type_extractor', ['priority' => -1000]);
1844+
}
1845+
18361846
if (ContainerBuilder::willBeAvailable('phpdocumentor/reflection-docblock', DocBlockFactoryInterface::class, ['symfony/framework-bundle', 'symfony/property-info'], true)) {
18371847
$definition = $container->register('property_info.php_doc_extractor', 'Symfony\Component\PropertyInfo\Extractor\PhpDocExtractor');
18381848
$definition->addTag('property_info.description_extractor', ['priority' => -1000]);

0 commit comments

Comments
 (0)
0