Description
- Platform:
MacOS
- Installed Via:
Homebrew
- PHP Version:
8.1
- Terminus Version:
3.5.2
Command Executed
terminus org:site:list -n <ORG_ID> --format=tsv --field=Name
Expected behavior
The command should list the sites within the specified organization without triggering any PHP deprecation warnings.
Actual behavior
The command executed triggers a PHP deprecation warning related to the str_replace()
function in the TsvFormatter.php
file. The warning message is as follows:
PHP Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in phar:///usr/local/Cellar/terminus/3.5.2/bin/terminus/vendor/consolidation/output-formatters/src/Formatters/TsvFormatter.php on line 36
This deprecation warning occurs when the str_replace()
function is called with a null
value, which is deprecated in PHP 8.1.
I've tried switching to different formats like json
and csv
, but the issue persists when using the tsv
format. It would be helpful if the TsvFormatter
checked for null
values before calling str_replace()
to avoid this warning.
Suggestion for Patch
A potential patch for the TsvFormatter.php
file would involve adding a check to ensure that the str_replace()
function is not passed a null
value. For example:
if (!is_null($subject)) {
$result = str_replace($search, $replace, $subject);
} else {
$result = $subject; // or provide a default value if appropriate
}
This change would prevent the deprecation warning by ensuring that str_replace()
only operates on valid strings.
Please let me know if there's any additional information I can provide or if there's a workaround to suppress these warnings.