Fix: Add Symfony Console 7.4+ addCommand() compatibility #1185
+1,354
−261
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This pull request:
Summary
Proposed Solution:
Added a compatibility wrapper addCommand() in Robo\Application that:
Update all internal calls to use addCommand() instead of add()
This ensures Robo works without deprecation warnings on Symfony 7.4+ and remains compatible with Symfony 6.
Description
When using Robo with Symfony Console 7.4+, a deprecation warning is triggered:
This occurs because Robo and its consumers call add() to register commands, but Symfony 7.4+ expects addCommand() instead. However, Symfony 6 does not have addCommand(), so a compatibility layer is needed.
***Note: We heavily use robo to orchestrate our local development and CI/CD for a single Drupal codebase using a custom upstream in Pantheon for over 200+ sites. We recently updated to Drupal 11.3 and we started getting a number of errors when running the custom robo commands. AI was used in the analysis of this issue and the solution proposed. We have tested against our own codebase and validated the errors no longer appear for us. I'll watch this to see if there are any test failures and will try to gracefully address, if possible and as time permits.