Skip to content

Add non-zero int type #2449

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

Merged
merged 2 commits into from
Jun 19, 2023
Merged

Add non-zero int type #2449

merged 2 commits into from
Jun 19, 2023

Conversation

PrinsFrank
Copy link
Contributor

For integers and floats that are used as divisors, a non-zero integer/float has to be used. This was easy to implement with integer ranges, but not easy for float ranges. How could we add that?

@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x.

@PrinsFrank PrinsFrank changed the base branch from 1.11.x to 1.10.x June 10, 2023 21:06
@ondrejmirtes
Copy link
Member

Hi, how common is to require all integers except zero? You can already express them today with int<min, -1>|int<1, max>.

As for floats - we don't have a FloatRangeType, it'd have to be added, and update all arithmetic operations in order to correctly calculate it.

@PrinsFrank
Copy link
Contributor Author

I've used that exact annotation in three different projects now, so I thought It'd be time to add an alias. If you don't think it's needed I can still use the full written form, I just thought it would be nice to have this alias.

Would you see value in adding float ranges? I would be happy to contribute something more and check if I can implement this in a new PR.

@ondrejmirtes
Copy link
Member

Hi, yes, I see value in it, you can definitely try it out :) Thank you.

@ondrejmirtes ondrejmirtes merged commit 65ff783 into phpstan:1.10.x Jun 19, 2023
@PrinsFrank PrinsFrank deleted the add-non-zero-int branch January 11, 2024 12:28
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.

None yet

3 participants