Skip to content

Commit

Permalink
Fix weaken for PHP8.4 closure names (#1303)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nevay authored May 2, 2024
1 parent 100e593 commit 82b191b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/SDK/Common/Util/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Closure;
use ReflectionFunction;
use stdClass;
use function str_starts_with;
use WeakReference;

/**
Expand All @@ -30,7 +31,7 @@ function weaken(Closure $closure, ?object &$target = null): Closure

$scope = $reflection->getClosureScopeClass();
$name = $reflection->getShortName();
if ($name !== '{closure}') {
if (!str_starts_with($name, '{closure')) {
/** @psalm-suppress InvalidScope @phpstan-ignore-next-line @phan-suppress-next-line PhanUndeclaredThis */
$closure = fn (...$args) => $this->$name(...$args);
if ($scope !== null) {
Expand Down

0 comments on commit 82b191b

Please sign in to comment.