Skip to content

Commit ab154b7

Browse files
committed
Make class constants fully dereferencable
1 parent de7c7ef commit ab154b7

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
Class constants can be used as a class name
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
const NAME = 'Test2';
8+
}
9+
10+
class Test2 {
11+
const FOO = 42;
12+
public static $foo = 42;
13+
14+
public static function foo() {
15+
return 42;
16+
}
17+
}
18+
19+
var_dump(Test::NAME::FOO);
20+
var_dump(Test::NAME::$foo);
21+
var_dump(Test::NAME::foo());
22+
23+
?>
24+
--EXPECT--
25+
int(42)
26+
int(42)
27+
int(42)

Zend/zend_language_parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,12 +1150,12 @@ fully_dereferencable:
11501150
variable { $$ = $1; }
11511151
| '(' expr ')' { $$ = $2; }
11521152
| dereferencable_scalar { $$ = $1; }
1153+
| class_constant { $$ = $1; }
11531154
;
11541155

11551156
array_object_dereferencable:
11561157
fully_dereferencable { $$ = $1; }
11571158
| constant { $$ = $1; }
1158-
| class_constant { $$ = $1; }
11591159
;
11601160

11611161
callable_expr:

0 commit comments

Comments
 (0)