How to set up phpcs with WordPress coding standard with PHP8?
Trying to set up PHP_CodeSniffer
with the WordPress Codings Standards. I'm running PHP v8.0.3
and phpcs v3.5.8.
(in March 2021).
WPCS is installed via
git clone -b master https://github.com/WordPress/WordPress-Coding-Standards.git wpcs
The installation worked, but running phpcs leads to this error:
phpcs: Uncaught TypeError: vsprintf(): Argument #2 ($values) must be of type array,
string given in file.php
This is apparently an issue with WPCS and fixed in this commit. The commit seems to be not merged into master yet, so I checked out the develop branch. This appears to fix the above-mentioned issue but causes another error:
phpcs: Referenced sniff PHPCSUtils does not exist
The proposed solution for fixing this issue is switching to the master branch, which brings me back to square one.
So both master
and develop
don't work for different reasons. I guess could change the source code in the master branch manually, but that doesn't seem to be a sustainable fix.
Is there a better way to make phpcs work with the current versions of PHP and WPCS?
Topic coding-standards php Wordpress
Category Web