Make class constants fully dereferencable

This commit is contained in:
Nikita Popov 2020-01-06 15:57:47 +01:00
parent de7c7efee9
commit ab154b7a64
2 changed files with 28 additions and 1 deletions

View File

@ -0,0 +1,27 @@
--TEST--
Class constants can be used as a class name
--FILE--
<?php
class Test {
const NAME = 'Test2';
}
class Test2 {
const FOO = 42;
public static $foo = 42;
public static function foo() {
return 42;
}
}
var_dump(Test::NAME::FOO);
var_dump(Test::NAME::$foo);
var_dump(Test::NAME::foo());
?>
--EXPECT--
int(42)
int(42)
int(42)

View File

@ -1150,12 +1150,12 @@ fully_dereferencable:
variable { $$ = $1; }
| '(' expr ')' { $$ = $2; }
| dereferencable_scalar { $$ = $1; }
| class_constant { $$ = $1; }
;
array_object_dereferencable:
fully_dereferencable { $$ = $1; }
| constant { $$ = $1; }
| class_constant { $$ = $1; }
;
callable_expr: