Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use namespace in @param

Is it good practice to include namespaces for classes in @param annotations? I know that phpdoc does not support namespaces, but how will other tools like phpdox or Doxygen act?

Which way is better / more common?

namespace foo\someNamespace;
use foo\someOtherNamespace\MyOtherClass;

--- with namespace ---

/**
 * @param \foo\someOtherNamespace\MyOtherClass $otherClass
 */
class myClass(MyOtherClass $otherClass)
{
    // do something
}

--- without namespace ---

/**
 * @param MyOtherClass $otherClass
 */
class myClass(MyOtherClass $otherClass)
{
    // do something
}
like image 247
Sebastian Heuer Avatar asked Dec 09 '11 16:12

Sebastian Heuer


1 Answers

The namespace is a part of the complete name of the class. So if you wouldn't add the namespace to the classname in @param you would give a wrong type.

Personally I think namespaces will become very soon the main criteria for the organization of classes in PHP. So the documentation tools will all have to use them.

like image 176
Marko Avatar answered Oct 17 '22 19:10

Marko