How to note that argument is optional in PHPDoc?

I have this constructor that takes an optional argument. The main problem is usability. A developer using my infrastructure will immediately catch a headache because he does not know if he can give an argument, which argument or not at all. Conclusion: it just sucks. But PHPDoc might help a little if someone has a reasonable IDE like Netbeans;)

So:

class ChildClass extends ParentClass {
    public function __construct() {
    $tplFile = func_get_arg(0);
    if (!isset($tpl)) {
        $tpl = 'index';
    }
    parent::__construct($tpl);
    }
}

How can I use PHPDoc here to indicate that the optional argument [$ tpl] can be provided?

+5
source share
2 answers

Declare a parameter and give it a preset:

public function __construct($my_argument = 0) 

IDE (phpEd, phpDoc) . phpDoc :

show ([$my_argument])
+6

.

-1

All Articles