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
Conversation
@@ -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']); |
There was a problem hiding this comment.
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
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! |
Thank you! |
closes phpstan/phpstan#5402