Skip to content

Commit 1000754

Browse files
committed
Merge branch '7.1' into 7.2
* 7.1: fix support for phpstan/phpdoc-parser 2
2 parents 3ee7490 + 1d88940 commit 1000754

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
@@ -146,7 +146,7 @@
146146
"php-http/discovery": "^1.15",
147147
"php-http/httplug": "^1.0|^2.0",
148148
"phpdocumentor/reflection-docblock": "^5.2",
149-
"phpstan/phpdoc-parser": "^1.0",
149+
"phpstan/phpdoc-parser": "^1.0|^2.0",
150150
"predis/predis": "^1.1|^2.0",
151151
"psr/http-client": "^1.0",
152152
"psr/simple-cache": "^1.0|^2.0|^3.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\NameScope;
2526
use Symfony\Component\PropertyInfo\PhpStan\NameScopeFactory;
2627
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
@@ -79,8 +80,14 @@ public function __construct(?array $mutatorPrefixes = null, ?array $accessorPref
7980
$this->accessorPrefixes = $accessorPrefixes ?? ReflectionExtractor::$defaultAccessorPrefixes;
8081
$this->arrayMutatorPrefixes = $arrayMutatorPrefixes ?? ReflectionExtractor::$defaultArrayMutatorPrefixes;
8182

82-
$this->phpDocParser = new PhpDocParser(new TypeParser(new ConstExprParser()), new ConstExprParser());
83-
$this->lexer = new Lexer();
83+
if (class_exists(ParserConfig::class)) {
84+
$parserConfig = new ParserConfig([]);
85+
$this->phpDocParser = new PhpDocParser($parserConfig, new TypeParser($parserConfig, new ConstExprParser($parserConfig)), new ConstExprParser($parserConfig));
86+
$this->lexer = new Lexer($parserConfig);
87+
} else {
88+
$this->phpDocParser = new PhpDocParser(new TypeParser(new ConstExprParser()), new ConstExprParser());
89+
$this->lexer = new Lexer();
90+
}
8491
$this->nameScopeFactory = new NameScopeFactory();
8592
$this->stringTypeResolver = new StringTypeResolver();
8693
$this->typeContextFactory = new TypeContextFactory($this->stringTypeResolver);

src/Symfony/Component/PropertyInfo/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"symfony/cache": "^6.4|^7.0",
3333
"symfony/dependency-injection": "^6.4|^7.0",
3434
"phpdocumentor/reflection-docblock": "^5.2",
35-
"phpstan/phpdoc-parser": "^1.0"
35+
"phpstan/phpdoc-parser": "^1.0|^2.0"
3636
},
3737
"conflict": {
3838
"phpdocumentor/reflection-docblock": "<5.2",

0 commit comments

Comments
 (0)