logic.test 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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_BooleanAnd(
  21. left: Expr_Variable(
  22. name: a
  23. )
  24. right: Expr_Variable(
  25. name: b
  26. )
  27. )
  28. 1: Expr_BooleanOr(
  29. left: Expr_Variable(
  30. name: a
  31. )
  32. right: Expr_Variable(
  33. name: b
  34. )
  35. )
  36. 2: Expr_BooleanNot(
  37. expr: Expr_Variable(
  38. name: a
  39. )
  40. )
  41. 3: Expr_BooleanNot(
  42. expr: Expr_BooleanNot(
  43. expr: Expr_Variable(
  44. name: a
  45. )
  46. )
  47. )
  48. 4: Expr_LogicalAnd(
  49. left: Expr_Variable(
  50. name: a
  51. )
  52. right: Expr_Variable(
  53. name: b
  54. )
  55. )
  56. 5: Expr_LogicalOr(
  57. left: Expr_Variable(
  58. name: a
  59. )
  60. right: Expr_Variable(
  61. name: b
  62. )
  63. )
  64. 6: Expr_LogicalXor(
  65. left: Expr_Variable(
  66. name: a
  67. )
  68. right: Expr_Variable(
  69. name: b
  70. )
  71. )
  72. 7: Expr_BooleanOr(
  73. left: Expr_BooleanAnd(
  74. left: Expr_Variable(
  75. name: a
  76. )
  77. right: Expr_Variable(
  78. name: b
  79. )
  80. )
  81. right: Expr_BooleanAnd(
  82. left: Expr_Variable(
  83. name: c
  84. )
  85. right: Expr_Variable(
  86. name: d
  87. )
  88. )
  89. )
  90. 8: Expr_BooleanAnd(
  91. left: Expr_BooleanAnd(
  92. left: Expr_Variable(
  93. name: a
  94. )
  95. right: Expr_BooleanOr(
  96. left: Expr_Variable(
  97. name: b
  98. )
  99. right: Expr_Variable(
  100. name: c
  101. )
  102. )
  103. )
  104. right: Expr_Variable(
  105. name: d
  106. )
  107. )
  108. 9: Expr_Assign(
  109. var: Expr_Variable(
  110. name: a
  111. )
  112. expr: Expr_BooleanOr(
  113. left: Expr_Variable(
  114. name: b
  115. )
  116. right: Expr_Variable(
  117. name: c
  118. )
  119. )
  120. )
  121. 10: Expr_LogicalOr(
  122. left: Expr_Assign(
  123. var: Expr_Variable(
  124. name: a
  125. )
  126. expr: Expr_Variable(
  127. name: b
  128. )
  129. )
  130. right: Expr_Variable(
  131. name: c
  132. )
  133. )
  134. )