Skip to content

Route ConsoleChannel errors to stderr through an OutputStyle - #27

Merged
imanimanyara merged 1 commit into
mainfrom
fix/console-channel-unwraps-output-style
Oct 13, 2026
Merged

imanimanyara merged 1 commit into
mainfrom
fix/console-channel-unwraps-output-style

Conversation

@imanimanyara

Copy link
Copy Markdown
Member

Summary

When ConsoleChannel::send() gets an error-level message, it routes it to stderr only if $output instanceof ConsoleOutputInterface. A command's $this->output is an OutputStyle. Illuminate\Console\Command::run() wraps the terminal output in one, and an OutputStyle is not a ConsoleOutputInterface, so injecting a command's output sent error lines to stdout. Nothing in the package passes an OutputStyle today, so the defect is latent. It is the same defect laranail/console fixed in #77 and in laranail/console#82.

  • The channel now unwraps the style before the check. The unwrap is a local copy of laranail/console's ErrorOutput::unwrap(), with a docblock that points at it. This module deliberately carries no laranail/* dependency.
  • require now names illuminate/console, for OutputStyle. laravel/framework already replaces it, so nothing new is installed. DeclaredRequirementsTest fails without this line; I checked that locally.
  • CHANGELOG [Unreleased]: a Fixed entry.

Tests

tests/Unit/ConsoleChannelStreamTest.php uses a split stdout/stderr ConsoleOutputInterface stand-in:

  • an error sent through an OutputStyle reaches stderr;
  • an info line sent through an OutputStyle stays on stdout;
  • an error sent through a bare console output reaches stderr, as before.

Fail-first: on the old code the OutputStyle error case fails (stdout was not empty) and the other two pass.

Local: pest 81 passed, phpstan clean, rector clean, phpcs 0 errors. Pint is clean against package-tools' pint.json; the local pint.json is byte-identical to it.

A command's output is an OutputStyle, which is not a
ConsoleOutputInterface, so error-level lines handed a command's output
went to stdout. Unwrap the style first, a local copy of laranail/console's
ErrorOutput::unwrap() since this module has no laranail dependency, and
declare illuminate/console for OutputStyle.
Copilot AI balanced review requested due to automatic review settings October 13, 2026 13:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@imanimanyara
imanimanyara merged commit 2feef76 into main Oct 13, 2026
11 checks passed
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.

2 participants