-
-
Notifications
You must be signed in to change notification settings - Fork 494
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PHP 8 | ControlStructureSpacing: bug fix - $data should be an array
The `$data` parameter of the `$phpcsFile->add[Fixable]Error|Warning()` methods is expected to be an array, not a string. Without this fix, PHP 8 will throw and (uncaught) `TypeError: vsprintf(): Argument #2 ($args) must be of type array, string given`.
- Loading branch information
Showing
1 changed file
with
5 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7cd46be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When will this be released? Right now, it's not possible to run
wpcs
with PHP 8.See also squizlabs/PHP_CodeSniffer#3196 (comment)
7cd46be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jrfnl
PHP 8 Support would be great. Hope to see something to getting wpcs work with PHP 8.
7cd46be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting as the latest release does not include this fix: https://github.com/WordPress/WordPress-Coding-Standards/releases/tag/2.3.0
I was looking into why
php-fpm
was taking enormous amounts of CPU usage. A side effect was that my WP install loaded images very slowly (8s for a 400x400 image).Turned out that
Fatal error: Uncaught TypeError: vsprintf(): Argument #2 ($values) must be of type array, string given in /Users/path_to_theme/vendor/squizlabs/php_codesniffer/src/Files/File.php:1050
filled my memory.My advise: use [email protected].
Edit: Issues of slow response and high CPU are still present. Take advice with a bucket of salt.
7cd46be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I manually added these to the specified file and it seems to fix the issue for me:
Windows 11
VSCode
7cd46be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Manually applied patch as above and can confirm fix.
7cd46be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bigupjeff I can also confirm making the changes above fixed issues for me.
To avoid making manual changes in my individual projects, I use composer to download the development repository and build all
vendor
files. This is currently a "quick fix" as I just encountered this issue today. Here is an example.I plan to make a fork from the WordPress-Coding-Standards stable release version and make the changes as a patch. After the fork is made I will update the gist accordingly. Hopefully, I can finish this all over the weekend.
7cd46be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mqschwanda Just had a look at the gist, but I honestly don't understand what you are doing there.
The below should be sufficient. Everything else is unnecessary.
7cd46be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For who is looking for a fix there is a tag that should fix the issue also if there isn't a new official release https://github.com/WordPress/WordPress-Coding-Standards/releases/tag/2.3.0-fix-vsprintf
7cd46be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mte90 Please be aware that the tag you mention is NOT recommended as it already contains breaking changes which will be part of the 3.0.0 release.
7cd46be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know but in the meantime is a solution to avoid crashes on phpcs and let to use WPCS :-)
7cd46be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoiding crashes is simple. Run WPCS on PHP 7.4 until v 3.0 has been released.