Skip to content

Commit c665dc6

Browse files
committed
check if method exists instead of php version
1 parent e3d3328 commit c665dc6

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/Subscribers/AttributeResolverTrait.php

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

2727
try {
28-
if (PHP_VERSION_ID < 80300) {
29-
$method = new ReflectionMethod($test);
30-
} else {
31-
// @phpstan-ignore-next-line
28+
if (method_exists(ReflectionMethod::class, 'createFromMethodName')) {
3229
$method = ReflectionMethod::createFromMethodName($test);
30+
} else {
31+
$method = new ReflectionMethod($test);
3332
}
3433
} catch (Exception) {
3534
return null;
@@ -53,12 +52,12 @@ private function parseMethod(string $test): string
5352

5453
private function getAttributeFromClass(string $test): ?UseCassette
5554
{
56-
if (PHP_VERSION_ID < 80300) {
57-
$method = new ReflectionMethod($test);
58-
} else {
59-
// @phpstan-ignore-next-line
55+
if (method_exists(ReflectionMethod::class, 'createFromMethodName')) {
6056
$method = ReflectionMethod::createFromMethodName($test);
57+
} else {
58+
$method = new ReflectionMethod($test);
6159
}
60+
6261
$class = $method->getDeclaringClass();
6362
$attributes = $class->getAttributes(UseCassette::class);
6463

0 commit comments

Comments
 (0)