diff --git a/src/MethodMetadata.php b/src/MethodMetadata.php index 742853a..49da3a2 100644 --- a/src/MethodMetadata.php +++ b/src/MethodMetadata.php @@ -72,7 +72,9 @@ private function getReflection(): \ReflectionMethod { if (null === $this->reflection) { $this->reflection = new \ReflectionMethod($this->class, $this->name); - $this->reflection->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $this->reflection->setAccessible(true); + } } return $this->reflection; diff --git a/tests/MethodMetadataTest.php b/tests/MethodMetadataTest.php index 96a2803..8935c55 100644 --- a/tests/MethodMetadataTest.php +++ b/tests/MethodMetadataTest.php @@ -14,7 +14,9 @@ public function testConstructor() { $metadata = new MethodMetadata(TestObject::class, 'setFoo'); $expectedReflector = new \ReflectionMethod(TestObject::class, 'setFoo'); - $expectedReflector->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $expectedReflector->setAccessible(true); + } $this->assertEquals(TestObject::class, $metadata->class); $this->assertEquals('setFoo', $metadata->name); @@ -43,7 +45,9 @@ public function testLazyReflectionCreationOnConstruction() $metadata = new MethodMetadata(TestObject::class, 'setFoo'); $reflectionProperty = new \ReflectionProperty(MethodMetadata::class, 'reflection'); - $reflectionProperty->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $reflectionProperty->setAccessible(true); + } $this->assertNull($reflectionProperty->getValue($metadata)); } @@ -54,7 +58,9 @@ public function testLazyReflectionCreationOnUnserialize() unserialize(serialize($metadata)); $reflectionProperty = new \ReflectionProperty(MethodMetadata::class, 'reflection'); - $reflectionProperty->setAccessible(true); + if (\PHP_VERSION_ID < 80100) { + $reflectionProperty->setAccessible(true); + } $this->assertNull($reflectionProperty->getValue($metadata)); }