PHP 8 and PHPUnit 9.3 support

This commit is contained in:
Graham Campbell
2020-08-07 11:23:45 +01:00
parent 051ca73cae
commit 3cfadee2bb
11 changed files with 95 additions and 48 deletions

View File

@ -76,7 +76,7 @@ final class HigherOrderMessage
Reflection::setPropertyValue($throwable, 'file', $this->filename);
Reflection::setPropertyValue($throwable, 'line', $this->line);
if ($throwable->getMessage() === sprintf(self::UNDEFINED_METHOD, $this->methodName)) {
if ($throwable->getMessage() === self::getUndefinedMethodMessage($target, $this->methodName)) {
/** @var \ReflectionClass $reflection */
$reflection = new ReflectionClass($target);
/* @phpstan-ignore-next-line */
@ -87,4 +87,13 @@ final class HigherOrderMessage
throw $throwable;
}
}
private static function getUndefinedMethodMessage(object $target, string $methodName): string
{
if (\PHP_MAJOR_VERSION >= 8) {
return sprintf(sprintf(self::UNDEFINED_METHOD, sprintf('%s::%s()', get_class($target), $methodName)));
}
return sprintf(self::UNDEFINED_METHOD, $methodName);
}
}