7
在@param註釋中包含類的命名空間是否是一種好的做法?我知道phpdoc不支持命名空間,但其他工具如phpdox或Doxygen會如何操作?在@param中使用命名空間
哪種方式更好/更常見?
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
}
+1我個人總是使用完整的命名空間\ Root \ MyClass來更容易地進行大量的查找替換操作......但是我通常也避免在命名空間中使用''語句,因爲我認爲它使得它更加容易很難理解我的代碼中發生了什麼。 – rdlowrey
我的約定是**總是**在Docbocks中使用FQN。沒有主要的反斜槓: _foo \ someOtherNamespace \ MyOtherClass $ otherClass_ – mosch