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

modulo '1' is always zero #973

Merged
merged 5 commits into from Feb 6, 2022
Merged

modulo '1' is always zero #973

merged 5 commits into from Feb 6, 2022

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Feb 1, 2022

src/Analyser/MutatingScope.php Outdated Show resolved Hide resolved
$rightType->getValue() === 0
|| $rightType->getValue() === 0.0
$scalarType->getValue() === 0
|| $scalarType->getValue() === 0.0
Copy link
Member

Choose a reason for hiding this comment

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

What about '0' here? Again, you can try ->toInteger().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this code was existant before this PR and covers a different use-case.
should I change it with this PR nevertheless , or better do so in a different PR?

Copy link
Member

Choose a reason for hiding this comment

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

You can do it here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

newly added testcases in 578e96d show that division by '0' and other falsy values work as expected.
so IMO we just leave this as is, right?

@staabm staabm marked this pull request as ready for review February 1, 2022 20:40
@ondrejmirtes ondrejmirtes merged commit 39e5e0c into phpstan:master Feb 6, 2022
@ondrejmirtes
Copy link
Member

Thank you.

@staabm staabm deleted the modulo1 branch February 6, 2022 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants