magento2: Updating symfony/console causing setup:di:compile failure
Preconditions (*)
1.2.4.2-p1 2.Centos 8 3.php 7.4
Steps to reproduce (*)
Expected result (*)
- [Screenshots, logs or description]
Actual result (*)
- [Screenshots, logs or description]
2.Incompatible argument type: Required type: int. Actual type: string
The name of the upgrade package is not remembered
The following error occurred during compilation

Workaround
The symfony/console released version 4.4.29 as a hotfix for Magento issue.
For now, you can run composer update symfony/console
Note: the root cause of this issue still not resolved yet
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 12
- Comments: 25 (16 by maintainers)
The changes will be reverted in symfony/console:4.4.29
The issue exists within Magento. The change made in
symfony/consoleis a temporary work-around and not a fix.It’s not a symfony issue, it’s Magento not being smart enough to resolve types correctly 😃
Workaround: “conflict”: { “symfony/console”: “>=v5.3.4||>=v4.4.27” },
Thanks @brosenberger & @Skyfly2021!
@Skyfly2021: I don’t have issues with
symfony/process, only withsymfony/consoleIt would be great if Magento’s
setup:di:compileprocess could look at the actual argument types and only falls back to the ones in phpdoc when the argument doesn’t have a type specified.Issue will happen for Magento 2.3.5 and higher versions (Magento 2.3.4 restricted
symfony/consoleto max version 4.1.9999)Finally, the PR https://github.com/laminas/laminas-code/pull/95 that fixes incorrect return type detecting was just merged and released in https://github.com/laminas/laminas-code/releases/tag/4.4.3! I’m going to prepare a new PR that will update the dependency for Laminas/code
@hostep workaround is temporary fix, also the issue is not on the Symfony side, but Magento, as it was for the “Laminas issue” 😃 I always encourage to update to the latest version of trusted packages such as laminas or Symfony, because they are well tested, mature and robust. Most of the time when there is an issue with a third party package upgrade, it’s because Magento codebase is poorly implemented. Magento has an important debt that won’t be fix because they know that “community” will find workaround or will fix it for them. Maybe we should let Magento assume their debt and pay for it?
If you want to patch the issue instead of pinning symfony/console’s version:
i created a pull request for symfony/console: https://github.com/symfony/symfony/pull/42281 and also any 2.3.x magento2 version is affected.
the problem are the missing php-doc parameters which are checked by the magento2 compiler
FYI I prepared PR to the laminas-code to fix the listed issue. https://github.com/laminas/laminas-code/pull/95 Waiting for a feedback
Please downgrade the package, finally solved: 1.composer require symfony/process:4.4.26 2.composer require symfony/console:4.4.26
Note: symfony/console has released a new version 4.4.29 as a hotfix for Magento where were resolved this issue. https://github.com/symfony/console/compare/v4.4.27...v4.4.29
Now you can run
composer update symfony/console. I added this workaround to the issue description.Note: this is not a permanent fix, we still should fix the root cause of this.
This also occurs in
2.4.2-p2too.I don’t think that not allowing versions higher then or equal to 4.4.27 to be installed is the correct workaround. You tend to forget about these workarounds and if symfony then releases a newer version that fixes a security issue, you’ll not get it.
It’s probably better to only conflict with version 4.4.27 and still allow higher versions. And then if it turns out that the next version still has the same problem, add that version to the conflict range.
It looks like they are considering reverting the change in the next version v4.4 of
symfony/console(which should be version <del>4.4.28</del> 4.4.29)