typhoon icon indicating copy to clipboard operation
typhoon copied to clipboard

Type resolution edge case

Open klimick opened this issue 10 months ago • 0 comments

interface A {}
interface B {}
final class AB implements A, B {}

interface GetA
{
    /**
     * @return A
     */
    public function get(): mixed;
}

interface GetB
{
    /**
     * @return B
     */
    public function get(): mixed;
}

final class Impl implements GetA, GetB
{
    public function get(): mixed
    {
        return new AB();
    }
}

$implReflection = TyphoonReflector::build()->reflectClass(Impl::class);

var_dump(TypeStringifier::stringify(
    $implReflection
        ->getMethod('get')
        ->getTyphoonReturnType(),
));

Actual output:

/home/klimenko/IdeaProjects/typhoon-reflection/main.php:41:
string(1) "A"

Expected output:

/home/klimenko/IdeaProjects/typhoon-reflection/main.php:41:
string(1) "A&B"

klimick avatar Apr 05 '24 15:04 klimick