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

Let commands write errors to STDERR if available (fix issue 2270) #2317

Open
wants to merge 8 commits into
base: 0.x
Choose a base branch
from

Conversation

InvisibleSmiley
Copy link

@InvisibleSmiley InvisibleSmiley commented Oct 16, 2024

Fixes #2270.

In the end I chose to copy/adapt OutputStyle::getErrorOutput as a new protected method on the abstract command rather than using SymfonyStyle because:

  1. creating SymfonyStyle requires both $input and $output, but some existing methods only receive $output
  2. SymfonyStyle behaves differently than the plain OutputStyle, which might introduce new issues

I also fixed the exit code for the case where no aliases exist, applying the rule "error output -> exit code 1".

@InvisibleSmiley InvisibleSmiley changed the title Issue-2270 Fix #2270 Oct 16, 2024
@InvisibleSmiley InvisibleSmiley changed the title Fix #2270 Let commands write errors to STDERR if available (fix issue 2270) Oct 16, 2024
@@ -204,7 +204,7 @@ public function connect(): void
*/
public static function getSuffix(array $options): string
{
if ($options['name'] === self::MEMORY) {
if (($options['name'] ?? '') === self::MEMORY) {
Copy link
Author

Choose a reason for hiding this comment

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

This produced a notice when running tests (with error_reporting = E_ALL in php.ini)

@@ -4,6 +4,12 @@

<rule ref="CakePHP"/>

<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
Copy link
Author

Choose a reason for hiding this comment

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

The tests do not contain all necessary imports (uses) right now because without this PHPCS will complain.
I added the missing imports to MigrateTest and will leave the rest for someone else to clean up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(At least) Non-interactive commands should write errors to STDERR
3 participants