assign.test 8.4 KB

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