Search code examples
phpnaming-conventionscommentsnamingcomment-conventions

What is the preferred way of notating methods in comments?


Sometimes one has to refer to another method when commenting. Here some example in PHP:

class A
{
    /**
     * @see B::bar
     */
    public function foo()
    {
        B::bar();
    }
}

class B
{
    public static function bar()
    {
        // ...
    }
}

So what if there would be a non-static method bar in class B? What is the best way to name other methods in comments?

Edit

The PHP manual seems to use mysqli->affected_rows as well as PDO::beginTransaction. But what it does not is including the parentheses after the method's name. What is pro and con here? I mean it is quite obvious that a method is followed by parentheses, so why no leave 'em out?

Thx in advance!


Solution

  • You could use the -> operator to reference an instance/object method rather than a class method. PHP.net does that in their manual as well (see MySQLi class for example).