-
Notifications
You must be signed in to change notification settings - Fork 729
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
Impossible intersection types are not checked at compile time #3706
Comments
Hi @Kenny1911. This is something static analysis can help you with. IMO, this doesn't need solving in the PHP engine, as it will just add more runtime burden. @Girgias thoughts? |
@iluuu1994 , however PHP does check |
That's not quite the same:
The engine makes assertions about members of intersection types being class types. I'm not sure about hard, but at least for |
Yes, as currently class-types are not loaded at compile time except where necessary (for variance checks). Changing this behaviour would at least require an RFC to allow the engine to autoload classes where previously it was not required. Checking for |
Right. Given this would either require to:
I don't think this should be solved. |
I agree to WONTFIX, but we should probably improve the documentation on intersection types. |
Just to note, that this is described in the type declaration page of the documentation. |
Description
The following code:
https://3v4l.org/sKIr0
I use intersection type
Foo&Bar
for function argument.Actually, there is no type that would be comparable to
Foo&Bar
. Therefore,Foo&Bar
is equivalent to the typenever
.If i use
never
in argument type, PHP Fatal Error will be thrown. But if i useFoo&Bar
, no error will occur.Resulted in this output:
Nothing
But I expected this output instead:
PHP Version
PHP 8.3.11
Operating System
Ubuntu 20.04
The text was updated successfully, but these errors were encountered: