assign.test 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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. $a **= $b;
  19. // chained assign
  20. $a = $b *= $c **= $d;
  21. // by ref assign
  22. $a =& $b;
  23. // list() assign
  24. list($a) = $b;
  25. list($a, , $b) = $c;
  26. list($a, list(, $c), $d) = $e;
  27. // inc/dec
  28. ++$a;
  29. $a++;
  30. --$a;
  31. $a--;
  32. -----
  33. array(
  34. 0: Expr_Assign(
  35. var: Expr_Variable(
  36. name: a
  37. comments: array(
  38. 0: // simple assign
  39. )
  40. )
  41. expr: Expr_Variable(
  42. name: b
  43. )
  44. comments: array(
  45. 0: // simple assign
  46. )
  47. )
  48. 1: Expr_AssignOp_BitwiseAnd(
  49. var: Expr_Variable(
  50. name: a
  51. comments: array(
  52. 0: // combined assign
  53. )
  54. )
  55. expr: Expr_Variable(
  56. name: b
  57. )
  58. comments: array(
  59. 0: // combined assign
  60. )
  61. )
  62. 2: Expr_AssignOp_BitwiseOr(
  63. var: Expr_Variable(
  64. name: a
  65. )
  66. expr: Expr_Variable(
  67. name: b
  68. )
  69. )
  70. 3: Expr_AssignOp_BitwiseXor(
  71. var: Expr_Variable(
  72. name: a
  73. )
  74. expr: Expr_Variable(
  75. name: b
  76. )
  77. )
  78. 4: Expr_AssignOp_Concat(
  79. var: Expr_Variable(
  80. name: a
  81. )
  82. expr: Expr_Variable(
  83. name: b
  84. )
  85. )
  86. 5: Expr_AssignOp_Div(
  87. var: Expr_Variable(
  88. name: a
  89. )
  90. expr: Expr_Variable(
  91. name: b
  92. )
  93. )
  94. 6: Expr_AssignOp_Minus(
  95. var: Expr_Variable(
  96. name: a
  97. )
  98. expr: Expr_Variable(
  99. name: b
  100. )
  101. )
  102. 7: Expr_AssignOp_Mod(
  103. var: Expr_Variable(
  104. name: a
  105. )
  106. expr: Expr_Variable(
  107. name: b
  108. )
  109. )
  110. 8: Expr_AssignOp_Mul(
  111. var: Expr_Variable(
  112. name: a
  113. )
  114. expr: Expr_Variable(
  115. name: b
  116. )
  117. )
  118. 9: Expr_AssignOp_Plus(
  119. var: Expr_Variable(
  120. name: a
  121. )
  122. expr: Expr_Variable(
  123. name: b
  124. )
  125. )
  126. 10: Expr_AssignOp_ShiftLeft(
  127. var: Expr_Variable(
  128. name: a
  129. )
  130. expr: Expr_Variable(
  131. name: b
  132. )
  133. )
  134. 11: Expr_AssignOp_ShiftRight(
  135. var: Expr_Variable(
  136. name: a
  137. )
  138. expr: Expr_Variable(
  139. name: b
  140. )
  141. )
  142. 12: Expr_AssignOp_Pow(
  143. var: Expr_Variable(
  144. name: a
  145. )
  146. expr: Expr_Variable(
  147. name: b
  148. )
  149. )
  150. 13: Expr_Assign(
  151. var: Expr_Variable(
  152. name: a
  153. comments: array(
  154. 0: // chained assign
  155. )
  156. )
  157. expr: Expr_AssignOp_Mul(
  158. var: Expr_Variable(
  159. name: b
  160. )
  161. expr: Expr_AssignOp_Pow(
  162. var: Expr_Variable(
  163. name: c
  164. )
  165. expr: Expr_Variable(
  166. name: d
  167. )
  168. )
  169. )
  170. comments: array(
  171. 0: // chained assign
  172. )
  173. )
  174. 14: Expr_AssignRef(
  175. var: Expr_Variable(
  176. name: a
  177. comments: array(
  178. 0: // by ref assign
  179. )
  180. )
  181. expr: Expr_Variable(
  182. name: b
  183. )
  184. comments: array(
  185. 0: // by ref assign
  186. )
  187. )
  188. 15: Expr_Assign(
  189. var: Expr_List(
  190. items: array(
  191. 0: Expr_ArrayItem(
  192. key: null
  193. value: Expr_Variable(
  194. name: a
  195. )
  196. byRef: false
  197. )
  198. )
  199. comments: array(
  200. 0: // list() assign
  201. )
  202. )
  203. expr: Expr_Variable(
  204. name: b
  205. )
  206. comments: array(
  207. 0: // list() assign
  208. )
  209. )
  210. 16: Expr_Assign(
  211. var: Expr_List(
  212. items: array(
  213. 0: Expr_ArrayItem(
  214. key: null
  215. value: Expr_Variable(
  216. name: a
  217. )
  218. byRef: false
  219. )
  220. 1: null
  221. 2: Expr_ArrayItem(
  222. key: null
  223. value: Expr_Variable(
  224. name: b
  225. )
  226. byRef: false
  227. )
  228. )
  229. )
  230. expr: Expr_Variable(
  231. name: c
  232. )
  233. )
  234. 17: Expr_Assign(
  235. var: Expr_List(
  236. items: array(
  237. 0: Expr_ArrayItem(
  238. key: null
  239. value: Expr_Variable(
  240. name: a
  241. )
  242. byRef: false
  243. )
  244. 1: Expr_ArrayItem(
  245. key: null
  246. value: Expr_List(
  247. items: array(
  248. 0: null
  249. 1: Expr_ArrayItem(
  250. key: null
  251. value: Expr_Variable(
  252. name: c
  253. )
  254. byRef: false
  255. )
  256. )
  257. )
  258. byRef: false
  259. )
  260. 2: Expr_ArrayItem(
  261. key: null
  262. value: Expr_Variable(
  263. name: d
  264. )
  265. byRef: false
  266. )
  267. )
  268. )
  269. expr: Expr_Variable(
  270. name: e
  271. )
  272. )
  273. 18: Expr_PreInc(
  274. var: Expr_Variable(
  275. name: a
  276. )
  277. comments: array(
  278. 0: // inc/dec
  279. )
  280. )
  281. 19: Expr_PostInc(
  282. var: Expr_Variable(
  283. name: a
  284. )
  285. )
  286. 20: Expr_PreDec(
  287. var: Expr_Variable(
  288. name: a
  289. )
  290. )
  291. 21: Expr_PostDec(
  292. var: Expr_Variable(
  293. name: a
  294. )
  295. )
  296. )