Is there a PHPDoc standard to describe function attributes passed by reference?

Viewed 308

I have a function which uses an attribute passed as reference:

public function doSomething(&$argumentPassedByReference)
{
    // ...
}

I maintain the PHPDoc of my project, so I described my function like this:

/**
 * Do something very useful with the thing passed in parameters
 *
 * @param Type $argumentPassedByReference Thing that will be edited
 */
public function doSomething(&$argumentPassedByReference)

But I'm not really satisfied because it doesn't show that $argumentPassedByReference is passed by reference. Is there a standard in PHPDoc to describe this?

2 Answers

Add the ampersand as in the function definition:

 /**
 * Do something very useful with the thing passed in parameters
 *
 * @param Type &$argumentPassedByReference Thing that will be edited
 */

Psalm has @param-out for marking the output type - not quite the same thing but might be useful.

Related