Skip to content

Commit

Permalink
PHP 8.4 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 3, 2024
1 parent 81e3e6d commit b8ec3bc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Utils/Callback.php
Expand Up @@ -94,7 +94,9 @@ public static function toReflection($callable): \ReflectionMethod|\ReflectionFun
}

if (is_string($callable) && str_contains($callable, '::')) {
return new ReflectionMethod($callable);
return PHP_VERSION_ID < 80300
? new ReflectionMethod($callable)
: ReflectionMethod::createFromMethodName($callable);

Check failure on line 99 in src/Utils/Callback.php

View workflow job for this annotation

GitHub Actions / PHPStan

Call to an undefined static method Nette\Utils\ReflectionMethod::createFromMethodName().
} elseif (is_array($callable)) {
return new ReflectionMethod($callable[0], $callable[1]);
} elseif (is_object($callable) && !$callable instanceof \Closure) {
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/Reflection.php
Expand Up @@ -100,7 +100,7 @@ public static function getMethodDeclaringMethod(\ReflectionMethod $method): \Ref

$hash = [$method->getFileName(), $method->getStartLine(), $method->getEndLine()];
if (($alias = $decl->getTraitAliases()[$method->name] ?? null)
&& ($m = new \ReflectionMethod($alias))
&& ($m = PHP_VERSION_ID < 80300 ? new \ReflectionMethod($alias) : \ReflectionMethod::createFromMethodName($alias))
&& $hash === [$m->getFileName(), $m->getStartLine(), $m->getEndLine()]
) {
return self::getMethodDeclaringMethod($m);
Expand Down

0 comments on commit b8ec3bc

Please sign in to comment.