[FP] Callable parameter usage violates definition: instanceof issue
| Subject | Details |
|---|---|
| Plugin | Php Inspections (EA Ultimate) last version |
Current behaviour
Hi,
In our project, we have a structure of classes and interfaces like this:
interface Vehicle {
}
abstract class Car implements Vehicle{
}
interface ElectricVehicle extends Vehicle{
}
class ElectricCar extends Car implements ElectricVehicle{
}
function foo(Car $car)
{
if ($car instanceof ElectricVehicle) {}
//elseif($car instanceof GasVehicle){}
//elseif($car instanceof NuclearVehicle){}
}
The check with instanceof throws a warning "It seems to be always false (classes are not related)." The classes are not directly related but Car is abstract so it will never be sent "as is". When we look at the example, the child of Car is ElectricCar, which implements ElectricVehicle.
It is kinda related with https://github.com/kalessil/phpinspectionsea/issues/902
Maybe this will be difficult to solve. In this case, is it possible to add a settings to disable this specific check?
Thanks
I think this is related, if not Il make an separate issue.

get the above error from this row:
if($exception instanceof \RuntimeException && !$exception instanceof HttpExceptionInterface) {
Trying to exclude HttpException from the test of RuntimeException.
class HttpException extends \RuntimeException implements HttpExceptionInterface
- \RuntimeException
- \Symfony\Component\HttpKernel\Exception\HttpException
- \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface