Skip to content

Commit 65feecd

Browse files
authored
Merge pull request #8 from marc-mabe/php8
Added support for PHP-8, fixes #7
2 parents 2c43cf7 + d00a789 commit 65feecd

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
CODE_COVERAGE: true
2424
- PHP_VERSION: 7.4
2525
CODE_COVERAGE: true
26+
- PHP_VERSION: 8.0-rc
27+
CODE_COVERAGE: true
2628

2729
steps:
2830
- uses: actions/checkout@v2

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"keywords": ["enum", "phpstan"],
66
"license": "BSD-3-Clause",
77
"require": {
8-
"php": "^7.1",
8+
"php": "^7.1 | ^8.0",
99
"marc-mabe/php-enum": "^1.1 || ^2.0 || ^3.0 || ^4.0",
1010
"phpstan/phpstan": "^0.12"
1111
},

src/EnumMethodsClassReflectionExtension.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class EnumMethodsClassReflectionExtension implements MethodsClassReflectionExten
1111
{
1212
public function hasMethod(ClassReflection $classReflection, string $methodName): bool
1313
{
14-
if ($classReflection->isSubclassOf(Enum::class)) {
15-
$array = $classReflection->getNativeReflection()->getMethod('getConstants')->invoke(null);
16-
17-
return array_key_exists($methodName, $array);
14+
if (!$classReflection->isSubclassOf(Enum::class)) {
15+
return false;
1816
}
1917

20-
return false;
18+
/** @var string|Enum $class */
19+
$class = $classReflection->getName();
20+
return array_key_exists($methodName, $class::getConstants());
2121
}
2222

2323
public function getMethod(ClassReflection $classReflection, string $methodName): MethodReflection

0 commit comments

Comments
 (0)