-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
I'm getting what I think is a false positive when I'm using interface_exists()- I've got an if statement like this:
namespace Foo;
use BarInterface;
class Example
{
public function exampleFalsePositive(string $classNameThatMightImplementInterfaceBar)
{
if (
interface_exists(BarInterface::class) &&
is_a($classNameThatMightImplementInterfaceBar, BarInterface::class, true)
) {
foreach ($classNameThatMightImplementInterfaceBar::methodDefinedInBar() as $thing) {
// do stuff here
}
}
}
}Now the issue is that in my current environment, interface Bar does not exist, so the fact that was not found should be moot given that I'm checking if it was found with interface_exists().
What I would be expecting is that if a class/interface name was not found but it's used inside an interface_exists() or class_exists call that it should pass in a similar fashion to how calling a method defined in interface A on an object returned from a method whose return type is interface B passes when you wrap the method in an instanceof check.
Thoughts?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels