4

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?

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Also, I realise you probably didn't need this answering 4 months later - I failed to check the date.
The link you shared not valid anymore

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.