0

PHPCS is complaining about php doc for implementations of interfaces that already have the php doc provided in the interface.

My question is, how do I cleanly get PHPCS to ignore interface method implementations, similar to java's @Override?

Below is an example of how I do it in java and what I have in php. My goal is to be able to ignore it for methods from interfaces that already have php doc. If the method is not a implementation, then it should still be required to have a php doc provided.

How it Works in Java

In java, I can have an interface like so:

public interface Sandbox {
    /**
     * Description of some method.
     */
    void someMethod();
}

And a class that implements it as so:

public class SandboxImpl implements Sandbox {
    @Override
    public void someMethod() {
        // This is the concrete implementaiton.
    }
}

With the above, java picks up the java doc without any issues and the @Override helps get past any check style checks.

What I have in PHP

In php, I have an interface like:

interface Sandbox
{
    /**
     * Some php doc.
     *
     * @return mixed
     */
    public function someMethod();
}

With a class that implements it like:

class SandboxImpl implements Sandbox
{
    public function someMethod()
    {
        // TODO: Implement someMethod() method.
    }
}
James Oravec
  • 19,579
  • 27
  • 94
  • 160
  • 1
    Did you already try with inheritDoc tag? – Aleksander Wons Jan 06 '16 at 12:44
  • @awons, I'll test it out. If it works, I'll have you write it as an answer and I'll accept it – James Oravec Jan 06 '16 at 16:03
  • @awons, that annotation didn't work at least for what my team has setup. It specifically looks for the @param and @return. The guys where I work say they got the check style standards from the symphony2 standards. I think I'm going to have to get a little more familiar with how the `php doc` and `PHPCS` stuff work together and see if there is a way to get it to work properly, either with that annotation or other means. I'll have to come back to this when I have time. – James Oravec Jan 06 '16 at 19:37

0 Answers0