Skip to content

Commit e627ae7

Browse files
committed
Backport #98: HHVM >3.18.4 & >3.20.2 reports as PHP-7.1 but does not support constant visibility
1 parent 7636429 commit e627ae7

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
@@ -378,9 +378,11 @@ private static function detectConstants($class)
378378

379379
do {
380380
$scopeConstants = array();
381-
if (PHP_VERSION_ID >= 70100) {
381+
if (\PHP_VERSION_ID >= 70100 && method_exists('ReflectionClass', 'getReflectionConstants')) {
382382
// Since PHP-7.1 visibility modifiers are allowed for class constants
383383
// for enumerations we are only interested in public once.
384+
// NOTE: HHVM > 3.26.2 still does not support private/protected constants.
385+
// It allows the visibility keyword but ignores it.
384386
foreach ($reflection->getReflectionConstants() as $reflConstant) {
385387
if ($reflConstant->isPublic()) {
386388
$scopeConstants[ $reflConstant->getName() ] = $reflConstant->getValue();

tests/MabeEnumTest/EnumTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ public function testConstVisibility()
297297
if (PHP_VERSION_ID < 70100) {
298298
$this->markTestSkipped('This test is for PHP-7.1 and upper only');
299299
}
300+
if (defined('HHVM_VERSION')) {
301+
$this->markTestSkipped('HHVM does not support constant visibility');
302+
}
300303

301304
$constants = ConstVisibilityEnum::getConstants();
302305
$this->assertSame(array(
@@ -310,6 +313,9 @@ public function testConstVisibilityExtended()
310313
if (PHP_VERSION_ID < 70100) {
311314
$this->markTestSkipped('This test is for PHP-7.1 and upper only');
312315
}
316+
if (defined('HHVM_VERSION')) {
317+
$this->markTestSkipped('HHVM does not support constant visibility');
318+
}
313319

314320
$constants = ConstVisibilityEnumExtended::getConstants();
315321
$this->assertSame(array(

0 commit comments

Comments
 (0)