Skip to content

Commit 9cd4ec1

Browse files
authored
Fix ReflectionMethod::__construct() deprecations (#7)
1 parent b239035 commit 9cd4ec1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/Subscribers/AttributeResolverTrait.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ private function getAttribute(string $test): ?UseCassette
2525
$test = $this->parseMethod($test);
2626

2727
try {
28-
$method = new ReflectionMethod($test);
28+
if (PHP_VERSION_ID < 80300) {
29+
$method = new ReflectionMethod($test);
30+
} else {
31+
// @phpstan-ignore-next-line
32+
$method = ReflectionMethod::createFromMethodName($test);
33+
}
2934
} catch (Exception) {
3035
return null;
3136
}
@@ -48,7 +53,12 @@ private function parseMethod(string $test): string
4853

4954
private function getAttributeFromClass(string $test): ?UseCassette
5055
{
51-
$method = new ReflectionMethod($test);
56+
if (PHP_VERSION_ID < 80300) {
57+
$method = new ReflectionMethod($test);
58+
} else {
59+
// @phpstan-ignore-next-line
60+
$method = ReflectionMethod::createFromMethodName($test);
61+
}
5262
$class = $method->getDeclaringClass();
5363
$attributes = $class->getAttributes(UseCassette::class);
5464

0 commit comments

Comments
 (0)