1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-04 02:07:59 +01:00
PHP-Parser/test/code/parser/expr/logic.test

190 lines
4.2 KiB
Plaintext
Raw Normal View History

2011-11-27 11:20:35 +01:00
Logical operators
-----
<?php
// boolean ops
$a && $b;
$a || $b;
!$a;
!!$a;
// logical ops
$a and $b;
$a or $b;
$a xor $b;
// precedence
$a && $b || $c && $d;
$a && ($b || $c) && $d;
$a = $b || $c;
$a = $b or $c;
-----
array(
2017-01-19 22:25:22 +01:00
0: Stmt_Expression(
expr: Expr_BinaryOp_BooleanAnd(
left: Expr_Variable(
name: a
comments: array(
0: // boolean ops
)
)
right: Expr_Variable(
name: b
)
comments: array(
0: // boolean ops
)
2011-11-27 11:20:35 +01:00
)
comments: array(
0: // boolean ops
)
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
1: Stmt_Expression(
expr: Expr_BinaryOp_BooleanOr(
left: Expr_Variable(
name: a
)
right: Expr_Variable(
name: b
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
2: Stmt_Expression(
2011-11-27 11:20:35 +01:00
expr: Expr_BooleanNot(
expr: Expr_Variable(
name: a
)
)
)
2017-01-19 22:25:22 +01:00
3: Stmt_Expression(
expr: Expr_BooleanNot(
expr: Expr_BooleanNot(
expr: Expr_Variable(
name: a
)
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
4: Stmt_Expression(
expr: Expr_BinaryOp_LogicalAnd(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
comments: array(
2017-01-19 22:25:22 +01:00
0: // logical ops
)
2011-11-27 11:20:35 +01:00
)
right: Expr_Variable(
name: b
)
comments: array(
2017-01-19 22:25:22 +01:00
0: // logical ops
)
2011-11-27 11:20:35 +01:00
)
2017-01-19 22:25:22 +01:00
comments: array(
0: // logical ops
)
)
5: Stmt_Expression(
expr: Expr_BinaryOp_LogicalOr(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
2017-01-19 22:25:22 +01:00
name: a
2011-11-27 11:20:35 +01:00
)
right: Expr_Variable(
2017-01-19 22:25:22 +01:00
name: b
2011-11-27 11:20:35 +01:00
)
)
)
2017-01-19 22:25:22 +01:00
6: Stmt_Expression(
expr: Expr_BinaryOp_LogicalXor(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: a
)
2017-01-19 22:25:22 +01:00
right: Expr_Variable(
name: b
)
)
)
7: Stmt_Expression(
expr: Expr_BinaryOp_BooleanOr(
left: Expr_BinaryOp_BooleanAnd(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
2017-01-19 22:25:22 +01:00
name: a
comments: array(
0: // precedence
)
2011-11-27 11:20:35 +01:00
)
right: Expr_Variable(
2017-01-19 22:25:22 +01:00
name: b
)
comments: array(
0: // precedence
)
)
right: Expr_BinaryOp_BooleanAnd(
left: Expr_Variable(
2011-11-27 11:20:35 +01:00
name: c
)
2017-01-19 22:25:22 +01:00
right: Expr_Variable(
name: d
)
)
comments: array(
0: // precedence
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
comments: array(
0: // precedence
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
8: Stmt_Expression(
expr: Expr_BinaryOp_BooleanAnd(
left: Expr_BinaryOp_BooleanAnd(
left: Expr_Variable(
name: a
)
right: Expr_BinaryOp_BooleanOr(
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
)
2011-11-27 11:20:35 +01:00
)
right: Expr_Variable(
2017-01-19 22:25:22 +01:00
name: d
2011-11-27 11:20:35 +01:00
)
)
)
2017-01-19 22:25:22 +01:00
9: Stmt_Expression(
expr: Expr_Assign(
2011-11-27 11:20:35 +01:00
var: Expr_Variable(
name: a
)
2017-01-19 22:25:22 +01:00
expr: Expr_BinaryOp_BooleanOr(
left: Expr_Variable(
name: b
)
right: Expr_Variable(
name: c
)
2011-11-27 11:20:35 +01:00
)
)
2017-01-19 22:25:22 +01:00
)
10: Stmt_Expression(
expr: Expr_BinaryOp_LogicalOr(
left: Expr_Assign(
var: Expr_Variable(
name: a
)
expr: Expr_Variable(
name: b
)
)
right: Expr_Variable(
name: c
)
2011-11-27 11:20:35 +01:00
)
)
)