Bug Report
Describe the current, buggy behavior
PHP Notices and warnings are sent to both stderr and stdout, so they cannot be redirected or discarded when needed in scripts
$ wp config get table_prefix
PHP Notice: Foo. in phar:///usr/local/bin/wp/vendor/wp-cli/config-command/src/Config_Command.php(444) : eval()'d code on line 75
Notice: Foo. in phar:///usr/local/bin/wp/vendor/wp-cli/config-command/src/Config_Command.php(444) : eval()'d code on line 75
PHP Warning: Bar. in phar:///usr/local/bin/wp/vendor/wp-cli/config-command/src/Config_Command.php(444) : eval()'d code on line 76
Warning: Bar. in phar:///usr/local/bin/wp/vendor/wp-cli/config-command/src/Config_Command.php(444) : eval()'d code on line 76
wp_
Describe how other contributors can replicate this bug
I have a script to showcase/reproduce issues captured in this gist, which makes use of wp config to avoid requiring a database, but the behavior can be reproduced with most other commands like wp site list as well.
Describe what you expect as the correct outcome
Errors/Warnings/Notices are only sent to stderr so that they can be captured, redirected, or discarded with shell redirections. Errors printing to stdout means capturing the output of a command is hard where you may not control all the code (i.e. running plugins with deprecated php syntax in PHP 8.2) and/or do not want to re-configure WP_DEBUG and its related constants.
Let us know what environment you are running this on
OS: Darwin 21.6.0 Darwin Kernel Version 21.6.0: Sun Nov 6 23:31:13 PST 2022; root:xnu-8020.240.14~1/RELEASE_ARM64_T6000 arm64
Shell: /bin/zsh
PHP binary: /opt/homebrew/Cellar/php/8.2.3/bin/php
PHP version: 8.2.3
php.ini used: /opt/homebrew/etc/php/8.2/php.ini
MySQL binary: /opt/homebrew/bin/mysql
MySQL version: mysql Ver 15.1 Distrib 10.11.2-MariaDB, for osx10.17 (arm64) using EditLine wrapper
SQL modes: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
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/philtyler/pantheon/projects/wpcli-repro
WP-CLI packages dir:
WP-CLI cache dir: /Users/philtyler/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.8.1