Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Documenting default values for optional parameters in PHP with phpDocumentor

With phpDocumentor, how do you document an optional parameter that has a default value like this:

public function myMethod ($param = 1234)
{
    // ...
}

How do I write the @param tag in the docblock to get the default value documented?

like image 770
Desmond Hume Avatar asked Oct 24 '25 08:10

Desmond Hume


1 Answers

The documentation is here

If you are not indicating in the actual code that the parameter is optional (via "$paramname = 'a default value'"), then you should mention in the parameter's description that the parameter is optional.

So for the source code in your question, you don't need to do anything. But if you don't include a default value for an optional parameter, you should include a note in the description detailing the default value.

like image 152
Thomas Coulter-Brophy Avatar answered Oct 27 '25 00:10

Thomas Coulter-Brophy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!