-
Notifications
You must be signed in to change notification settings - Fork 548
NeverType: accept nothing #2110
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
Conversation
|
An idea - only explicit never should have this behaviour. If you have implicit never, it means that the function signature is wrong, and you already have an error at the declaration - no need for a new error when calling it :) |
|
interessting :) you should have a look at the impact this change has on open issues: https://github.com/phpstan/phpstan-src/actions/runs/3693563281#summary-10085912763 (Issue-Bot summary) |
Oh, thanks a lot for this comment! This probably explains why it has been implemented to accept everything. I'll update this so that only the behaviour of explicit never is changed 👍 |
9d6bbfa to
dd609dd
Compare
ondrejmirtes
left a comment
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.
Thank you, it makes total sense and issue bot agrees :)
Please:
- Add a regression test for the one implemented feature request that asks for this :)
- Please add a test that shows that explicit
nevercan be passed into explicitnever:)
dd609dd to
cd5015c
Compare
|
Thank you! |
|
I'm really gonna go crazy here :D Because of this change, this now reports problem like this: So if you create a new ArrayCollection and immediately try to add something to it, it's gonna report an error. Maybe we'll have to postpone this until generics are smarter 🤔 |
|
That's phpstan/phpstan#8511 / phpstan/phpstan#6731 again, right? Did you not see the failing test Ondřej? :P |
I was surprised to find out that
NeverTypeaccepts everything. Shouldn't it be the opposite? It's the bottom type, it's empty. No value can be of this type. Why accept every value then?Consider this PR me poking around and waiting to see what builds break.