diff --git a/src/Infrastructure/PropertyInfo/Extractor/PollyfillPhpStanExtractor.php b/src/Infrastructure/PropertyInfo/Extractor/PollyfillPhpStanExtractor.php index 7b7533a..2c2cda5 100644 --- a/src/Infrastructure/PropertyInfo/Extractor/PollyfillPhpStanExtractor.php +++ b/src/Infrastructure/PropertyInfo/Extractor/PollyfillPhpStanExtractor.php @@ -23,6 +23,7 @@ use PHPStan\PhpDocParser\Parser\PhpDocParser; use PHPStan\PhpDocParser\Parser\TokenIterator; use PHPStan\PhpDocParser\Parser\TypeParser; +use PHPStan\PhpDocParser\ParserConfig; use Symfony\Component\PropertyInfo\Extractor\ConstructorArgumentTypeExtractorInterface; use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface; @@ -77,8 +78,18 @@ public function __construct(?array $mutatorPrefixes = null, ?array $accessorPref $this->accessorPrefixes = $accessorPrefixes ?? ReflectionExtractor::$defaultAccessorPrefixes; $this->arrayMutatorPrefixes = $arrayMutatorPrefixes ?? ReflectionExtractor::$defaultArrayMutatorPrefixes; - $this->phpDocParser = new PhpDocParser(new TypeParser(new ConstExprParser()), new ConstExprParser()); - $this->lexer = new Lexer(); + if (class_exists(ParserConfig::class)) { // PhpStan 2.0 + $config = new ParserConfig([]); + $this->lexer = new Lexer($config); + $this->phpDocParser = new PhpDocParser( + $config, + new TypeParser($config, new ConstExprParser($config)), + new ConstExprParser($config) + ); + } else { + $this->lexer = new Lexer(); + $this->phpDocParser = new PhpDocParser(new TypeParser(new ConstExprParser()), new ConstExprParser()); + } $this->nameScopeFactory = new NameScopeFactory(); } diff --git a/src/RestClientBuilder.php b/src/RestClientBuilder.php index 309488c..9ecd6b2 100644 --- a/src/RestClientBuilder.php +++ b/src/RestClientBuilder.php @@ -98,12 +98,12 @@ public static function create(PsrHttpClient $client, ?string $apiKey = null, ?st $typeExtractors = []; /* @infection-ignore-all */ - if (isOldPackage('symfony/property-info', '6.1')) { + if (isOldPackage('symfony/property-info', '7.1.8')) { $typeExtractors[] = new PollyfillPhpStanExtractor(); } /* @infection-ignore-all */ - if (!isOldPackage('symfony/property-info', '6.1')) { + if (!isOldPackage('symfony/property-info', '7.1.8')) { $typeExtractors[] = new PhpStanExtractor(); }