Skip to content

Commit 7a2ed46

Browse files
committed
Fix #388: Cannot use the class magic constant in traits.
1 parent 9323bb9 commit 7a2ed46

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

jphp-core/src/org/develnext/jphp/core/syntax/generators/manually/SimpleExprGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ protected Token processStaticAccess(Token current, Token previous, ListIterator<
644644
} else
645645
unexpectedToken(current);
646646
} else if (current instanceof ClassStmtToken) { // PHP 5.5 ::class
647-
if (clazz instanceof ParentExprToken || clazz instanceof StaticExprToken) {
647+
if (clazz instanceof ParentExprToken || clazz instanceof StaticExprToken || clazz instanceof SelfExprToken) {
648648
if (clazz instanceof StaticExprToken) {
649649
analyzer.getScope().setStaticExists(true);
650650
}

jphp-core/tests/org/develnext/jphp/core/compiler/jvm/ClassesTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ public void testBug404() {
158158
check("classes/bug404.phpt", true);
159159
}
160160

161+
@Test
162+
public void testBug388() {
163+
check("classes/bug388.phpt", true);
164+
}
165+
161166
@Test
162167
public void testBug264() {
163168
check("classes/bug264.php");
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Cannot use the `class` magic constant in traits
3+
--FILE--
4+
<?php
5+
trait a
6+
{
7+
public static function test() { var_dump(self::class); }
8+
}
9+
a::test();
10+
?>
11+
--EXPECT--
12+
string(1) "a"

0 commit comments

Comments
 (0)