-
Notifications
You must be signed in to change notification settings - Fork 659
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
Clarify in docs that zero is not considered a positive-int #8060
Conversation
I wasn't sure from reading the docs whether or not Psalm consider zero to be positive.
Idk, "positive" has always had a clear well established meaning to me 🤷 If we're going to bother changing it though, I would say:
which provides the same information but also points people to the newer int range feature which is much more useful. Speaking of, int ranges should probably be documented there as well, and we should make sure there aren't any other scalar types missing documentation. |
I like your version @AndrolGenhald. The way I was taught in school, 'positive' means |
Wikipedia gives both definitions of positive: https://en.wikipedia.org/wiki/Sign_(mathematics)#Terminology_for_signs |
Wow, I never realized there was differing terminology there, I've only ever known [non-]positive and [non-]negative! |
btw the type I was actually looking for was the Probably not enough use cases for |
at least with integers there's only one zero! Float has +0 and -0 of course. |
Personally I've just moved to using int ranges everywhere, it's shorter and easier to understand. Before int ranges were introduced there were a lot of Edit: @orklah mentions here that apparently PHPStan supports |
@@ -12,7 +12,7 @@ The type `scalar` is the supertype of all scalar types. | |||
|
|||
### positive-int | |||
|
|||
`positive-int` allows only positive integers | |||
`positive-int` allows only positive integers (equivalent to int<1, max>) |
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.
Slight nitpick: use backticks for int<1, max>
?
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.
Done, thanks.
Oh, I thought I already added negative-int but I guess not. It should be easy to do if someone wants to add that |
Thanks! |
I wasn't sure from reading the docs whether or not Psalm consider zero to be positive.