Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEAR and Squiz FunctionComment sniffs throw errors for some invalid @param line formats #1091

Closed
andykais opened this issue Jul 27, 2016 · 2 comments

Comments

@andykais
Copy link

andykais commented Jul 27, 2016

php ~/Build/php-codesniffer-2.6.1/phpcs.phar --extensions=php,php3,php4,php5,phtml,inc,lib,module,info --report=xml --standard=PSR2,Generic,Zend,Squiz,PSR1,MySource,PEAR --report-file=phpcs.xml drupal-8.1.x
PHP Notice:  Undefined offset: 1 in phar:///home/andrew/Build/codedx/dev/lift-project/bundle/target/scala-2.11/classes/bundled-tools/php-codesniffer-2.6.1/phpcs.phar/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php on line 261
PHP Notice:  Undefined offset: 1 in phar:///home/andrew/Build/codedx/dev/lift-project/bundle/target/scala-2.11/classes/bundled-tools/php-codesniffer-2.6.1/phpcs.phar/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php on line 262
PHP Notice:  Undefined offset: 1 in phar:///home/andrew/Build/codedx/dev/lift-project/bundle/target/scala-2.11/classes/bundled-tools/php-codesniffer-2.6.1/phpcs.phar/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php on line 261
PHP Notice:  Undefined offset: 1 in phar:///home/andrew/Build/codedx/dev/lift-project/bundle/target/scala-2.11/classes/bundled-tools/php-codesniffer-2.6.1/phpcs.phar/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php on line 262
PHP Notice:  Undefined offset: 1 in phar:///home/andrew/Build/codedx/dev/lift-project/bundle/target/scala-2.11/classes/bundled-tools/php-codesniffer-2.6.1/phpcs.phar/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php on line 230
PHP Notice:  Undefined offset: 1 in phar:///home/andrew/Build/codedx/dev/lift-project/bundle/target/scala-2.11/classes/bundled-tools/php-codesniffer-2.6.1/phpcs.phar/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php on line 231
PHP Notice:  Undefined offset: 1 in phar:///home/andrew/Build/codedx/dev/lift-project/bundle/target/scala-2.11/classes/bundled-tools/php-codesniffer-2.6.1/phpcs.phar/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php on line 261
PHP Notice:  Undefined offset: 1 in phar:///home/andrew/Build/codedx/dev/lift-project/bundle/target/scala-2.11/classes/bundled-tools/php-codesniffer-2.6.1/phpcs.phar/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php on line 262
PHP Notice:  Undefined offset: 1 in phar:///home/andrew/Build/codedx/dev/lift-project/bundle/target/scala-2.11/classes/bundled-tools/php-codesniffer-2.6.1/phpcs.phar/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php on line 261
PHP Notice:  Undefined offset: 1 in phar:///home/andrew/Build/codedx/dev/lift-project/bundle/target/scala-2.11/classes/bundled-tools/php-codesniffer-2.6.1/phpcs.phar/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php on line 262
PHP Notice:  Undefined offset: 1 in phar:///home/andrew/Build/codedx/dev/lift-project/bundle/target/scala-2.11/classes/bundled-tools/php-codesniffer-2.6.1/phpcs.phar/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php on line 230
PHP Notice:  Undefined offset: 1 in phar:///home/andrew/Build/codedx/dev/lift-project/bundle/target/scala-2.11/classes/bundled-tools/php-codesniffer-2.6.1/phpcs.phar/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php on line 231

seems to be coming from a preg_match that doesnt check if it yields nothing

preg_match('/([^$&.]+)(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/', $tokens[($tag + 2)]['content'], $matches);

$typeLen   = strlen($matches[1]);
$type      = trim($matches[1]);
@gsherwood
Copy link
Member

Tracked down to this function comment style:

/**
 * Function comment.
 *
 * @param $bar
 *   Comment here.
 * @param ...
 *   Additional arguments here.
 *
 * @return
 *   Return value
 *
 */
function foo($bar) {
}

@gsherwood gsherwood changed the title undefined offset error in codesniffer standard PEAR and Squiz FunctionComment sniffs throw errors for some invalid @param line formats Jul 27, 2016
gsherwood added a commit that referenced this issue Jul 27, 2016
@gsherwood
Copy link
Member

The problem is caused by the use of ... instead of ...$paramName. I didn't bother adding any specific error messages for this format. I'm sure Drupal doesn't use thee sniffs and so wouldn't care.

Thanks for reporting the bug.

gsherwood added a commit that referenced this issue Jul 28, 2016
photodude added a commit to photodude/coding-standards that referenced this issue Feb 19, 2017
photodude added a commit to photodude/coding-standards that referenced this issue Mar 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants