Skip to content

Commit c8d1216

Browse files
committed
Treat magic constants like normal constants
1 parent 8999a13 commit c8d1216

File tree

3 files changed

+345
-301
lines changed

3 files changed

+345
-301
lines changed

grammar/php7.y

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,14 @@ ctor_arguments:
831831

832832
constant:
833833
name { $$ = Expr\ConstFetch[$1]; }
834+
| T_LINE { $$ = Scalar\MagicConst\Line[]; }
835+
| T_FILE { $$ = Scalar\MagicConst\File[]; }
836+
| T_DIR { $$ = Scalar\MagicConst\Dir[]; }
837+
| T_CLASS_C { $$ = Scalar\MagicConst\Class_[]; }
838+
| T_TRAIT_C { $$ = Scalar\MagicConst\Trait_[]; }
839+
| T_METHOD_C { $$ = Scalar\MagicConst\Method[]; }
840+
| T_FUNC_C { $$ = Scalar\MagicConst\Function_[]; }
841+
| T_NS_C { $$ = Scalar\MagicConst\Namespace_[]; }
834842
;
835843

836844
class_constant:
@@ -864,14 +872,6 @@ dereferencable_scalar:
864872
scalar:
865873
T_LNUMBER { $$ = $this->parseLNumber($1, attributes()); }
866874
| T_DNUMBER { $$ = Scalar\DNumber[Scalar\DNumber::parse($1)]; }
867-
| T_LINE { $$ = Scalar\MagicConst\Line[]; }
868-
| T_FILE { $$ = Scalar\MagicConst\File[]; }
869-
| T_DIR { $$ = Scalar\MagicConst\Dir[]; }
870-
| T_CLASS_C { $$ = Scalar\MagicConst\Class_[]; }
871-
| T_TRAIT_C { $$ = Scalar\MagicConst\Trait_[]; }
872-
| T_METHOD_C { $$ = Scalar\MagicConst\Method[]; }
873-
| T_FUNC_C { $$ = Scalar\MagicConst\Function_[]; }
874-
| T_NS_C { $$ = Scalar\MagicConst\Namespace_[]; }
875875
| dereferencable_scalar { $$ = $1; }
876876
| constant { $$ = $1; }
877877
| class_constant { $$ = $1; }

0 commit comments

Comments
 (0)