Search code examples
phpinterfacephpstormphpdocimplements

How to fix an error about PHPDoc on interface class


I'm working on a PHP library and I have two classes.

First one is like this:

/**
 * @method static A getInstance()
 */
interface A {...}

Second one is like this:

class B implements A {...}

getInstance is not defined in A, except in PHPDoc above class. Now, my IDE (PHPStorm) suggests an error, saying that I should implement getInstance in B.

My questions are:

  1. Why they put this method in PHPDoc even though it's not declared in the interface? I doubt it's a mistake, since they used the same comment in many other classes.

  2. What do you recommend? should I implement in B or should I remove the PHPDoc comment from A?


Solution

  • I think it's the mistake because any of the classes which implement OW_Storage interface don't implement getInstance() method. You can make sure it with help search. It means this function isn't used.

    You can remove the doc block from the interface but right way is to do pull-request in origin repository.