-
-
Notifications
You must be signed in to change notification settings - Fork 736
Closed
rectorphp/rector-downgrade-php
#271Labels
Description
Bug Report
| Subject | Details |
|---|---|
| Rector version | last dev-main |
| Installed as | composer dependency |
Minimal PHP Code Causing Issue
When method implements interface with union of of parent method, the union return removed, then after it, it cause fatal error
Fatal error: Declaration of Imp::run() must be compatible with DoX::run(): FooInterface
this should copy method interface return instead.
See https://getrector.com/demo/80f293b5-ef36-4df0-bb0c-ede44636885a
<?php
interface FooInterface {}
class A implements FooInterface {}
class B implements FooInterface {}
interface DoX
{
public function run(): FooInterface;
}
class Imp implements DoX
{
public function run(): A|B
{
return new A();
}
}Responsible rules
DowngradeUnionTypeDeclarationRector
Expected Behavior
/**
* @return \A|\B
*/
- public function run(): A|B
+ public function run(): FooInterface
{
return new A();
}