logic.test 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. Logical operators
  2. -----
  3. <?php
  4. // boolean ops
  5. $a && $b;
  6. $a || $b;
  7. !$a;
  8. !!$a;
  9. // logical ops
  10. $a and $b;
  11. $a or $b;
  12. $a xor $b;
  13. // precedence
  14. $a && $b || $c && $d;
  15. $a && ($b || $c) && $d;
  16. $a = $b || $c;
  17. $a = $b or $c;
  18. -----
  19. array(
  20. 0: Stmt_Expression(
  21. expr: Expr_BinaryOp_BooleanAnd(
  22. left: Expr_Variable(
  23. name: a
  24. comments: array(
  25. 0: // boolean ops
  26. )
  27. )
  28. right: Expr_Variable(
  29. name: b
  30. )
  31. comments: array(
  32. 0: // boolean ops
  33. )
  34. )
  35. comments: array(
  36. 0: // boolean ops
  37. )
  38. )
  39. 1: Stmt_Expression(
  40. expr: Expr_BinaryOp_BooleanOr(
  41. left: Expr_Variable(
  42. name: a
  43. )
  44. right: Expr_Variable(
  45. name: b
  46. )
  47. )
  48. )
  49. 2: Stmt_Expression(
  50. expr: Expr_BooleanNot(
  51. expr: Expr_Variable(
  52. name: a
  53. )
  54. )
  55. )
  56. 3: Stmt_Expression(
  57. expr: Expr_BooleanNot(
  58. expr: Expr_BooleanNot(
  59. expr: Expr_Variable(
  60. name: a
  61. )
  62. )
  63. )
  64. )
  65. 4: Stmt_Expression(
  66. expr: Expr_BinaryOp_LogicalAnd(
  67. left: Expr_Variable(
  68. name: a
  69. comments: array(
  70. 0: // logical ops
  71. )
  72. )
  73. right: Expr_Variable(
  74. name: b
  75. )
  76. comments: array(
  77. 0: // logical ops
  78. )
  79. )
  80. comments: array(
  81. 0: // logical ops
  82. )
  83. )
  84. 5: Stmt_Expression(
  85. expr: Expr_BinaryOp_LogicalOr(
  86. left: Expr_Variable(
  87. name: a
  88. )
  89. right: Expr_Variable(
  90. name: b
  91. )
  92. )
  93. )
  94. 6: Stmt_Expression(
  95. expr: Expr_BinaryOp_LogicalXor(
  96. left: Expr_Variable(
  97. name: a
  98. )
  99. right: Expr_Variable(
  100. name: b
  101. )
  102. )
  103. )
  104. 7: Stmt_Expression(
  105. expr: Expr_BinaryOp_BooleanOr(
  106. left: Expr_BinaryOp_BooleanAnd(
  107. left: Expr_Variable(
  108. name: a
  109. comments: array(
  110. 0: // precedence
  111. )
  112. )
  113. right: Expr_Variable(
  114. name: b
  115. )
  116. comments: array(
  117. 0: // precedence
  118. )
  119. )
  120. right: Expr_BinaryOp_BooleanAnd(
  121. left: Expr_Variable(
  122. name: c
  123. )
  124. right: Expr_Variable(
  125. name: d
  126. )
  127. )
  128. comments: array(
  129. 0: // precedence
  130. )
  131. )
  132. comments: array(
  133. 0: // precedence
  134. )
  135. )
  136. 8: Stmt_Expression(
  137. expr: Expr_BinaryOp_BooleanAnd(
  138. left: Expr_BinaryOp_BooleanAnd(
  139. left: Expr_Variable(
  140. name: a
  141. )
  142. right: Expr_BinaryOp_BooleanOr(
  143. left: Expr_Variable(
  144. name: b
  145. )
  146. right: Expr_Variable(
  147. name: c
  148. )
  149. )
  150. )
  151. right: Expr_Variable(
  152. name: d
  153. )
  154. )
  155. )
  156. 9: Stmt_Expression(
  157. expr: Expr_Assign(
  158. var: Expr_Variable(
  159. name: a
  160. )
  161. expr: Expr_BinaryOp_BooleanOr(
  162. left: Expr_Variable(
  163. name: b
  164. )
  165. right: Expr_Variable(
  166. name: c
  167. )
  168. )
  169. )
  170. )
  171. 10: Stmt_Expression(
  172. expr: Expr_BinaryOp_LogicalOr(
  173. left: Expr_Assign(
  174. var: Expr_Variable(
  175. name: a
  176. )
  177. expr: Expr_Variable(
  178. name: b
  179. )
  180. )
  181. right: Expr_Variable(
  182. name: c
  183. )
  184. )
  185. )
  186. )