wearerequired / coding-standards

💻 required coding standards for PHP, JavaScript and CSS.
https://handbook.required.com/development/coding-standards/
GNU General Public License v2.0
11 stars 2 forks source link

PHP 8.2 #241

Closed krokodok closed 5 months ago

krokodok commented 6 months ago

To make the package PHPCompatibility/PHPCompatibility, which is a dependency of PHPCompatibility/PHPCompatibilityWP, work with PHP 8.2, the developers suggest using the develop-Branch as version 9.9.99 until there is a new release:

ocean90 commented 5 months ago

Do you have an example code snippet/project where this was an issue?

krokodok commented 5 months ago

I encountered these problems at https://github.com/wearerequired/autofit-garages/, but I don't remember exactly how to reproduce it. Maybe this can somehow work otherwise. I did in fact not encounter the same problem at other PHP 8.2 websites, but maybe the project setups are too different.

ocean90 commented 5 months ago

I was able to revert the related commit and PHPCS is still running.

Keeping this open for further reference.

krokodok commented 5 months ago

I just encountered the problem in https://github.com/wearerequired/trailworks-theme as well. The problem occurs only in VS Code and that was the reason for my update.

Recreate

grafik

An error occurred during processing; checking has been aborted. The error message was: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /Users/jeffchi/Projects/trailworks/wordpress/content/themes/trailworks-theme/vendor/phpcompatibility/php-compatibility/PHPCompatibility/Sniff.php on line 131\nThe error originated in the .PHPCompatibility. sniff on line 131.

If this is just an individual error for my IDE setup, that is okay. It still works from CLI.

ocean90 commented 5 months ago

Interesting! I'll give the extension a try. I'm using shevaua.phpcs and persoderlind.vscode-phpcbf.

ocean90 commented 5 months ago

@krokodok I was able to reproduce this (also with my extensions) and it's actually a PHPCS config error. The upgrade guide for 5.0.0 includes the note that you have to set minimum_supported_wp_version and testVersion in phpcs.xml.dist. Once you add the necessary config the error is gone and you get the sniff to use the correct version for any compatibility checks.

Line 131 of Sniff.php is about the testVersion. In the develop branch a string cast operator is used.

krokodok commented 5 months ago

@ocean90 Super, thanks for taking the time to check!