WordPress / WordPress-Coding-Standards

PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions
MIT License
2.55k stars 483 forks source link

PHP 8.3 Deprecation Notice: trim(): Passing null to parameter #1 ($string) #2502

Closed Ti3Et0s closed 2 hours ago

Ti3Et0s commented 2 hours ago

Description

When using WPCS with PHP 8.3, the I18n and PrefixAllGlobals sniffs are causing deprecation notices due to trim() being called with null values.

Error Message

trim(): Passing null to parameter #1 ($string) of type string is deprecated

The error occurs in:

Environment

Impact

This affects all PHP files being checked by these sniffs, making it difficult to use WPCS with PHP 8.3. The error prevents proper code analysis as the checking is aborted when the deprecation notice is encountered.

Temporary Workaround

Currently using a local PHPCS configuration that excludes these sniffs to allow development to continue, but this means losing important WordPress-specific checks.

Suggested Solution

Update the relevant sniffs to ensure trim() is only called on string values, possibly by adding type checking before the trim() calls.

jrfnl commented 2 hours ago

Closing as invalid. This was fixed years ago and included in the WPCS 3.0.0 release.