newInInitializer.test 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. New in initializers
  2. -----
  3. <?php
  4. const C = new Foo;
  5. function a($x = new Foo) {
  6. static $y = new Foo;
  7. }
  8. #[Attr(new Foo)]
  9. class Bar {
  10. const C = new Foo;
  11. public $prop = new Foo;
  12. }
  13. -----
  14. !!php7
  15. array(
  16. 0: Stmt_Const(
  17. consts: array(
  18. 0: Const(
  19. name: Identifier(
  20. name: C
  21. )
  22. value: Expr_New(
  23. class: Name(
  24. parts: array(
  25. 0: Foo
  26. )
  27. )
  28. args: array(
  29. )
  30. )
  31. )
  32. )
  33. )
  34. 1: Stmt_Function(
  35. attrGroups: array(
  36. )
  37. byRef: false
  38. name: Identifier(
  39. name: a
  40. )
  41. params: array(
  42. 0: Param(
  43. attrGroups: array(
  44. )
  45. flags: 0
  46. type: null
  47. byRef: false
  48. variadic: false
  49. var: Expr_Variable(
  50. name: x
  51. )
  52. default: Expr_New(
  53. class: Name(
  54. parts: array(
  55. 0: Foo
  56. )
  57. )
  58. args: array(
  59. )
  60. )
  61. )
  62. )
  63. returnType: null
  64. stmts: array(
  65. 0: Stmt_Static(
  66. vars: array(
  67. 0: Stmt_StaticVar(
  68. var: Expr_Variable(
  69. name: y
  70. )
  71. default: Expr_New(
  72. class: Name(
  73. parts: array(
  74. 0: Foo
  75. )
  76. )
  77. args: array(
  78. )
  79. )
  80. )
  81. )
  82. )
  83. )
  84. )
  85. 2: Stmt_Class(
  86. attrGroups: array(
  87. 0: AttributeGroup(
  88. attrs: array(
  89. 0: Attribute(
  90. name: Name(
  91. parts: array(
  92. 0: Attr
  93. )
  94. )
  95. args: array(
  96. 0: Arg(
  97. name: null
  98. value: Expr_New(
  99. class: Name(
  100. parts: array(
  101. 0: Foo
  102. )
  103. )
  104. args: array(
  105. )
  106. )
  107. byRef: false
  108. unpack: false
  109. )
  110. )
  111. )
  112. )
  113. )
  114. )
  115. flags: 0
  116. name: Identifier(
  117. name: Bar
  118. )
  119. extends: null
  120. implements: array(
  121. )
  122. stmts: array(
  123. 0: Stmt_ClassConst(
  124. attrGroups: array(
  125. )
  126. flags: 0
  127. type: null
  128. consts: array(
  129. 0: Const(
  130. name: Identifier(
  131. name: C
  132. )
  133. value: Expr_New(
  134. class: Name(
  135. parts: array(
  136. 0: Foo
  137. )
  138. )
  139. args: array(
  140. )
  141. )
  142. )
  143. )
  144. )
  145. 1: Stmt_Property(
  146. attrGroups: array(
  147. )
  148. flags: MODIFIER_PUBLIC (1)
  149. type: null
  150. props: array(
  151. 0: Stmt_PropertyProperty(
  152. name: VarLikeIdentifier(
  153. name: prop
  154. )
  155. default: Expr_New(
  156. class: Name(
  157. parts: array(
  158. 0: Foo
  159. )
  160. )
  161. args: array(
  162. )
  163. )
  164. )
  165. )
  166. )
  167. )
  168. )
  169. )