Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

phpdoc

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?

like image 675
LucileDT Avatar asked Sep 17 '25 14:09

LucileDT


1 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
 */
like image 128
Dostrelith Avatar answered Sep 19 '25 06:09

Dostrelith