From bb30d99e9363b8b0069d85202226ef711e111624 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Fri, 22 Mar 2024 15:39:19 +0100 Subject: [PATCH] Use static closures where possible --- src/Reflection/ReflectionMethod.php | 4 ++-- src/Reflection/ReflectionProperty.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Reflection/ReflectionMethod.php b/src/Reflection/ReflectionMethod.php index 69b82b4a8..a4d9999b4 100644 --- a/src/Reflection/ReflectionMethod.php +++ b/src/Reflection/ReflectionMethod.php @@ -427,7 +427,7 @@ private function callStaticMethod(array $args): mixed $implementingClassName = $this->getImplementingClass()->getName(); /** @psalm-suppress InvalidStringClass */ - $closure = Closure::bind(fn (string $implementingClassName, string $_methodName, array $methodArgs): mixed => $implementingClassName::{$_methodName}(...$methodArgs), null, $implementingClassName); + $closure = Closure::bind(static fn (string $implementingClassName, string $_methodName, array $methodArgs): mixed => $implementingClassName::{$_methodName}(...$methodArgs), null, $implementingClassName); assert($closure instanceof Closure); @@ -438,7 +438,7 @@ private function callStaticMethod(array $args): mixed private function callObjectMethod(object $object, array $args): mixed { /** @psalm-suppress MixedMethodCall */ - $closure = Closure::bind(fn (object $object, string $methodName, array $methodArgs): mixed => $object->{$methodName}(...$methodArgs), $object, $this->getImplementingClass()->getName()); + $closure = Closure::bind(static fn (object $object, string $methodName, array $methodArgs): mixed => $object->{$methodName}(...$methodArgs), $object, $this->getImplementingClass()->getName()); assert($closure instanceof Closure); diff --git a/src/Reflection/ReflectionProperty.php b/src/Reflection/ReflectionProperty.php index 52a65f341..f66895cb3 100644 --- a/src/Reflection/ReflectionProperty.php +++ b/src/Reflection/ReflectionProperty.php @@ -460,7 +460,7 @@ public function getValue(object|null $object = null): mixed $instance = $this->assertObject($object); - $closure = Closure::bind(fn (object $instance, string $propertyName): mixed => $instance->{$propertyName}, $instance, $implementingClassName); + $closure = Closure::bind(static fn (object $instance, string $propertyName): mixed => $instance->{$propertyName}, $instance, $implementingClassName); assert($closure instanceof Closure); @@ -494,7 +494,7 @@ public function setValue(mixed $object, mixed $value = null): void $instance = $this->assertObject($object); - $closure = Closure::bind(function (object $instance, string $propertyName, mixed $value): void { + $closure = Closure::bind(static function (object $instance, string $propertyName, mixed $value): void { $instance->{$propertyName} = $value; }, $instance, $implementingClassName);