Improved generics for higher order

This commit is contained in:
luke
2021-11-27 18:48:58 +00:00
parent c49700dd47
commit beb14ce5f4
9 changed files with 212 additions and 35 deletions

View File

@ -38,6 +38,10 @@ final class HigherOrderMessage
/**
* Re-throws the given `$throwable` with the good line and filename.
*
* @template TValue of object
*
* @param TValue $target
*/
public function call(object $target): mixed
{
@ -59,7 +63,7 @@ final class HigherOrderMessage
Reflection::setPropertyValue($throwable, 'line', $this->line);
if ($throwable->getMessage() === self::getUndefinedMethodMessage($target, $this->name)) {
/** @var ReflectionClass $reflection */
/** @var ReflectionClass<TValue> $reflection */
$reflection = new ReflectionClass($target);
/* @phpstan-ignore-next-line */
$reflection = $reflection->getParentClass() ?: $reflection;