anonymous.test 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. Anonymous classes
  2. -----
  3. <?php
  4. new class {
  5. public function test() {}
  6. };
  7. new class extends A implements B, C {};
  8. new class() {
  9. public $foo;
  10. };
  11. new class($a, $b) extends A {
  12. use T;
  13. };
  14. class A {
  15. public function test() {
  16. return new class($this) extends A {
  17. const A = 'B';
  18. };
  19. }
  20. }
  21. -----
  22. array(
  23. 0: Stmt_Expression(
  24. expr: Expr_New(
  25. class: Stmt_Class(
  26. attrGroups: array(
  27. )
  28. flags: 0
  29. name: null
  30. extends: null
  31. implements: array(
  32. )
  33. stmts: array(
  34. 0: Stmt_ClassMethod(
  35. attrGroups: array(
  36. )
  37. flags: PUBLIC (1)
  38. byRef: false
  39. name: Identifier(
  40. name: test
  41. )
  42. params: array(
  43. )
  44. returnType: null
  45. stmts: array(
  46. )
  47. )
  48. )
  49. )
  50. args: array(
  51. )
  52. )
  53. )
  54. 1: Stmt_Expression(
  55. expr: Expr_New(
  56. class: Stmt_Class(
  57. attrGroups: array(
  58. )
  59. flags: 0
  60. name: null
  61. extends: Name(
  62. name: A
  63. )
  64. implements: array(
  65. 0: Name(
  66. name: B
  67. )
  68. 1: Name(
  69. name: C
  70. )
  71. )
  72. stmts: array(
  73. )
  74. )
  75. args: array(
  76. )
  77. )
  78. )
  79. 2: Stmt_Expression(
  80. expr: Expr_New(
  81. class: Stmt_Class(
  82. attrGroups: array(
  83. )
  84. flags: 0
  85. name: null
  86. extends: null
  87. implements: array(
  88. )
  89. stmts: array(
  90. 0: Stmt_Property(
  91. attrGroups: array(
  92. )
  93. flags: PUBLIC (1)
  94. type: null
  95. props: array(
  96. 0: PropertyItem(
  97. name: VarLikeIdentifier(
  98. name: foo
  99. )
  100. default: null
  101. )
  102. )
  103. )
  104. )
  105. )
  106. args: array(
  107. )
  108. )
  109. )
  110. 3: Stmt_Expression(
  111. expr: Expr_New(
  112. class: Stmt_Class(
  113. attrGroups: array(
  114. )
  115. flags: 0
  116. name: null
  117. extends: Name(
  118. name: A
  119. )
  120. implements: array(
  121. )
  122. stmts: array(
  123. 0: Stmt_TraitUse(
  124. traits: array(
  125. 0: Name(
  126. name: T
  127. )
  128. )
  129. adaptations: array(
  130. )
  131. )
  132. )
  133. )
  134. args: array(
  135. 0: Arg(
  136. name: null
  137. value: Expr_Variable(
  138. name: a
  139. )
  140. byRef: false
  141. unpack: false
  142. )
  143. 1: Arg(
  144. name: null
  145. value: Expr_Variable(
  146. name: b
  147. )
  148. byRef: false
  149. unpack: false
  150. )
  151. )
  152. )
  153. )
  154. 4: Stmt_Class(
  155. attrGroups: array(
  156. )
  157. flags: 0
  158. name: Identifier(
  159. name: A
  160. )
  161. extends: null
  162. implements: array(
  163. )
  164. stmts: array(
  165. 0: Stmt_ClassMethod(
  166. attrGroups: array(
  167. )
  168. flags: PUBLIC (1)
  169. byRef: false
  170. name: Identifier(
  171. name: test
  172. )
  173. params: array(
  174. )
  175. returnType: null
  176. stmts: array(
  177. 0: Stmt_Return(
  178. expr: Expr_New(
  179. class: Stmt_Class(
  180. attrGroups: array(
  181. )
  182. flags: 0
  183. name: null
  184. extends: Name(
  185. name: A
  186. )
  187. implements: array(
  188. )
  189. stmts: array(
  190. 0: Stmt_ClassConst(
  191. attrGroups: array(
  192. )
  193. flags: 0
  194. type: null
  195. consts: array(
  196. 0: Const(
  197. name: Identifier(
  198. name: A
  199. )
  200. value: Scalar_String(
  201. value: B
  202. )
  203. )
  204. )
  205. )
  206. )
  207. )
  208. args: array(
  209. 0: Arg(
  210. name: null
  211. value: Expr_Variable(
  212. name: this
  213. )
  214. byRef: false
  215. unpack: false
  216. )
  217. )
  218. )
  219. )
  220. )
  221. )
  222. )
  223. )
  224. )