When running Matomo with PHP 7.4 this command runs without an error:
php console --no-ansi -n config:get --section=General --key=force_ssl --format=text
General.force_ssl = 1
echo $?
0
With PHP 8.1 it returns the result, but it also returns errors messages and has a non-zero exit code:
php console --no-ansi -n config:get --section=General --key=force_ssl --format=text
WARNING [2022-05-16 12:37:20] 153951 /var/www/matomo/plugins/CoreAdminHome/Commands/ConfigGet.php(92): Deprecated - trim(): Passing null to parameter <a href='/1'>#1</a> ($string) of type string is deprecated - Matomo 4.10.0 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already)
General.force_ssl = 1
Error: error or warning logs detected, exit 1
echo $?
1
This breaks some Ansible code I have for managing Matomo sites, if the error messages went to standard error and only the result went to standard out that would make it easier to cope with.
Thanks for the bug report. I can reproduce the error with your description.