You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implemented method with the same conditional return type as the interface reports ImplementedReturnTypeMismatch #12988
<?php/** * @template T = mixed */interface Box
{
/** * @template U = never * @param (callable(T): U)|null $f * @return Box<($f is null ? T : U)> */publicfunctionmap(?callable$f = null): Box;
}
/** * @template T = mixed * @implements Box<T> */finalclass Just implements Box
{
/** @param T $value */publicfunction__construct(privatemixed$value) {}
/** * @template U = never * @param (callable(T): U)|null $f * @return Box<($f is null ? T : U)> */publicfunctionmap(?callable$f = null): Box
{
return$f === null ? $this : newJust($f($this->value));
}
}
ImplementedReturnTypeMismatch (line 27): The inherited return type 'Box<(T:Just as mixed)|(U:fn-box::map as mixed)>' for Box::map is different to the implemented return type for Just::map 'Box<(TGeneratedFromParam0 is null ? T:Just as mixed : U:fn-just::map as mixed)>'
The docblocks are identical. The inherited type has its conditional collapsed to T|U, while the implemented one keeps it, so the comparison fails. Expected: no issue.
Seen on guzzle/promises 3.1.0 (Promise::then, Coroutine::then), now in the perf corpus (#12984).
Activity
fix(templates): read the conditional return of an implementation for …
fix(templates): compare the conditional return type of an implementat…