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 [1] #1984

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 one 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 MinimumWPVersionTrait::get_wp_version_from_cli() method where the Helper::getCommandLineData() method can return either string or null.

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

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 one 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 `MinimumWPVersionTrait::get_wp_version_from_cli()` method where the `Helper::getCommandLineData()` method can return either string or `null`.

Ref: https://phpcsutils.com/phpdoc/classes/PHPCSUtils-BackCompat-Helper.html#method_getCommandLineData
@GaryJones GaryJones merged commit a538cdb into develop Apr 9, 2021
@GaryJones GaryJones deleted the php-8.1/fix-incompatibility-trim branch April 9, 2021 02:23
@jrfnl jrfnl mentioned this pull request Jan 18, 2022
websupporter added a commit to mailpoet/mailpoet that referenced this pull request Apr 1, 2022
We introduced the WordPress Coding standards, which are currently not
compatible with PHP 8.1. We need to wait for the next major version
to be able to upgrade to PHP 8.1.

Example: WordPress/WordPress-Coding-Standards#1984
[MAILPOET-4219]
samnajian pushed a commit to mailpoet/mailpoet that referenced this pull request Apr 1, 2022
We introduced the WordPress Coding standards, which are currently not
compatible with PHP 8.1. We need to wait for the next major version
to be able to upgrade to PHP 8.1.

Example: WordPress/WordPress-Coding-Standards#1984
[MAILPOET-4219]
samnajian pushed a commit to mailpoet/mailpoet that referenced this pull request Apr 1, 2022
We introduced the WordPress Coding standards, which are currently not
compatible with PHP 8.1. We need to wait for the next major version
to be able to upgrade to PHP 8.1.

Example: WordPress/WordPress-Coding-Standards#1984
[MAILPOET-4219]
samnajian pushed a commit to mailpoet/mailpoet that referenced this pull request Apr 1, 2022
We introduced the WordPress Coding standards, which are currently not
compatible with PHP 8.1. We need to wait for the next major version
to be able to upgrade to PHP 8.1.

Example: WordPress/WordPress-Coding-Standards#1984
[MAILPOET-4219]
samnajian pushed a commit to mailpoet/mailpoet that referenced this pull request Apr 1, 2022
We introduced the WordPress Coding standards, which are currently not
compatible with PHP 8.1. We need to wait for the next major version
to be able to upgrade to PHP 8.1.

Example: WordPress/WordPress-Coding-Standards#1984
[MAILPOET-4219]
samnajian pushed a commit to mailpoet/mailpoet that referenced this pull request Apr 1, 2022
We introduced the WordPress Coding standards, which are currently not
compatible with PHP 8.1. We need to wait for the next major version
to be able to upgrade to PHP 8.1.

Example: WordPress/WordPress-Coding-Standards#1984
[MAILPOET-4219]
JanJakes pushed a commit to mailpoet/mailpoet that referenced this pull request Apr 4, 2022
We introduced the WordPress Coding standards, which are currently not
compatible with PHP 8.1. We need to wait for the next major version
to be able to upgrade to PHP 8.1.

Example: WordPress/WordPress-Coding-Standards#1984
[MAILPOET-4219]
veljkho pushed a commit to mailpoet/mailpoet that referenced this pull request Apr 4, 2022
We introduced the WordPress Coding standards, which are currently not
compatible with PHP 8.1. We need to wait for the next major version
to be able to upgrade to PHP 8.1.

Example: WordPress/WordPress-Coding-Standards#1984
[MAILPOET-4219]
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