0

My source code generates the following error with PHP_CodeSniffer. "Doc comment for var &$myVar does not match actual variable name $myVar at position 2"

PEAR.Commenting.FunctionComment.ParamNameNoMatch

The code:

/**
* Function comment
*
* @param object $newVar some comment
* @param array &$myVar some comment
*
* @return null
*/
private function _myFunction($newVar, &$myVar) {
    // my code here...
}

What could be the reason?

San
  • 666
  • 7
  • 27
  • Please follow the link for the fix: https://github.com/squizlabs/PHP_CodeSniffer/issues/478 – San Feb 09 '15 at 07:07

1 Answers1

0

PHPDoc does not support ampersands and PHP Codesniffer is strictly implementing PHPDoc.
I would prefer it to be considered a PHPDoc bug that needs addressed rather than a having Codesniffer conform. How else do you document that a variable is passed by reference?!

https://github.com/squizlabs/PHP_CodeSniffer/issues/248

Brad Kent
  • 4,982
  • 3
  • 22
  • 26