diff --git a/conf/bleedingEdge.neon b/conf/bleedingEdge.neon index 173734d56a..6d4d61af81 100644 --- a/conf/bleedingEdge.neon +++ b/conf/bleedingEdge.neon @@ -36,3 +36,4 @@ parameters: strictStaticMethodTemplateTypeVariance: true propertyVariance: true genericPrototypeMessage: true + stricterFunctionMap: true diff --git a/conf/config.neon b/conf/config.neon index cc15584c2a..5676c7aba3 100644 --- a/conf/config.neon +++ b/conf/config.neon @@ -66,6 +66,7 @@ parameters: strictStaticMethodTemplateTypeVariance: false propertyVariance: false genericPrototypeMessage: false + stricterFunctionMap: false fileExtensions: - php checkAdvancedIsset: false @@ -302,6 +303,7 @@ parametersSchema: strictStaticMethodTemplateTypeVariance: bool() propertyVariance: bool() genericPrototypeMessage: bool() + stricterFunctionMap: bool() ]) fileExtensions: listOf(string()) checkAdvancedIsset: bool() @@ -936,6 +938,8 @@ services: - class: PHPStan\Reflection\SignatureMap\FunctionSignatureMapProvider + arguments: + stricterFunctionMap: %featureToggles.stricterFunctionMap% autowired: - PHPStan\Reflection\SignatureMap\FunctionSignatureMapProvider diff --git a/resources/functionMap_bleedingEdge.php b/resources/functionMap_bleedingEdge.php new file mode 100644 index 0000000000..0539c9db7d --- /dev/null +++ b/resources/functionMap_bleedingEdge.php @@ -0,0 +1,10 @@ + [ + + ], + 'old' => [ + + ] +]; diff --git a/src/Reflection/SignatureMap/FunctionSignatureMapProvider.php b/src/Reflection/SignatureMap/FunctionSignatureMapProvider.php index d4ce2b06af..fe518371a8 100644 --- a/src/Reflection/SignatureMap/FunctionSignatureMapProvider.php +++ b/src/Reflection/SignatureMap/FunctionSignatureMapProvider.php @@ -32,6 +32,7 @@ public function __construct( private SignatureMapParser $parser, private InitializerExprTypeResolver $initializerExprTypeResolver, private PhpVersion $phpVersion, + private bool $stricterFunctionMap, ) { } @@ -178,6 +179,15 @@ public function getSignatureMap(): array $signatureMap = array_change_key_case($signatureMap, CASE_LOWER); + if ($this->stricterFunctionMap) { + $stricterFunctionMap = require __DIR__ . '/../../../resources/functionMap_bleedingEdge.php'; + if (!is_array($stricterFunctionMap)) { + throw new ShouldNotHappenException('Signature map could not be loaded.'); + } + + $signatureMap = $this->computeSignatureMap($signatureMap, $stricterFunctionMap); + } + if ($this->phpVersion->getVersionId() >= 70400) { $php74MapDelta = require __DIR__ . '/../../../resources/functionMap_php74delta.php'; if (!is_array($php74MapDelta)) { diff --git a/tests/PHPStan/Reflection/SignatureMap/Php8SignatureMapProviderTest.php b/tests/PHPStan/Reflection/SignatureMap/Php8SignatureMapProviderTest.php index 910e6eaf93..9a8c6620c1 100644 --- a/tests/PHPStan/Reflection/SignatureMap/Php8SignatureMapProviderTest.php +++ b/tests/PHPStan/Reflection/SignatureMap/Php8SignatureMapProviderTest.php @@ -153,6 +153,7 @@ private function createProvider(): Php8SignatureMapProvider self::getContainer()->getByType(SignatureMapParser::class), self::getContainer()->getByType(InitializerExprTypeResolver::class), $phpVersion, + true, ), self::getContainer()->getByType(FileNodesFetcher::class), self::getContainer()->getByType(FileTypeMapper::class), diff --git a/tests/PHPStan/Reflection/SignatureMap/SignatureMapParserTest.php b/tests/PHPStan/Reflection/SignatureMap/SignatureMapParserTest.php index bfcbeeca56..8b7c9c5da2 100644 --- a/tests/PHPStan/Reflection/SignatureMap/SignatureMapParserTest.php +++ b/tests/PHPStan/Reflection/SignatureMap/SignatureMapParserTest.php @@ -496,7 +496,7 @@ public function dataParseAll(): array public function testParseAll(int $phpVersionId): void { $parser = self::getContainer()->getByType(SignatureMapParser::class); - $provider = new FunctionSignatureMapProvider($parser, self::getContainer()->getByType(InitializerExprTypeResolver::class), new PhpVersion($phpVersionId)); + $provider = new FunctionSignatureMapProvider($parser, self::getContainer()->getByType(InitializerExprTypeResolver::class), new PhpVersion($phpVersionId), true); $signatureMap = $provider->getSignatureMap(); $reflector = self::getContainer()->getByType(Reflector::class);