8000 fix support for phpstan/phpdoc-parser 2 · symfony/symfony@ae236a9 · GitHub
[go: up one dir, main page]

Skip to content

Commit ae236a9

Browse files
committed
fix support for phpstan/phpdoc-parser 2
1 parent 2c7c4ba commit ae236a9

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
"pda/pheanstalk": "^4.0",
138138
"php-http/httplug": "^1.0|^2.0",
139139
"php-http/message-factory": "^1.0",
140-
"phpstan/phpdoc-parser": "^1.0",
140+
"phpstan/phpdoc-parser": "^1.0|^2.0",
141141
"predis/predis": "^1.1|^2.0",
142142
"psr/http-client": "^1.0",
143143
"psr/simple-cache": "^1.0|^2.0",

src/Symfony/Component/PropertyInfo/Extractor/PhpStanExtractor.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use PHPStan\PhpDocParser\Parser\PhpDocParser;
2222
use PHPStan\PhpDocParser\Parser\TokenIterator;
2323
use PHPStan\PhpDocParser\Parser\TypeParser;
24+
use PHPStan\PhpDocParser\ParserConfig;
2425
use Symfony\Component\PropertyInfo\PhpStan\NameScopeFactory;
2526
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
2627
use Symfony\Component\PropertyInfo\Type;
@@ -73,8 +74,14 @@ public function __construct(?array $mutatorPrefixes = null, ?array $accessorPref
7374
$this->accessorPrefixes = $accessorPrefixes ?? ReflectionExtractor::$defaultAccessorPrefixes;
7475
$this->arrayMutatorPrefixes = $arrayMutatorPrefixes ?? ReflectionExtractor::$defaultArrayMutatorPrefixes;
7576

76-
$this->phpDocParser = new PhpDocParser(new TypeParser(new ConstExprParser()), new ConstExprParser());
77-
$this->lexer = new Lexer();
77+
if (class_exists(ParserConfig::class)) {
78+
$parserConfig = new ParserConfig([]);
79+
$this->phpDocParser = new PhpDocParser($parserConfig, new TypeParser($parserConfig, new ConstExprParser($parserConfig)), new ConstExprParser($parserConfig));
80+
$this->lexer = new Lexer($parserConfig);
81+
} else {
82+
$this->phpDocParser = new PhpDocParser(new TypeParser(new ConstExprParser()), new ConstExprParser());
83+
$this->lexer = new Lexer();
84+
}
7885
$this->nameScopeFactory = new NameScopeFactory();
7986
}
8087

src/Symfony/Component/PropertyInfo/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"symfony/cache": "^4.4|^5.0|^6.0",
3434
"symfony/dependency-injection": "^4.4|^5.0|^6.0",
3535
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
36-
"phpstan/phpdoc-parser": "^1.0",
36+
"phpstan/phpdoc-parser": "^1.0|^2.0",
3737
"doctrine/annotations": "^1.10.4|^2"
3838
},
3939
"conflict": {

0 commit comments

Comments
 (0)
0