For reasons of ease of maintenance AND IDE class auto-completion and member hinting, I've used PHPDoc in my project. Given this example class:
class my_class {
public $id;
public $name;
public $number;
public function __construct() {
//Do something
}
public function Rename($name) {
$this->name = $name;
}
}
I would prefer to document all properties ($id
, $name
and $number
) with the class documentation itself, which is above the class declaration, and then place documentation for methods (if necessary) above each method. Here is what I ultimately want my class to look like:
/**
* Represents an example class for Stackoverflow
*
* @property int $id The id of the object
* @property string $name The name of the object
* @property int $number The number of the object
*/
class my_class {
public $id;
public $name;
public $number;
public function __construct() {
//Do something
}
/**
* Renames the object
* @param string $name Name to rename object
*/
public function Rename($name) {
$this->name = $name;
}
}
This is precisely what I prefer to have as documentation, however Netbeans' autocomplete fails to operate correctly, as it lists each property twice. For example, if I start typing $my_class_object->i
the auto-complete will list two $id properties: one as described in my PHPDoc, and another is described as an unknown variable with "PHPDoc Not Found".
There is a solution that works to solve the Netbeans issue - add a @var
PHPDoc block above each property, however I think it unnecessarily clutters up my class, especially some of my classes that have 10+ properties.
Is there a [good] solution to both of my issues (clean doc, proper Netbeans hinting), or am I going about this incorrectly?