Skip to content

Quiet formatter output when it isn't going to a terminal #1544

Description

extension format prints each underlying tool's raw output, including things that only make sense on a live terminal. Every run shows PHP-CS-Fixer's version banner, runtime line, config path, core count and a "ask for help" URL, plus an animated progress bar (0/2 … 2/2). This shows up even when the output is redirected to a file or piped into something else, where there's nothing to animate. Logs and CI output fill up with progress-bar frames and banner text. A run that changes nothing still prints around 15 lines.

Suggested improvement

When the output isn't going to a terminal, drop the progress bar and the tool banners and keep just the result lines (which files changed). The banners could stay available under --verbose for debugging. A clean run should be nearly silent.

Example — a no-op run that changed nothing:

Resources/app/administration/src/main.js 21ms (unchanged)
Resources/config/services.yaml 10ms (unchanged)
No PHP version requirement found in composer.json...
If you need help while solving warnings, ask at https://github.com/PHP-CS-Fixer/...
PHP CS Fixer 3.95.20 Adalbertus by Fabien Potencier...
PHP runtime: 8.5.10
Loaded config default from ".../php-cs-fixer.dist.php".
Running analysis on 9 cores with 10 files per process.
 0/2 [░░░░░░░░░░░░░]   0%
 1/2 [▓▓▓▓▓▓░░░░░░░]  50%
 2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

Fixed 0 of 2 files in 0.058 seconds

Related to #1528, but scoped to the mechanical part that can be done without the broader output-normalization design.

Activity

  1. changed the title [-]`extension validate` reports 0 problems when all findings are suppressed, with no indication of suppression[/-] [+]Quieten formatter output when it isn't going to a terminal[/+] on Sep 11, 2026
  2. changed the title [-]Quieten formatter output when it isn't going to a terminal[/-] [+]Quiet formatter output when it isn't going to a terminal[/+] on Sep 11, 2026
  3. tturkowski commented on Sep 16, 2026

    @tturkowski
    Contributor

    Soner (@shyim) Do you think it's a good candidate for Pascal's first issue?

  4. shyim commented on Sep 16, 2026

    @shyim
    Member

    not really like an easy easy ticket tbh fiddly, but fine

  5. lasomethingsomething commented on Sep 18, 2026

    @lasomethingsomething
    ContributorAuthor

    Tomasz Turkowski (@tturkowski) to do some digging for Pascal to take over

  6. MalteJanz commented on Oct 5, 2026

    @MalteJanz
    Contributor

    Just a thought: instead of stripping things out when "the output isn't going to a terminal", it might be a better idea to already think ahead and properly parse each formatters output into a struct we own in the shopware-cli, similar to what the extension / project validate command does.

    Then we can also "own" the terminal and other output formats and change them how we would like.

  7. lasomethingsomething commented on Oct 5, 2026

    @lasomethingsomething
    ContributorAuthor

    Malte Janz (@MalteJanz) Sure, makes sense

  8. shyim commented on Oct 6, 2026

    @shyim
    Member

    I had trouble and not all tools supported that, thats why I gave up captureing their content...

  9. lasomethingsomething commented on Oct 6, 2026

    @lasomethingsomething
    ContributorAuthor

    PHP tools often don't provide the parsing. Could check the tools that don't have it, consider making an upstream PR. If it's just one tool, why not?

    At least worth the effort of looking into it and writing it down.

  10. pascal-zarrad commented on Oct 7, 2026

    @pascal-zarrad

    I verified each formatter tool’s output options and behavior so we can decide how we want to handle them.

    Generally, silencing can be achieved by simply not routing the commands’ stderr to os.Stderr.
    Parsing the output to generate results is a bit more complex, as described below.

    PHP-CS-Fixer

    • Result: stdout
    • Diagnostics: stderr
    • Output options
      • --show-progress: none hides progress completely. dots outputs progress similar to PHPUnit instead of showing a progress bar, which is also a useful option.
      • --format: Multiple formats are available. For our use case, json fits best.
      • --verbose: Shows the applied fixers.
      • --diff: Includes a diff in the output, which can help us pinpoint the actual location of the issue.
      • Use exit codes to determine whether an error occurred.

    Suggestion

    Use JSON as the output format and set progress to either dots or none. Run with --verbose so we can show which rules were violated.

    We must consider exit codes when handling errors. Errors are not included in the structured output and are written to stderr.

    If we want richer support, such as annotations in PRs, we may want to parse --diff. However, we still won’t be able to identify the exact rule violation for each line. Therefore, I think adding a single annotation to the first line of each affected file, prompting the user to run PHP-CS-Fixer without --dry-run, would be a good solution.

    JSON Schema: PHP-CS-Fixer JSON Schema

    Prettier

    • Result: stdout
    • Diagnostics: stderr
    • Output options
      • --list-different: Outputs a list of files that need formatting to stdout, one file per line.
      • Use exit codes to determine whether an error occurred.

    Suggestion

    Unfortunately, Prettier does not seem to provide more detailed output than the list of affected files. The only way to generate a more detailed report would be to inspect the diff from an actual run with --write, which we should avoid during a dry run.

    There are other possible workarounds, such as using stdin, but they would result in poor performance and more complex parsing.

    We must consider exit codes when handling errors. Errors are written to stderr.

    I'd handle this like PHP-CS-Fixer, but without any details on the rule violations.

  11. lasomethingsomething commented on Oct 8, 2026

    @lasomethingsomething
    ContributorAuthor

    Pascal Zarrad (@pascal-zarrad) A quick thanks for the nicely detailed comment above :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Fields

No fields configured for Improvement.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions