Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rand() return-type extension #606

Merged
merged 13 commits into from Aug 12, 2021
Merged

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Aug 1, 2021

@@ -16,11 +17,15 @@ class RandomIntFunctionReturnTypeExtension implements \PHPStan\Type\DynamicFunct

public function isFunctionSupported(FunctionReflection $functionReflection): bool
{
return $functionReflection->getName() === 'random_int';
return in_array($functionReflection->getName(), ['random_int', 'rand']);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured functionality wise, it would be easiest to use the same ReturnTypeExtension for rand and random_int.

I did not change the class-name to not break BC

@staabm
Copy link
Contributor Author

staabm commented Aug 1, 2021

I think this is good to go.

turning the zero-args case into a positive-int was great advice, which improved types in a few spots quite a bit!

@ondrejmirtes ondrejmirtes merged commit eb15c46 into phpstan:master Aug 12, 2021
@ondrejmirtes
Copy link
Member

Thank you!

@staabm staabm deleted the rand-return branch August 27, 2021 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants