DowngradeCovariantReturnTypeRector
Make method return same type as parent
class ParentType {}
class ChildType extends ParentType {}
class A
{
public function covariantReturnTypes(): ParentType
{
}
}
class B extends A
{
- public function covariantReturnTypes(): ChildType
+ /**
+ * @return ChildType
+ */
+ public function covariantReturnTypes(): ParentType
{
}
}
Configure your rector.php:
<?php
use Rector\Config\RectorConfig;
use Rector\DowngradePhp74\Rector\ClassMethod\DowngradeCovariantReturnTypeRector;
return RectorConfig::configure()
->withRules([
DowngradeCovariantReturnTypeRector::class,
]);