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.1 compatibility: fix deprecation notice [2] #1985

Merged
merged 1 commit into from
Apr 9, 2021

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Apr 7, 2021

PHP 8.1 deprecates passing null to PHP native functions where the parameter(s) is not explicitly nullable.

While in PHP 8.1 this is only a deprecation, it should, of course, still be fixed.

This commit contains a fix for the second of the two issues in WordPressCS found related to this so far (based on the unit tests).

Passing null to trim() is now deprecated, so more defensive coding or explicit type casting is needed.
This comes into play for the I18nSniff::process_token() and the PrefixAllGlobalsSniff::process_token() methods where the Helper::getConfigData() method can return either string or null.

Ref: https://phpcsutils.com/phpdoc/classes/PHPCSUtils-BackCompat-Helper.html#method_getConfigData

PHP 8.1 deprecates passing `null` to PHP native functions where the parameter(s) is not explicitly nullable.

While in PHP 8.1 this is only a deprecation, it should, of course, still be fixed.

This commit contains a fix for the second of the two issues in WordPressCS found related to this so far (based on the unit tests).

Passing `null` to `trim()` is now deprecated, so more defensive coding or explicit type casting is needed.
This comes into play for the `I18nSniff::process_token()` and the `PrefixAllGlobalsSniff::process_token()` methods where the `Helper::getConfigData()` method can return either string or `null`.

Ref: https://phpcsutils.com/phpdoc/classes/PHPCSUtils-BackCompat-Helper.html#method_getConfigData
@jrfnl jrfnl force-pushed the php-8.1/fix-incompatibility-trim-2 branch from b7102dd to e9c4858 Compare April 7, 2021 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants