Bug Report
| Subject |
Details |
| Rector version |
e.g. v0.10.1 |
| Installed as |
composer dependency |
Package symfony/cache has file vendor/symfony/cache/CacheItem.php, with this content (here):
final class CacheItem implements ItemInterface
{
public function tag($tags): ItemInterface
{
// ...
return $this;
}
}
The interface ItemInterface has this content (here):
interface ItemInterface extends CacheItemInterface
{
public function tag($tags): self;
}
The downgrade set for PHP 7.4 has these 2 rules, in this same order:
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(DowngradeCovariantReturnTypeRector::class);
$services->set(DowngradeSelfTypeDeclarationRector::class);
};
When downgrading CacheItem.php, function tag should be modified twice:
DowngradeCovariantReturnTypeRector must first transform the return type, from ItemInterface to self
DowngradeSelfTypeDeclarationRector should then remove the self return type
But the second step is not happening. As a consequence, after running the downgrade, function tag returns self, which is not accepted for PHP 7.3.
Minimal PHP Code Causing Issue
I tried to recreate the problem here, but the output is different:
https://getrector.org/demo/0d1b5ce4-c1a3-4fb8-bc3f-1fbe982f6e90
Bug Report
Package
symfony/cachehas filevendor/symfony/cache/CacheItem.php, with this content (here):The interface
ItemInterfacehas this content (here):The downgrade set for PHP 7.4 has these 2 rules, in this same order:
When downgrading
CacheItem.php, functiontagshould be modified twice:DowngradeCovariantReturnTypeRectormust first transform the return type, fromItemInterfacetoselfDowngradeSelfTypeDeclarationRectorshould then remove theselfreturn typeBut the second step is not happening. As a consequence, after running the downgrade, function
tagreturnsself, which is not accepted for PHP 7.3.Minimal PHP Code Causing Issue
I tried to recreate the problem here, but the output is different:
https://getrector.org/demo/0d1b5ce4-c1a3-4fb8-bc3f-1fbe982f6e90