assign.test 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. Assignments
  2. -----
  3. <?php
  4. // simple assign
  5. $a = $b;
  6. // combined assign
  7. $a &= $b;
  8. $a |= $b;
  9. $a ^= $b;
  10. $a .= $b;
  11. $a /= $b;
  12. $a -= $b;
  13. $a %= $b;
  14. $a *= $b;
  15. $a += $b;
  16. $a <<= $b;
  17. $a >>= $b;
  18. // by ref assign
  19. $a =& $b;
  20. $a =& new B;
  21. // list() assign
  22. list($a) = $b;
  23. list($a, , $b) = $c;
  24. list($a, list(, $c), $d) = $e;
  25. // inc/dec
  26. ++$a;
  27. $a++;
  28. --$a;
  29. $a--;
  30. -----
  31. array(
  32. 0: Expr_Assign(
  33. var: Expr_Variable(
  34. name: a
  35. )
  36. expr: Expr_Variable(
  37. name: b
  38. )
  39. )
  40. 1: Expr_AssignBitwiseAnd(
  41. var: Expr_Variable(
  42. name: a
  43. )
  44. expr: Expr_Variable(
  45. name: b
  46. )
  47. )
  48. 2: Expr_AssignBitwiseOr(
  49. var: Expr_Variable(
  50. name: a
  51. )
  52. expr: Expr_Variable(
  53. name: b
  54. )
  55. )
  56. 3: Expr_AssignBitwiseXor(
  57. var: Expr_Variable(
  58. name: a
  59. )
  60. expr: Expr_Variable(
  61. name: b
  62. )
  63. )
  64. 4: Expr_AssignConcat(
  65. var: Expr_Variable(
  66. name: a
  67. )
  68. expr: Expr_Variable(
  69. name: b
  70. )
  71. )
  72. 5: Expr_AssignDiv(
  73. var: Expr_Variable(
  74. name: a
  75. )
  76. expr: Expr_Variable(
  77. name: b
  78. )
  79. )
  80. 6: Expr_AssignMinus(
  81. var: Expr_Variable(
  82. name: a
  83. )
  84. expr: Expr_Variable(
  85. name: b
  86. )
  87. )
  88. 7: Expr_AssignMod(
  89. var: Expr_Variable(
  90. name: a
  91. )
  92. expr: Expr_Variable(
  93. name: b
  94. )
  95. )
  96. 8: Expr_AssignMul(
  97. var: Expr_Variable(
  98. name: a
  99. )
  100. expr: Expr_Variable(
  101. name: b
  102. )
  103. )
  104. 9: Expr_AssignPlus(
  105. var: Expr_Variable(
  106. name: a
  107. )
  108. expr: Expr_Variable(
  109. name: b
  110. )
  111. )
  112. 10: Expr_AssignShiftLeft(
  113. var: Expr_Variable(
  114. name: a
  115. )
  116. expr: Expr_Variable(
  117. name: b
  118. )
  119. )
  120. 11: Expr_AssignShiftRight(
  121. var: Expr_Variable(
  122. name: a
  123. )
  124. expr: Expr_Variable(
  125. name: b
  126. )
  127. )
  128. 12: Expr_AssignRef(
  129. var: Expr_Variable(
  130. name: a
  131. )
  132. expr: Expr_Variable(
  133. name: b
  134. )
  135. )
  136. 13: Expr_AssignRef(
  137. var: Expr_Variable(
  138. name: a
  139. )
  140. expr: Expr_New(
  141. class: Name(
  142. parts: array(
  143. 0: B
  144. )
  145. )
  146. args: array(
  147. )
  148. )
  149. )
  150. 14: Expr_Assign(
  151. var: Expr_List(
  152. vars: array(
  153. 0: Expr_Variable(
  154. name: a
  155. )
  156. )
  157. )
  158. expr: Expr_Variable(
  159. name: b
  160. )
  161. )
  162. 15: Expr_Assign(
  163. var: Expr_List(
  164. vars: array(
  165. 0: Expr_Variable(
  166. name: a
  167. )
  168. 1: null
  169. 2: Expr_Variable(
  170. name: b
  171. )
  172. )
  173. )
  174. expr: Expr_Variable(
  175. name: c
  176. )
  177. )
  178. 16: Expr_Assign(
  179. var: Expr_List(
  180. vars: array(
  181. 0: Expr_Variable(
  182. name: a
  183. )
  184. 1: Expr_List(
  185. vars: array(
  186. 0: null
  187. 1: Expr_Variable(
  188. name: c
  189. )
  190. )
  191. )
  192. 2: Expr_Variable(
  193. name: d
  194. )
  195. )
  196. )
  197. expr: Expr_Variable(
  198. name: e
  199. )
  200. )
  201. 17: Expr_PreInc(
  202. var: Expr_Variable(
  203. name: a
  204. )
  205. )
  206. 18: Expr_PostInc(
  207. var: Expr_Variable(
  208. name: a
  209. )
  210. )
  211. 19: Expr_PreDec(
  212. var: Expr_Variable(
  213. name: a
  214. )
  215. )
  216. 20: Expr_PostDec(
  217. var: Expr_Variable(
  218. name: a
  219. )
  220. )
  221. )