Skip to content

Conversation

@IanDelMar
Copy link
Contributor

Types may depend on the PHPStan version used--especially when a dynamic return type extension relies on types inferred by PHPStan.

Example from SlashitFunctionsDynamicFunctionReturnTypeExtension, where the type depends on PHPStan’s handling of rtrim():

$type = $scope->getType(new FuncCall(new FullyQualified('rtrim'), [$functionCall->getArgs()[0], new Arg(new String_('/\\'))]));

Among other cases, this can cause tests to fail in the lowest-deps build. To avoid bumping the required PHPStan version, this PR introduces the InstalledPhpStanVersion class and uses it in DynamicReturnTypeExtensionTest to avoid gathering types for versions that produce different results than the latest.

The types returned in the lowest supported version should still be checked to rule out incorrect cases. This has been done for data/slashit-functions.php. We could also add, e.g., data/slashit-functions-bc.php with assertions that pass with the lowest PHPStan version. This has not been done yet.

@szepeviktor
Copy link
Owner

That is my Ian!
Supporting 28 years old software!

@szepeviktor szepeviktor merged commit aa722f0 into szepeviktor:2.x Sep 14, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants