-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
Make array_combine() generic #3351
Comments
@ondrejmirtes I'd like to contribute this but I don't get where should I put that stub? |
Stub files (https://phpstan.org/user-guide/stub-files) are supported above userland classes, userland functions, userland methods, useland properties, builtin classes, builtin methods, built properties, but unfortunately not above builtin functions, there wasn't a use case until now. So the support for that needs to be added first. For userland functions it was done here phpstan/phpstan-src@7f07659#diff-1cf42bada627951c5878a8529e3f81cc for builtin functions it would have to be done in https://github.com/phpstan/phpstan-src/blob/master/src/Reflection/SignatureMap/NativeFunctionReflectionProvider.php. |
@b1rdex PHPStan now reports different result with your code snippet: @@ @@
+PHP 8.0 (2 errors)
+==========
+
11: Cannot access offset 'a' on array<string, int>|false.
-13: Cannot access offset 'a' on array|false.
+24: Method HelloWorld::combine() never returns false so it can be removed from the return typehint.
+
+PHP 7.1 – 7.4 (1 error)
+==========
+
+11: Cannot access offset 'a' on array<string, int>|false. Full reportPHP 8.0 (2 errors)
PHP 7.1 – 7.4 (1 error)
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
https://phpstan.org/r/59427afd-8dc6-4b14-8d40-2c52b5fc8d34
Currently,
array_combine
producesarray|false
. It should be enhanced with this:The text was updated successfully, but these errors were encountered: