rectorphp/rector-symfony

SymfonyLevelSetList::UP_TO_SYMFONY_43 is too aggressive toward `CacheInterface`

Jean85 opened this issue · 7 comments

Jean85 commented

The SymfonyLevelSetList::UP_TO_SYMFONY_43 level set includes a RenameClassRector configuration for PSR-6's CacheInterface, which is definitely too aggressive:

'Psr\SimpleCache\CacheInterface' => 'Symfony\Contracts\Cache\CacheInterface',

This acts on any possible PSR-16 that I may have in my codebase, breaking them; also, since it's a RenameClassRector and not a specific rector, I cannot disable it in any way, apart from loosing any other possible rename RenameClassRector on that class.

Is there any workaround? What can I do?

Hi, thanks for reporting. What was the original change in Symfony that invoke this?

Jean85 commented

The set reports symfony/symfony#29236 a few rows above as a comment. That change makes some sense in a Symfony-only context, but if my code is to stay interoperable leveraging PSR-16, this rule will break that interop.

I see. This is a pickle as Rector can upgrade only A → B deterministics cases, so it will require bit hacking to get through :)

If you need to upgrade Symfony, but just somewhere, you can comment out this line, apply the upgrade set for Symfony 4.3, then change the cache classes yourself where needed. Then remove the Symfony 4.3 upgrade set and continue to Symfony 4.4 👍

Jean85 commented

Thank you for the suggestion. Is there though a way to remove the 4.3 set without having to renounce to the whole UP_TO_SYMFONY_* LevelSets?

If you need different behavior. Not really.

The best practice is to use those sets only for upgrade, not in long-term.

This will help avoid these issues: rectorphp/rector-src#5477

Resolved inhttps://github.com//pull/574