菜谱项目

anonymous.test 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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: Expr_New(
  24. class: Stmt_Class(
  25. flags: 0
  26. name: null
  27. extends: null
  28. implements: array(
  29. )
  30. stmts: array(
  31. 0: Stmt_ClassMethod(
  32. flags: MODIFIER_PUBLIC (1)
  33. byRef: false
  34. name: test
  35. params: array(
  36. )
  37. returnType: null
  38. stmts: array(
  39. )
  40. )
  41. )
  42. )
  43. args: array(
  44. )
  45. )
  46. 1: Expr_New(
  47. class: Stmt_Class(
  48. flags: 0
  49. name: null
  50. extends: Name(
  51. parts: array(
  52. 0: A
  53. )
  54. )
  55. implements: array(
  56. 0: Name(
  57. parts: array(
  58. 0: B
  59. )
  60. )
  61. 1: Name(
  62. parts: array(
  63. 0: C
  64. )
  65. )
  66. )
  67. stmts: array(
  68. )
  69. )
  70. args: array(
  71. )
  72. )
  73. 2: Expr_New(
  74. class: Stmt_Class(
  75. flags: 0
  76. name: null
  77. extends: null
  78. implements: array(
  79. )
  80. stmts: array(
  81. 0: Stmt_Property(
  82. flags: MODIFIER_PUBLIC (1)
  83. props: array(
  84. 0: Stmt_PropertyProperty(
  85. name: foo
  86. default: null
  87. )
  88. )
  89. )
  90. )
  91. )
  92. args: array(
  93. )
  94. )
  95. 3: Expr_New(
  96. class: Stmt_Class(
  97. flags: 0
  98. name: null
  99. extends: Name(
  100. parts: array(
  101. 0: A
  102. )
  103. )
  104. implements: array(
  105. )
  106. stmts: array(
  107. 0: Stmt_TraitUse(
  108. traits: array(
  109. 0: Name(
  110. parts: array(
  111. 0: T
  112. )
  113. )
  114. )
  115. adaptations: array(
  116. )
  117. )
  118. )
  119. )
  120. args: array(
  121. 0: Arg(
  122. value: Expr_Variable(
  123. name: a
  124. )
  125. byRef: false
  126. unpack: false
  127. )
  128. 1: Arg(
  129. value: Expr_Variable(
  130. name: b
  131. )
  132. byRef: false
  133. unpack: false
  134. )
  135. )
  136. )
  137. 4: Stmt_Class(
  138. flags: 0
  139. name: A
  140. extends: null
  141. implements: array(
  142. )
  143. stmts: array(
  144. 0: Stmt_ClassMethod(
  145. flags: MODIFIER_PUBLIC (1)
  146. byRef: false
  147. name: test
  148. params: array(
  149. )
  150. returnType: null
  151. stmts: array(
  152. 0: Stmt_Return(
  153. expr: Expr_New(
  154. class: Stmt_Class(
  155. flags: 0
  156. name: null
  157. extends: Name(
  158. parts: array(
  159. 0: A
  160. )
  161. )
  162. implements: array(
  163. )
  164. stmts: array(
  165. 0: Stmt_ClassConst(
  166. flags: 0
  167. consts: array(
  168. 0: Const(
  169. name: A
  170. value: Scalar_String(
  171. value: B
  172. )
  173. )
  174. )
  175. )
  176. )
  177. )
  178. args: array(
  179. 0: Arg(
  180. value: Expr_Variable(
  181. name: this
  182. )
  183. byRef: false
  184. unpack: false
  185. )
  186. )
  187. )
  188. )
  189. )
  190. )
  191. )
  192. )
  193. )