123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490 |
- Valid usages of reserved keywords as identifiers
- -----
- <?php
- class Test {
- function array() {}
- function public() {}
- static function list() {}
- static function protected() {}
- public $class;
- public $private;
- const TRAIT = 3, FINAL = 4;
- const __CLASS__ = 1, __TRAIT__ = 2, __FUNCTION__ = 3, __METHOD__ = 4, __LINE__ = 5,
- __FILE__ = 6, __DIR__ = 7, __NAMESPACE__ = 8;
- // __halt_compiler does not work
- }
- $t = new Test;
- $t->array();
- $t->public();
- Test::list();
- Test::protected();
- $t->class;
- $t->private;
- Test::TRAIT;
- Test::FINAL;
- class Foo {
- use TraitA, TraitB {
- TraitA::catch insteadof namespace\TraitB;
- TraitA::list as foreach;
- TraitB::throw as protected public;
- TraitB::self as protected;
- exit as die;
- \TraitC::exit as bye;
- namespace\TraitC::exit as byebye;
- TraitA::
- //
- /** doc comment */
- #
- catch /* comment */
- // comment
- # comment
- insteadof TraitB;
- }
- }
- -----
- array(
- 0: Stmt_Class(
- flags: 0
- name: Identifier(
- name: Test
- )
- extends: null
- implements: array(
- )
- stmts: array(
- 0: Stmt_ClassMethod(
- flags: 0
- byRef: false
- name: Identifier(
- name: array
- )
- params: array(
- )
- returnType: null
- stmts: array(
- )
- )
- 1: Stmt_ClassMethod(
- flags: 0
- byRef: false
- name: Identifier(
- name: public
- )
- params: array(
- )
- returnType: null
- stmts: array(
- )
- )
- 2: Stmt_ClassMethod(
- flags: MODIFIER_STATIC (8)
- byRef: false
- name: Identifier(
- name: list
- )
- params: array(
- )
- returnType: null
- stmts: array(
- )
- )
- 3: Stmt_ClassMethod(
- flags: MODIFIER_STATIC (8)
- byRef: false
- name: Identifier(
- name: protected
- )
- params: array(
- )
- returnType: null
- stmts: array(
- )
- )
- 4: Stmt_Property(
- flags: MODIFIER_PUBLIC (1)
- type: null
- props: array(
- 0: Stmt_PropertyProperty(
- name: VarLikeIdentifier(
- name: class
- )
- default: null
- )
- )
- )
- 5: Stmt_Property(
- flags: MODIFIER_PUBLIC (1)
- type: null
- props: array(
- 0: Stmt_PropertyProperty(
- name: VarLikeIdentifier(
- name: private
- )
- default: null
- )
- )
- )
- 6: Stmt_ClassConst(
- flags: 0
- consts: array(
- 0: Const(
- name: Identifier(
- name: TRAIT
- )
- value: Scalar_LNumber(
- value: 3
- )
- )
- 1: Const(
- name: Identifier(
- name: FINAL
- )
- value: Scalar_LNumber(
- value: 4
- )
- )
- )
- )
- 7: Stmt_ClassConst(
- flags: 0
- consts: array(
- 0: Const(
- name: Identifier(
- name: __CLASS__
- )
- value: Scalar_LNumber(
- value: 1
- )
- )
- 1: Const(
- name: Identifier(
- name: __TRAIT__
- )
- value: Scalar_LNumber(
- value: 2
- )
- )
- 2: Const(
- name: Identifier(
- name: __FUNCTION__
- )
- value: Scalar_LNumber(
- value: 3
- )
- )
- 3: Const(
- name: Identifier(
- name: __METHOD__
- )
- value: Scalar_LNumber(
- value: 4
- )
- )
- 4: Const(
- name: Identifier(
- name: __LINE__
- )
- value: Scalar_LNumber(
- value: 5
- )
- )
- 5: Const(
- name: Identifier(
- name: __FILE__
- )
- value: Scalar_LNumber(
- value: 6
- )
- )
- 6: Const(
- name: Identifier(
- name: __DIR__
- )
- value: Scalar_LNumber(
- value: 7
- )
- )
- 7: Const(
- name: Identifier(
- name: __NAMESPACE__
- )
- value: Scalar_LNumber(
- value: 8
- )
- )
- )
- )
- 8: Stmt_Nop(
- comments: array(
- 0: // __halt_compiler does not work
- )
- )
- )
- )
- 1: Stmt_Expression(
- expr: Expr_Assign(
- var: Expr_Variable(
- name: t
- )
- expr: Expr_New(
- class: Name(
- parts: array(
- 0: Test
- )
- )
- args: array(
- )
- )
- )
- )
- 2: Stmt_Expression(
- expr: Expr_MethodCall(
- var: Expr_Variable(
- name: t
- )
- name: Identifier(
- name: array
- )
- args: array(
- )
- )
- )
- 3: Stmt_Expression(
- expr: Expr_MethodCall(
- var: Expr_Variable(
- name: t
- )
- name: Identifier(
- name: public
- )
- args: array(
- )
- )
- )
- 4: Stmt_Expression(
- expr: Expr_StaticCall(
- class: Name(
- parts: array(
- 0: Test
- )
- )
- name: Identifier(
- name: list
- )
- args: array(
- )
- )
- )
- 5: Stmt_Expression(
- expr: Expr_StaticCall(
- class: Name(
- parts: array(
- 0: Test
- )
- )
- name: Identifier(
- name: protected
- )
- args: array(
- )
- )
- )
- 6: Stmt_Expression(
- expr: Expr_PropertyFetch(
- var: Expr_Variable(
- name: t
- )
- name: Identifier(
- name: class
- )
- )
- )
- 7: Stmt_Expression(
- expr: Expr_PropertyFetch(
- var: Expr_Variable(
- name: t
- )
- name: Identifier(
- name: private
- )
- )
- )
- 8: Stmt_Expression(
- expr: Expr_ClassConstFetch(
- class: Name(
- parts: array(
- 0: Test
- )
- )
- name: Identifier(
- name: TRAIT
- )
- )
- )
- 9: Stmt_Expression(
- expr: Expr_ClassConstFetch(
- class: Name(
- parts: array(
- 0: Test
- )
- )
- name: Identifier(
- name: FINAL
- )
- )
- )
- 10: Stmt_Class(
- flags: 0
- name: Identifier(
- name: Foo
- )
- extends: null
- implements: array(
- )
- stmts: array(
- 0: Stmt_TraitUse(
- traits: array(
- 0: Name(
- parts: array(
- 0: TraitA
- )
- )
- 1: Name(
- parts: array(
- 0: TraitB
- )
- )
- )
- adaptations: array(
- 0: Stmt_TraitUseAdaptation_Precedence(
- trait: Name(
- parts: array(
- 0: TraitA
- )
- )
- method: Identifier(
- name: catch
- )
- insteadof: array(
- 0: Name_Relative(
- parts: array(
- 0: TraitB
- )
- )
- )
- )
- 1: Stmt_TraitUseAdaptation_Alias(
- trait: Name(
- parts: array(
- 0: TraitA
- )
- )
- method: Identifier(
- name: list
- )
- newModifier: null
- newName: Identifier(
- name: foreach
- )
- )
- 2: Stmt_TraitUseAdaptation_Alias(
- trait: Name(
- parts: array(
- 0: TraitB
- )
- )
- method: Identifier(
- name: throw
- )
- newModifier: MODIFIER_PROTECTED (2)
- newName: Identifier(
- name: public
- )
- )
- 3: Stmt_TraitUseAdaptation_Alias(
- trait: Name(
- parts: array(
- 0: TraitB
- )
- )
- method: Identifier(
- name: self
- )
- newModifier: MODIFIER_PROTECTED (2)
- newName: null
- )
- 4: Stmt_TraitUseAdaptation_Alias(
- trait: null
- method: Identifier(
- name: exit
- )
- newModifier: null
- newName: Identifier(
- name: die
- )
- )
- 5: Stmt_TraitUseAdaptation_Alias(
- trait: Name_FullyQualified(
- parts: array(
- 0: TraitC
- )
- )
- method: Identifier(
- name: exit
- )
- newModifier: null
- newName: Identifier(
- name: bye
- )
- )
- 6: Stmt_TraitUseAdaptation_Alias(
- trait: Name_Relative(
- parts: array(
- 0: TraitC
- )
- )
- method: Identifier(
- name: exit
- )
- newModifier: null
- newName: Identifier(
- name: byebye
- )
- )
- 7: Stmt_TraitUseAdaptation_Precedence(
- trait: Name(
- parts: array(
- 0: TraitA
- )
- )
- method: Identifier(
- name: catch
- comments: array(
- 0: //
- 1: /** doc comment */
- 2: #
- )
- )
- insteadof: array(
- 0: Name(
- parts: array(
- 0: TraitB
- )
- )
- )
- )
- )
- )
- )
- )
- )
|