Skip to content

Commit d032e0e

Browse files
committed
HHVM > 3.26.2 still does not support private/protected constants. It allows the visibility keyword but ignores it.
1 parent c7b9b30 commit d032e0e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Enum.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,11 @@ private static function detectConstants($class)
351351

352352
do {
353353
$scopeConstants = [];
354-
if (\PHP_VERSION_ID >= 70100) {
354+
if (\PHP_VERSION_ID >= 70100 && method_exists(ReflectionClass::class, 'getReflectionConstants')) {
355355
// Since PHP-7.1 visibility modifiers are allowed for class constants
356356
// for enumerations we are only interested in public once.
357+
// NOTE: HHVM > 3.26.2 still does not support private/protected constants.
358+
// It allows the visibility keyword but ignores it.
357359
foreach ($reflection->getReflectionConstants() as $reflConstant) {
358360
if ($reflConstant->isPublic()) {
359361
$scopeConstants[ $reflConstant->getName() ] = $reflConstant->getValue();

tests/MabeEnumTest/EnumTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,9 @@ public function testConstVisibility()
388388
if (PHP_VERSION_ID < 70100) {
389389
$this->markTestSkipped('This test is for PHP-7.1 and upper only');
390390
}
391+
if (defined('HHVM_VERSION')) {
392+
$this->markTestSkipped('HHVM does not support constant visibility');
393+
}
391394

392395
$constants = ConstVisibilityEnum::getConstants();
393396
$this->assertSame(array(
@@ -401,6 +404,9 @@ public function testConstVisibilityExtended()
401404
if (PHP_VERSION_ID < 70100) {
402405
$this->markTestSkipped('This test is for PHP-7.1 and upper only');
403406
}
407+
if (defined('HHVM_VERSION')) {
408+
$this->markTestSkipped('HHVM does not support constant visibility');
409+
}
404410

405411
$constants = ConstVisibilityEnumExtended::getConstants();
406412
$this->assertSame(array(

0 commit comments

Comments
 (0)