wp-cli / php-cli-tools

A collection of tools to help with PHP command line utilities
MIT License
673 stars 118 forks source link

"PHP Deprecated" notices on PHP 8.2: grapheme_strlen, preg_match_all, strlen, str_pad #162

Closed slaFFik closed 1 year ago

slaFFik commented 1 year ago

Bug Report

Describe the current, buggy behavior

I'm calling this command:

WP_CLI\Utils\format_items( 'table', [ $data ], array_keys( $data ) );

in my custom WP CLI command.

It generates the several deprecations.

I'm on PHP 8.2.

[23-Sep-2023 23:18:01 UTC] PHP Deprecated:  grapheme_strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /Users/slaffik/.wp-cli/packages/local/slaffik/wp-cli-tail/vendor/wp-cli/php-cli-tools/lib/cli/cli.php on line 329
[23-Sep-2023 23:18:01 UTC] PHP Deprecated:  preg_match_all(): Passing null to parameter #2 ($subject) of type string is deprecated in /Users/slaffik/.wp-cli/packages/local/slaffik/wp-cli-tail/vendor/wp-cli/php-cli-tools/lib/cli/cli.php on line 331
[23-Sep-2023 23:18:01 UTC] PHP Deprecated:  strlen(): Passing null to parameter #1 ($string) of type string is deprecated in phar:///opt/homebrew/Cellar/wp-cli/2.8.1/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/Colors.php on line 215
[23-Sep-2023 23:18:01 UTC] PHP Deprecated:  str_pad(): Passing null to parameter #1 ($string) of type string is deprecated in phar:///opt/homebrew/Cellar/wp-cli/2.8.1/bin/wp/vendor/wp-cli/php-cli-tools/lib/cli/Colors.php on line 218

Describe what you would expect as the correct outcome

No "PHP Deprecated" notices.

Let us know what environment you are running this on

OS:     Darwin 22.6.0 Darwin Kernel Version 22.6.0: Fri Sep 15 13:41:28 PDT 2023; root:xnu-8796.141.3.700.8~1/RELEASE_ARM64_T6000 arm64
Shell:  /bin/zsh
PHP binary:     /opt/homebrew/Cellar/php/8.2.10/bin/php
PHP version:    8.2.10
php.ini used:   /opt/homebrew/etc/php/8.2/php.ini
MySQL binary:   
MySQL version:  
SQL modes:      
WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      phar://wp-cli.phar/vendor
WP_CLI phar path:       /Users/slaffik/Projects/[redacted]
WP-CLI packages dir:    /Users/slaffik/.wp-cli/packages/
WP-CLI cache dir:       /Users/slaffik/.wp-cli/cache
WP-CLI global config:   
WP-CLI project config:  
WP-CLI version: 2.8.1