|
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\NameScopeFactory; |
25 | 26 | use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; |
26 | 27 | use Symfony\Component\PropertyInfo\Type as LegacyType; |
@@ -75,8 +76,14 @@ public function __construct(?array $mutatorPrefixes = null, ?array $accessorPref |
75 | 76 | $this->accessorPrefixes = $accessorPrefixes ?? ReflectionExtractor::$defaultAccessorPrefixes; |
76 | 77 | $this->arrayMutatorPrefixes = $arrayMutatorPrefixes ?? ReflectionExtractor::$defaultArrayMutatorPrefixes; |
77 | 78 |
|
78 | | - $this->phpDocParser = new PhpDocParser(new TypeParser(new ConstExprParser()), new ConstExprParser()); |
79 | | - $this->lexer = new Lexer(); |
| 79 | + if (class_exists(ParserConfig::class)) { |
| 80 | + $parserConfig = new ParserConfig([]); |
| 81 | + $this->phpDocParser = new PhpDocParser($parserConfig, new TypeParser($parserConfig, new ConstExprParser($parserConfig)), new ConstExprParser($parserConfig)); |
| 82 | + $this->lexer = new Lexer($parserConfig); |
| 83 | + } else { |
| 84 | + $this->phpDocParser = new PhpDocParser(new TypeParser(new ConstExprParser()), new ConstExprParser()); |
| 85 | + $this->lexer = new Lexer(); |
| 86 | + } |
80 | 87 | $this->nameScopeFactory = new NameScopeFactory(); |
81 | 88 | $this->stringTypeResolver = new StringTypeResolver(); |
82 | 89 | $this->typeContextFactory = new TypeContextFactory($this->stringTypeResolver); |
|
0 commit comments