Psalm: UndefinedInterfaceMethod on extended system interfaces

Created on 28 Mar 2019  路  6Comments  路  Source: vimeo/psalm

When extending from an system interfaces the inheritance is not checked.

interface ContainerInterface extends \RecursiveIterator
{
    /**
     * @param string|callable $filter
     * @return ContainerInterface
     */
    public function filter($filter, array $params = []): self;
}

the RecursiveIterator extends the Iterator interface which has current, key, next, ... methods

class Item implements ContainerInterface
{
    /**
     * @var ContainerInterface
     */
    private $container;

    /**
     * @return Item
     */
    public function current()
    {
        return $this->container->current();
    }
}

results in an

ERROR: UndefinedInterfaceMethod - Item.php - Method ContainerInterface::current does not exist
return $this->container->current();

bug

Most helpful comment

Thanks all! That was a bad bug, I'm sorry.

All 6 comments

I'm not sure what the bug is here?

ContainerInterface extends \RecursiveIterator which extends the \Iterator interface
ContainerInterface contains therefore the methods from Iterator interface for example current()

But plsam give an error that ContainerInterface::current is not defined!

The code you've given doesn't run: https://3v4l.org/1booS

@weirdan thx for the example!

Thanks all! That was a bad bug, I'm sorry.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LeSuisse picture LeSuisse  路  3Comments

Pierstoval picture Pierstoval  路  3Comments

muglug picture muglug  路  3Comments

staabm picture staabm  路  3Comments

greg0ire picture greg0ire  路  3Comments