|
21 | 21 | use PHPStan\PhpDocParser\Parser\PhpDocParser;
|
22 | 22 | use PHPStan\PhpDocParser\Parser\TokenIterator;
|
23 | 23 | use PHPStan\PhpDocParser\Parser\TypeParser;
|
| 24 | +use PHPStan\PhpDocParser\ParserConfig; |
24 | 25 | use Symfony\Component\PropertyInfo\PhpStan\NameScope;
|
25 | 26 | use Symfony\Component\PropertyInfo\PhpStan\NameScopeFactory;
|
26 | 27 | use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
|
@@ -79,8 +80,14 @@ public function __construct(?array $mutatorPrefixes = null, ?array $accessorPref
|
79 | 80 | $this->accessorPrefixes = $accessorPrefixes ?? ReflectionExtractor::$defaultAccessorPrefixes;
|
80 | 81 | $this->arrayMutatorPrefixes = $arrayMutatorPrefixes ?? ReflectionExtractor::$defaultArrayMutatorPrefixes;
|
81 | 82 |
|
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 | + } |
84 | 91 | $this->nameScopeFactory = new NameScopeFactory();
|
85 | 92 | $this->stringTypeResolver = new StringTypeResolver();
|
86 | 93 | $this->typeContextFactory = new TypeContextFactory($this->stringTypeResolver);
|
|
0 commit comments