Resolve PHP_INT_MAX as positive integer#684
Resolve PHP_INT_MAX as positive integer#684ondrejmirtes merged 3 commits intophpstan:masterfrom herndlm:feature/resolve-php-int-max
PHP_INT_MAX as positive integer#684Conversation
|
Ok well, looks like I broke things anyway :) I'll look into that. Discovered the makefile too late.. |
ondrejmirtes
left a comment
There was a problem hiding this comment.
This PR is mostly fine, thank you :) Also please note there are other constants that would benefit from the same treatment, for example PHP_INT_MIN is definitely one of them but there are many more.
I'd appreciate if you could go through this list and created more specific types:
Lines 113 to 157 in 43c192b
Integers can be made more specific using IntegerRangeType, strings can have AccessoryNonEmptyStringType and AccessoryNumericStringType attached to them in IntersectionType.
I'd like if you'd find some time to do it in the next PR after this one is merged. Thank you!
Right, I thought about that, but wanted to keep it simple and small here. How do you prefer the PRs for those? E.g. all in one, or grouped by affected area or type. It depends I guess.. Also: I tried to add |
|
The other constants should be tested using NodeScopeResolverTest and the
No idea why that would be happening. You should isolate the problem to a smallest file possible, run that with |
|
Thank you! |
Fixes phpstan/phpstan#5657
This is my first PR, I definitely don't know enough about phpstan internals and might have missed something.
I was no sure what this should resolve to. It would be enough and best to set it to "positive int" but I think this concept is not existing, is it? I then chose the positive range because
PHP_INT_MAXfeels not correct as that would be the value of the platform phpstan is running onInitially I tried to be smart and dynamically resolve all int constant via
constantbut realised that this a bad idea because of the already mentioned 1. What do you think?