new.test 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. New
  2. -----
  3. <?php
  4. new A;
  5. new A($b);
  6. // class name variations
  7. new $a();
  8. new $a['b']();
  9. new A::$b();
  10. // DNCR object access
  11. new $a->b();
  12. new $a->b->c();
  13. new $a->b['c']();
  14. new $a->b{'c'}();
  15. // test regression introduces by new dereferencing syntax
  16. (new A);
  17. -----
  18. array(
  19. 0: Stmt_Expression(
  20. expr: Expr_New(
  21. class: Name(
  22. parts: array(
  23. 0: A
  24. )
  25. )
  26. args: array(
  27. )
  28. )
  29. )
  30. 1: Stmt_Expression(
  31. expr: Expr_New(
  32. class: Name(
  33. parts: array(
  34. 0: A
  35. )
  36. )
  37. args: array(
  38. 0: Arg(
  39. name: null
  40. value: Expr_Variable(
  41. name: b
  42. )
  43. byRef: false
  44. unpack: false
  45. )
  46. )
  47. )
  48. )
  49. 2: Stmt_Expression(
  50. expr: Expr_New(
  51. class: Expr_Variable(
  52. name: a
  53. )
  54. args: array(
  55. )
  56. comments: array(
  57. 0: // class name variations
  58. )
  59. )
  60. comments: array(
  61. 0: // class name variations
  62. )
  63. )
  64. 3: Stmt_Expression(
  65. expr: Expr_New(
  66. class: Expr_ArrayDimFetch(
  67. var: Expr_Variable(
  68. name: a
  69. )
  70. dim: Scalar_String(
  71. value: b
  72. )
  73. )
  74. args: array(
  75. )
  76. )
  77. )
  78. 4: Stmt_Expression(
  79. expr: Expr_New(
  80. class: Expr_StaticPropertyFetch(
  81. class: Name(
  82. parts: array(
  83. 0: A
  84. )
  85. )
  86. name: VarLikeIdentifier(
  87. name: b
  88. )
  89. )
  90. args: array(
  91. )
  92. )
  93. )
  94. 5: Stmt_Expression(
  95. expr: Expr_New(
  96. class: Expr_PropertyFetch(
  97. var: Expr_Variable(
  98. name: a
  99. )
  100. name: Identifier(
  101. name: b
  102. )
  103. )
  104. args: array(
  105. )
  106. comments: array(
  107. 0: // DNCR object access
  108. )
  109. )
  110. comments: array(
  111. 0: // DNCR object access
  112. )
  113. )
  114. 6: Stmt_Expression(
  115. expr: Expr_New(
  116. class: Expr_PropertyFetch(
  117. var: Expr_PropertyFetch(
  118. var: Expr_Variable(
  119. name: a
  120. )
  121. name: Identifier(
  122. name: b
  123. )
  124. )
  125. name: Identifier(
  126. name: c
  127. )
  128. )
  129. args: array(
  130. )
  131. )
  132. )
  133. 7: Stmt_Expression(
  134. expr: Expr_New(
  135. class: Expr_ArrayDimFetch(
  136. var: Expr_PropertyFetch(
  137. var: Expr_Variable(
  138. name: a
  139. )
  140. name: Identifier(
  141. name: b
  142. )
  143. )
  144. dim: Scalar_String(
  145. value: c
  146. )
  147. )
  148. args: array(
  149. )
  150. )
  151. )
  152. 8: Stmt_Expression(
  153. expr: Expr_New(
  154. class: Expr_ArrayDimFetch(
  155. var: Expr_PropertyFetch(
  156. var: Expr_Variable(
  157. name: a
  158. )
  159. name: Identifier(
  160. name: b
  161. )
  162. )
  163. dim: Scalar_String(
  164. value: c
  165. )
  166. )
  167. args: array(
  168. )
  169. )
  170. )
  171. 9: Stmt_Expression(
  172. expr: Expr_New(
  173. class: Name(
  174. parts: array(
  175. 0: A
  176. )
  177. )
  178. args: array(
  179. )
  180. )
  181. comments: array(
  182. 0: // test regression introduces by new dereferencing syntax
  183. )
  184. )
  185. )