-
Notifications
You must be signed in to change notification settings - Fork 665
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
MissingDependency is reported even if guarded for said dependency #8258
Comments
I found these snippets: https://psalm.dev/r/ba929c576a<?php
class Bar implements Foo {}
function takesAnInt(): void {
if (!interface_exists(Foo::class)) {
return;
}
new Bar();
}
|
Well, as far as Psalm can know, you guarded against a class that doesn't exists because you made a typo in the name and it's exactly what it wants to warn you about. Or it could also be a case where it's just an issue with the autoloader provided to Psalm, which you also should be warned about. I'd just suppress those, it's a pretty niche pattern that'd be hard to handle |
I do think though that the fact that |
I found these snippets: https://psalm.dev/r/20b3f55d85<?php
class Bar implements Foo {}
function takesAnInt(): void {
if (!class_exists(Foo::class)) {
return;
}
new Bar();
}
|
I'm fine with that :) |
@ostrolucky You also have to conditionally define the class (which is terrible for Psalm's analysis), because otherwise PHP will crash if it's autoloaded whether or not you construct it: https://3v4l.org/XZROZ Conditionally defining does remove the |
I found these snippets: https://psalm.dev/r/5aff6f4584<?php
if (interface_exists(Foo::class)) {
class Bar implements Foo {}
} else {
class Bar {}
}
function takesAnInt(): void {
if (!interface_exists(Foo::class)) {
return;
}
new Bar();
}
|
- psalm issue: vimeo/psalm#8258 Signed-off-by: Arthur Schiwon <[email protected]>
- psalm issue: vimeo/psalm#8258 Signed-off-by: Arthur Schiwon <[email protected]>
- psalm issue: vimeo/psalm#8258 Signed-off-by: Arthur Schiwon <[email protected]>
- psalm issue: vimeo/psalm#8258 Signed-off-by: Arthur Schiwon <[email protected]>
- psalm issue: vimeo/psalm#8258 Signed-off-by: Arthur Schiwon <[email protected]>
https://psalm.dev/r/ba929c576a
The text was updated successfully, but these errors were encountered: