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

Avoid deprecation warnings in newer PHP #185

Merged
merged 1 commit into from
Mar 26, 2025
Merged

Conversation

mrsdizzie
Copy link
Member

To avoid deprecation warnings in PHP 8.1+:

PHP Deprecated:  str_replace(): Passing null to parameter #3 ($subject)
of type array|string is deprecated in
/Users/isla/source/wp-cli-dev/php-cli-tools/lib/cli/table/Tabular.php on
line 30

I saw this while running tests for wp-cli/package-command#197 where some rows of wp package browse look like:

        array(4) {
          [0]=>
          string(22) "redkiwi-nl/localconfig"
          [1]=>
          NULL
          [2]=>
          string(0) ""
          [3]=>
          string(54) "0.1, 0.2.1, 0.2.2, 0.3, 0.3.1, 9999999-dev, dev-master"
        }
        array(4) {
          [0]=>
          string(18) "vccw/scaffold-vccw"
          [1]=>
          NULL
          [2]=>
          string(0) ""
          [3]=>
          string(84) "1.0.0, 1.0.1, 1.1.0, 1.1.1, 1.2.0, 1.3.0, 1.4.0, 9999999-dev, dev-master, dev-stable"
        }
        array(4) {
          [0]=>
          string(22) "welaika/wp-cli-db2utf8"
          [1]=>
          NULL
          [2]=>
          string(0) ""
          [3]=>
          string(23) "9999999-dev, dev-master"
        }

@mrsdizzie mrsdizzie requested a review from a team as a code owner March 26, 2025 15:37
@mrsdizzie mrsdizzie added the bug label Mar 26, 2025
@mrsdizzie mrsdizzie added this to the 0.12.5 milestone Mar 26, 2025
To avoid deprecation warnings in newer PHP:
```
PHP Deprecated:  str_replace(): Passing null to parameter #3 ($subject)
of type array|string is deprecated in
/Users/isla/source/wp-cli-dev/php-cli-tools/lib/cli/table/Tabular.php on
line 30
```
@mrsdizzie mrsdizzie force-pushed the fix/avoid-null-values branch from 414e72a to 854de46 Compare March 26, 2025 15:39
Copy link

codecov bot commented Mar 26, 2025

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Copy link
Member

@swissspidy swissspidy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find, thanks! Appreciate the added test, as the existing tests didn't cover this.

@swissspidy swissspidy merged commit 34b83b4 into master Mar 26, 2025
18 checks passed
@swissspidy swissspidy deleted the fix/avoid-null-values branch March 26, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants