Skip to content

fix: replace addCommand() with add() for symfony/console 7.x compatibility#4

Merged
damienlagae merged 2 commits into
mainfrom
fix/addcommand-symfony-console-7
Mar 13, 2026
Merged

fix: replace addCommand() with add() for symfony/console 7.x compatibility#4
damienlagae merged 2 commits into
mainfrom
fix/addcommand-symfony-console-7

Conversation

@damienlagae
Copy link
Copy Markdown
Member

Problem

Symfony\Component\Console\Application::addCommand() does not exist in symfony/console 7.x. The available methods are add() (single command) and addCommands() (array). This causes a fatal error when running vendor/bin/coding-standard init in projects using symfony/console ^7.0.

Fix

Replace addCommand() with add(), which is the correct method name and is compatible with both symfony/console ^7.0 and ^8.0.

Replace add() calls with getDefaultCommands() override, which is the
correct hook point for Application subclasses and avoids PHPStan issues
with inherited method resolution.

Add bootstrapFiles to phpstan.neon to ensure symfony/console types are
loaded when PHPStan runs from the isolated tools/phpstan/ directory.

Add Symfony version matrix (^7.0, ^8.0) to CI test job to verify
compatibility across both supported major versions.
@damienlagae damienlagae merged commit 39816b1 into main Mar 13, 2026
4 checks passed
@damienlagae damienlagae deleted the fix/addcommand-symfony-console-7 branch March 13, 2026 11:37
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.

1 participant