phpcs Fatal Error with wp-coding-standards/wpcs

The phpcs autoformat-er failed to perform on save in VS Code. "A Fatal Error" pops up. It is caused by the sniffs applied, wpcs, which is not yet compatible with PHP8. But it can be resolved with a line of PHP configuration.

phpcs Fatal Error with wp-coding-standards/wpcs
Photo by Ridham Nagralawala / Unsplash

PHP: v8.2.5
phpcs: v3.7.2
wp-coding-standards/wpcs: v2.3

Solution

modify the PHP configuration to stop emitting the warning
php.ini

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

Cause

wpcs don't support php8 yet. When a deprecation error is triggered, but not the expected return, the Fatal Error occurs.