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

Fix the return types of round()/ceil()/floor() #729

Merged
merged 17 commits into from Feb 3, 2022

Conversation

johnbillion
Copy link
Contributor

On PHP < 8 these functions return boolean false when the $num parameter is an array: https://3v4l.org/J9KkP

PHPStan correctly reports an error if the type of $num is known and not int|float, but it's possible for the type not to be known.

This playground example is as good as I could manage: https://phpstan.org/r/59f77cf2-a658-4f2b-9630-80c778714ab2

@johnbillion
Copy link
Contributor Author

I'm not sure what the failing tests are telling me. They seem unrelated to this change but I don't have a good enough understanding of PHPStan internals to know for sure. Guidance appreciated.

@ondrejmirtes
Copy link
Member

I'd love to use this, can you please rebase and make the build green? Thank you.

@ondrejmirtes
Copy link
Member

There's still a lot of failures.

@johnbillion
Copy link
Contributor Author

It's difficult to determine what's failing due to this change and what's also failing in master currently. I'll wait until master is green then take another look.

@ondrejmirtes
Copy link
Member

Yeah, you can safely rebase now :)

@ondrejmirtes ondrejmirtes merged commit afc49fd into phpstan:master Feb 3, 2022
@ondrejmirtes
Copy link
Member

Thank you!

@johnbillion
Copy link
Contributor Author

Thanks for helping get it over the finishing line :-)

@johnbillion johnbillion deleted the rounding-return-types branch February 3, 2022 11:53
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