Closed marekdedic closed 1 year ago
The issue happens when running phpcs with this config:
<?xml version="1.0"?> <ruleset> <file>error.php</file> <config name="installed_paths" value="vendor/wp-coding-standards/wpcs"/> <rule ref="WordPress.WhiteSpace.ControlStructureSpacing" /> </ruleset>
... over a file containing this code:
<?php function fn () {}
Note the space between fn and () - removing it fixes the error.
fn
()
The resulting error:
> vendor/bin/phpcs PHP Fatal error: Uncaught TypeError: vsprintf(): Argument #2 ($values) must be of type array, string given in /home/user/project/vendor/squizlabs/php_codesniffer/src/Files/File.php:1056 Stack trace: #0 /home/user/project/vendor/squizlabs/php_codesniffer/src/Files/File.php(1056): vsprintf() #1 /home/user/project/vendor/squizlabs/php_codesniffer/src/Files/File.php(672): PHP_CodeSniffer\Files\File->addMessage() #2 /home/user/project/vendor/squizlabs/php_codesniffer/src/Files/File.php(780): PHP_CodeSniffer\Files\File->addError() #3 /home/user/project/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php(205): PHP_CodeSniffer\Files\File->addFixableError() #4 /home/user/project/vendor/wp-coding-standards/wpcs/WordPress/Sniff.php(910): WordPressCS\WordPress\Sniffs\WhiteSpace\ControlStructureSpacingSniff->process_token() #5 /home/user/project/vendor/squizlabs/php_codesniffer/src/Files/File.php(498): WordPressCS\WordPress\Sniff->process() #6 /home/user/project/vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php(92): PHP_CodeSniffer\Files\File->process() #7 /home/user/project/vendor/squizlabs/php_codesniffer/src/Runner.php(628): PHP_CodeSniffer\Files\LocalFile->process() #8 /home/user/project/vendor/squizlabs/php_codesniffer/src/Runner.php(500): PHP_CodeSniffer\Runner->processFile() #9 /home/user/project/vendor/squizlabs/php_codesniffer/src/Runner.php(114): PHP_CodeSniffer\Runner->run() #10 /home/user/project/vendor/squizlabs/php_codesniffer/bin/phpcs(18): PHP_CodeSniffer\Runner->runPHPCS() #11 {main} thrown in /home/user/project/vendor/squizlabs/php_codesniffer/src/Files/File.php on line 1056
develop
Closing as duplicate of numerous previous issues. This has been fixed a long time ago in develop and we're working hard on getting WPCS 3.0.0 released.
Bug Description
Minimal Code Snippet
The issue happens when running phpcs with this config:
... over a file containing this code:
Note the space between
fn
and()
- removing it fixes the error.The resulting error:
Environment
Tested Against
develop
branch?develop
branch of WPCS.