From 37e36d8361712f84e08a8324f9c56438125c46d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nico=20Hiort=20af=20Orn=C3=A4s?= Date: Fri, 14 Mar 2025 13:25:35 +0200 Subject: [PATCH 1/3] Fix ReflectionMethod::__construct() deprecations Fixes the following issues: 1) /symfony/vendor/angelov/phpunit-php-vcr/src/Subscribers/AttributeResolverTrait.php:28 Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead 2) /symfony/vendor/angelov/phpunit-php-vcr/src/Subscribers/AttributeResolverTrait.php:51 Calling ReflectionMethod::__construct() with 1 argument is deprecated, use ReflectionMethod::createFromMethodName() instead --- src/Subscribers/AttributeResolverTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Subscribers/AttributeResolverTrait.php b/src/Subscribers/AttributeResolverTrait.php index 1dd1097..ed4e845 100644 --- a/src/Subscribers/AttributeResolverTrait.php +++ b/src/Subscribers/AttributeResolverTrait.php @@ -25,7 +25,7 @@ private function getAttribute(string $test): ?UseCassette $test = $this->parseMethod($test); try { - $method = new ReflectionMethod($test); + $method = ReflectionMethod::createFromMethodName($test); } catch (Exception) { return null; } @@ -48,7 +48,7 @@ private function parseMethod(string $test): string private function getAttributeFromClass(string $test): ?UseCassette { - $method = new ReflectionMethod($test); + $method = ReflectionMethod::createFromMethodName($test); $class = $method->getDeclaringClass(); $attributes = $class->getAttributes(UseCassette::class); From b4c916b9803601297721a19100b0fdf21b07ed96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nico=20Hiort=20af=20Orn=C3=A4s?= Date: Tue, 18 Mar 2025 13:45:25 +0200 Subject: [PATCH 2/3] Keep support for PHP 8.2 --- src/Subscribers/AttributeResolverTrait.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Subscribers/AttributeResolverTrait.php b/src/Subscribers/AttributeResolverTrait.php index ed4e845..55e00ac 100644 --- a/src/Subscribers/AttributeResolverTrait.php +++ b/src/Subscribers/AttributeResolverTrait.php @@ -25,7 +25,11 @@ private function getAttribute(string $test): ?UseCassette $test = $this->parseMethod($test); try { - $method = ReflectionMethod::createFromMethodName($test); + if (PHP_VERSION_ID < 80300) { + $method = new ReflectionMethod($test); + } else { + $method = ReflectionMethod::createFromMethodName($test); + } } catch (Exception) { return null; } @@ -48,7 +52,11 @@ private function parseMethod(string $test): string private function getAttributeFromClass(string $test): ?UseCassette { - $method = ReflectionMethod::createFromMethodName($test); + if (PHP_VERSION_ID < 80300) { + $method = new ReflectionMethod($test); + } else { + $method = ReflectionMethod::createFromMethodName($test); + } $class = $method->getDeclaringClass(); $attributes = $class->getAttributes(UseCassette::class); From ccade350dcf2fef9074388684a16c6c84c55e94f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nico=20Hiort=20af=20Orn=C3=A4s?= Date: Tue, 18 Mar 2025 16:21:25 +0200 Subject: [PATCH 3/3] Ignore error in phpstan --- src/Subscribers/AttributeResolverTrait.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Subscribers/AttributeResolverTrait.php b/src/Subscribers/AttributeResolverTrait.php index 55e00ac..556f7a4 100644 --- a/src/Subscribers/AttributeResolverTrait.php +++ b/src/Subscribers/AttributeResolverTrait.php @@ -28,6 +28,7 @@ private function getAttribute(string $test): ?UseCassette if (PHP_VERSION_ID < 80300) { $method = new ReflectionMethod($test); } else { + // @phpstan-ignore-next-line $method = ReflectionMethod::createFromMethodName($test); } } catch (Exception) { @@ -55,6 +56,7 @@ private function getAttributeFromClass(string $test): ?UseCassette if (PHP_VERSION_ID < 80300) { $method = new ReflectionMethod($test); } else { + // @phpstan-ignore-next-line $method = ReflectionMethod::createFromMethodName($test); } $class = $method->getDeclaringClass();