Phpinspectionsea: Callable parameter usage violates definition should not check interfaces

Created on 27 Apr 2018  路  3Comments  路  Source: kalessil/phpinspectionsea

I don't know if it could be generalized, but certainly it should be skipped for \assert(). The following code will fails, but is a valid check.

interface MyInterface
{
}

class MyClass implements MyInterface
{
    public function check(MyClass $myClass)
    {
        \assert($myClass instanceof MyInterface);
    }
}
question

All 3 comments

Why? I don't see the point:

  • if the interface is important, it can be placed as the parameter type declaration
  • if the interfaces get removed, the class still keep the implementation

Can you share your use case please (currently the report warning seems to fullfill its' intention)?

I think this case is similar to :

 function check(string $a) {
       if(is_string($a)){
      }
}

But I can be wrong.

Re-visiting the ticket after a while. The check has found the dead code (probably existing before introducing parameter types), hence closing the issue.

@rentalhost, with a fresh look - isn't it the dead code.

Was this page helpful?
0 / 5 - 0 ratings