-
-
Notifications
You must be signed in to change notification settings - Fork 898
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
V2 false positive type error within is_resource conditional #12111
Comments
This is expected behaviour. |
I think this may be due to the fact that is_resource returns false for closed resources, and so is not sufficient for type safety. I don't know what the alternative here is, however, and I suggest a better error message if possible! |
@ondrejmirtes if that's the case then why does it still throw the error for open-resource? |
Those are currently just aliases for |
@herndlm that would certainly be helpful in my case - I can't just change the conditional for a patch release, so I'll have to roll phpstan back :-/ |
I'll look into it and will include you in the PR if it works. Currently thinking about adding a |
fyi I did some digging and playing around with an implementation, but changing something as big as I was thinking seems too risky and not worth it. E.g. was thinking of a) adding additional type information to psalm is separating those 2 currently, which feels somewhat reasonable to me, but there are also issues reported there, see e.g. vimeo/psalm#5854 or vimeo/psalm#2763. I think both solutions have issues and maybe it's best to quote @muglug from one of the above links
I feel whatever I do here will break something :/ |
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. |
Bug report
See the failing phpstan run
We are getting a type error within a union type because "resource" is not supported, even when the call is wrapped in
if (!is_resource) { ... }
.This is a regression since v1
Code snippet that reproduces the problem
https://phpstan.org/r/73167be4-3cfc-43a8-8613-9041aa97a126
Expected output
The issue reported is incorrect
Did PHPStan help you today? Did it make you happy in any way?
Yes, it made me very happy 😊
The text was updated successfully, but these errors were encountered: