anonymous.test 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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: MODIFIER_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. parts: array(
  63. 0: A
  64. )
  65. )
  66. implements: array(
  67. 0: Name(
  68. parts: array(
  69. 0: B
  70. )
  71. )
  72. 1: Name(
  73. parts: array(
  74. 0: C
  75. )
  76. )
  77. )
  78. stmts: array(
  79. )
  80. )
  81. args: array(
  82. )
  83. )
  84. )
  85. 2: Stmt_Expression(
  86. expr: Expr_New(
  87. class: Stmt_Class(
  88. attrGroups: array(
  89. )
  90. flags: 0
  91. name: null
  92. extends: null
  93. implements: array(
  94. )
  95. stmts: array(
  96. 0: Stmt_Property(
  97. attrGroups: array(
  98. )
  99. flags: MODIFIER_PUBLIC (1)
  100. type: null
  101. props: array(
  102. 0: Stmt_PropertyProperty(
  103. name: VarLikeIdentifier(
  104. name: foo
  105. )
  106. default: null
  107. )
  108. )
  109. )
  110. )
  111. )
  112. args: array(
  113. )
  114. )
  115. )
  116. 3: Stmt_Expression(
  117. expr: Expr_New(
  118. class: Stmt_Class(
  119. attrGroups: array(
  120. )
  121. flags: 0
  122. name: null
  123. extends: Name(
  124. parts: array(
  125. 0: A
  126. )
  127. )
  128. implements: array(
  129. )
  130. stmts: array(
  131. 0: Stmt_TraitUse(
  132. traits: array(
  133. 0: Name(
  134. parts: array(
  135. 0: T
  136. )
  137. )
  138. )
  139. adaptations: array(
  140. )
  141. )
  142. )
  143. )
  144. args: array(
  145. 0: Arg(
  146. name: null
  147. value: Expr_Variable(
  148. name: a
  149. )
  150. byRef: false
  151. unpack: false
  152. )
  153. 1: Arg(
  154. name: null
  155. value: Expr_Variable(
  156. name: b
  157. )
  158. byRef: false
  159. unpack: false
  160. )
  161. )
  162. )
  163. )
  164. 4: Stmt_Class(
  165. attrGroups: array(
  166. )
  167. flags: 0
  168. name: Identifier(
  169. name: A
  170. )
  171. extends: null
  172. implements: array(
  173. )
  174. stmts: array(
  175. 0: Stmt_ClassMethod(
  176. attrGroups: array(
  177. )
  178. flags: MODIFIER_PUBLIC (1)
  179. byRef: false
  180. name: Identifier(
  181. name: test
  182. )
  183. params: array(
  184. )
  185. returnType: null
  186. stmts: array(
  187. 0: Stmt_Return(
  188. expr: Expr_New(
  189. class: Stmt_Class(
  190. attrGroups: array(
  191. )
  192. flags: 0
  193. name: null
  194. extends: Name(
  195. parts: array(
  196. 0: A
  197. )
  198. )
  199. implements: array(
  200. )
  201. stmts: array(
  202. 0: Stmt_ClassConst(
  203. attrGroups: array(
  204. )
  205. flags: 0
  206. type: null
  207. consts: array(
  208. 0: Const(
  209. name: Identifier(
  210. name: A
  211. )
  212. value: Scalar_String(
  213. value: B
  214. )
  215. )
  216. )
  217. )
  218. )
  219. )
  220. args: array(
  221. 0: Arg(
  222. name: null
  223. value: Expr_Variable(
  224. name: this
  225. )
  226. byRef: false
  227. unpack: false
  228. )
  229. )
  230. )
  231. )
  232. )
  233. )
  234. )
  235. )
  236. )