logic.test 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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: Expr_BinaryOp_BooleanAnd(
  21. left: Expr_Variable(
  22. name: a
  23. comments: array(
  24. 0: // boolean ops
  25. )
  26. )
  27. right: Expr_Variable(
  28. name: b
  29. )
  30. comments: array(
  31. 0: // boolean ops
  32. )
  33. )
  34. 1: Expr_BinaryOp_BooleanOr(
  35. left: Expr_Variable(
  36. name: a
  37. )
  38. right: Expr_Variable(
  39. name: b
  40. )
  41. )
  42. 2: Expr_BooleanNot(
  43. expr: Expr_Variable(
  44. name: a
  45. )
  46. )
  47. 3: Expr_BooleanNot(
  48. expr: Expr_BooleanNot(
  49. expr: Expr_Variable(
  50. name: a
  51. )
  52. )
  53. )
  54. 4: Expr_BinaryOp_LogicalAnd(
  55. left: Expr_Variable(
  56. name: a
  57. comments: array(
  58. 0: // logical ops
  59. )
  60. )
  61. right: Expr_Variable(
  62. name: b
  63. )
  64. comments: array(
  65. 0: // logical ops
  66. )
  67. )
  68. 5: Expr_BinaryOp_LogicalOr(
  69. left: Expr_Variable(
  70. name: a
  71. )
  72. right: Expr_Variable(
  73. name: b
  74. )
  75. )
  76. 6: Expr_BinaryOp_LogicalXor(
  77. left: Expr_Variable(
  78. name: a
  79. )
  80. right: Expr_Variable(
  81. name: b
  82. )
  83. )
  84. 7: Expr_BinaryOp_BooleanOr(
  85. left: Expr_BinaryOp_BooleanAnd(
  86. left: Expr_Variable(
  87. name: a
  88. comments: array(
  89. 0: // precedence
  90. )
  91. )
  92. right: Expr_Variable(
  93. name: b
  94. )
  95. comments: array(
  96. 0: // precedence
  97. )
  98. )
  99. right: Expr_BinaryOp_BooleanAnd(
  100. left: Expr_Variable(
  101. name: c
  102. )
  103. right: Expr_Variable(
  104. name: d
  105. )
  106. )
  107. comments: array(
  108. 0: // precedence
  109. )
  110. )
  111. 8: Expr_BinaryOp_BooleanAnd(
  112. left: Expr_BinaryOp_BooleanAnd(
  113. left: Expr_Variable(
  114. name: a
  115. )
  116. right: Expr_BinaryOp_BooleanOr(
  117. left: Expr_Variable(
  118. name: b
  119. )
  120. right: Expr_Variable(
  121. name: c
  122. )
  123. )
  124. )
  125. right: Expr_Variable(
  126. name: d
  127. )
  128. )
  129. 9: Expr_Assign(
  130. var: Expr_Variable(
  131. name: a
  132. )
  133. expr: Expr_BinaryOp_BooleanOr(
  134. left: Expr_Variable(
  135. name: b
  136. )
  137. right: Expr_Variable(
  138. name: c
  139. )
  140. )
  141. )
  142. 10: Expr_BinaryOp_LogicalOr(
  143. left: Expr_Assign(
  144. var: Expr_Variable(
  145. name: a
  146. )
  147. expr: Expr_Variable(
  148. name: b
  149. )
  150. )
  151. right: Expr_Variable(
  152. name: c
  153. )
  154. )
  155. )