woocommerce / woocommerce-sniffs

Collection of PHP_CodeSniffer sniffs for WooCommerce
https://packagist.org/packages/woocommerce/woocommerce-sniffs
MIT License
48 stars 10 forks source link

Fatal error: Uncaught TypeError: vsprintf() #34

Open helgatheviking opened 1 year ago

helgatheviking commented 1 year ago

Does this need a dependency update? I am seeing the following then trying to run the code checker sniffs:

PHP Fatal error: Uncaught TypeError: vsprintf(): Argument #2 ($values) must be of type array, string given in /home/helga/Sites/sandbox/wp-content/plugins/woocommerce-mix-and-match-products/vendor/squizlabs/php_codesniffer/src/Files/File.php:1056

using PHP 8.1.12 in Ubuntu

andfinally commented 1 year ago

Sounds similar to this old issue in the WP sniffs.

helgatheviking commented 1 year ago

Hmm... yes, it does seem similar, but I am not sure how to patch woocommerce sniffs to get it to work with the dev branch of the WP Code standards.

rrennick commented 1 year ago

I am not sure how to patch woocommerce sniffs to get it to work with the dev branch of the WP Code standards.

If you fork the repo you could create a branch where you change the package version to dev-trunk. Then use your fork & branch (dev-BRANCHNAME) in your plugin composer.json.

rogyw commented 1 year ago

I got this error when using period (.) as the file list to check instead of *.php e.g.

./vendor/bin/phpcs --standard=WordPress-Extra .

PHP Fatal error:  Uncaught TypeError: vsprintf(): Argument #2 ($values) must be of type array, string given in /vendor/squizlabs/php_codesniffer/src/Files/File.php:1056

Tried replacing . with *.php as shown below and the error does not occur:

./vendor/bin/phpcs --standard=WordPress-Extra *.php 
helgatheviking commented 1 year ago

Could we give this some new impetus now that WP Code Standards are updated?