-
Notifications
You must be signed in to change notification settings - Fork 478
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
Resolve PHP_INT_MAX
as positive integer
#684
Resolve PHP_INT_MAX
as positive integer
#684
Conversation
Ok well, looks like I broke things anyway :) I'll look into that. Discovered the makefile too late.. |
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.
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
- ICONV_IMPL | |
- LIBXML_VERSION | |
- LIBXML_DOTTED_VERSION | |
- PHP_VERSION | |
- PHP_MAJOR_VERSION | |
- PHP_MINOR_VERSION | |
- PHP_RELEASE_VERSION | |
- PHP_VERSION_ID | |
- PHP_EXTRA_VERSION | |
- PHP_WINDOWS_VERSION_MAJOR | |
- PHP_WINDOWS_VERSION_MINOR | |
- PHP_WINDOWS_VERSION_BUILD | |
- PHP_ZTS | |
- PHP_DEBUG | |
- PHP_MAXPATHLEN | |
- PHP_OS | |
- PHP_OS_FAMILY | |
- PHP_SAPI | |
- PHP_EOL | |
- PHP_INT_MAX | |
- PHP_INT_MIN | |
- PHP_INT_SIZE | |
- PHP_FLOAT_DIG | |
- PHP_FLOAT_EPSILON | |
- PHP_FLOAT_MIN | |
- PHP_FLOAT_MAX | |
- DEFAULT_INCLUDE_PATH | |
- PEAR_INSTALL_DIR | |
- PEAR_EXTENSION_DIR | |
- PHP_EXTENSION_DIR | |
- PHP_PREFIX | |
- PHP_BINDIR | |
- PHP_BINARY | |
- PHP_MANDIR | |
- PHP_LIBDIR | |
- PHP_DATADIR | |
- PHP_SYSCONFDIR | |
- PHP_LOCALSTATEDIR | |
- PHP_CONFIG_FILE_PATH | |
- PHP_CONFIG_FILE_SCAN_DIR | |
- PHP_SHLIB_SUFFIX | |
- PHP_FD_SETSIZE | |
- OPENSSL_VERSION_NUMBER | |
- ZEND_DEBUG_BUILD | |
- ZEND_THREAD_SAFE |
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_MAX
feels 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
constant
but realised that this a bad idea because of the already mentioned 1. What do you think?