Skip to content

Commit 786299f

Browse files
committed
Restore compatibility with XP < 10.8.0
1 parent 2fc6a5b commit 786299f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"description" : "XP Compiler",
77
"keywords": ["module", "xp"],
88
"require" : {
9-
"xp-framework/core": "^10.8",
9+
"xp-framework/core": "^10.0 | ^9.0 | ^8.0 | ^7.0",
1010
"xp-framework/ast": "dev-feature/php-enums as 7.1.0",
1111
"php" : ">=7.0.0"
1212
},

src/main/php/lang/ast/emit/Reflection.class.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
class Reflection extends Type {
66
private $reflect;
7+
private static $UNITENUM;
78

8-
static function __static() { }
9+
static function __static() {
10+
self::$UNITENUM= interface_exists(\UnitEnum::class, false); // Compatibility with XP < 10.8.0
11+
}
912

1013
/** @param string $type */
1114
public function __construct($type) {
@@ -28,7 +31,7 @@ public function name() { return $this->reflect->name; }
2831
public function rewriteEnumCase($member) {
2932
if ($this->reflect->isSubclassOf(Enum::class)) {
3033
return $this->reflect->getStaticPropertyValue($member, null) instanceof Enum;
31-
} else if (!self::$ENUMS && $this->reflect->isSubclassOf(\UnitEnum::class)) {
34+
} else if (!self::$ENUMS && self::$UNITENUM && $this->reflect->isSubclassOf(\UnitEnum::class)) {
3235
$value= $this->reflect->getConstant($member) ?: $this->reflect->getStaticPropertyValue($member, null);
3336
return $value instanceof \UnitEnum;
3437
}

0 commit comments

Comments
 (0)