Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Ti3Et0s opened this issue Oct 25, 2024 · 1 comment
Closed

Comments

@Ti3Et0s
Copy link

Ti3Et0s commented Oct 25, 2024

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:

  • /WordPress/Sniffs/WP/I18nSniff.php on line 194
  • /WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php on line 280

Environment

  • PHP Version: 8.3.11
  • WPCS Version: 2.3.0
  • Project: Working with _s (Underscores) WordPress starter theme

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
Copy link
Member

jrfnl commented Oct 25, 2024

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

@jrfnl jrfnl closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants