|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace PHPSA\Compiler\Expression\BinaryOp; |
|
4
|
|
|
|
|
5
|
|
|
use PHPSA\CompiledExpression; |
|
6
|
|
|
use PHPSA\Context; |
|
7
|
|
|
use PHPSA\Compiler\Expression; |
|
8
|
|
|
use PHPSA\Compiler\Expression\AbstractExpressionCompiler; |
|
9
|
|
|
|
|
10
|
|
|
class NotIdentical extends AbstractExpressionCompiler |
|
11
|
|
|
{ |
|
12
|
|
|
protected $name = 'PhpParser\Node\Expr\BinaryOp\NotIdentical'; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* It's used in conditions |
|
16
|
|
|
* {left-expr} !== {right-expr} |
|
17
|
|
|
* |
|
18
|
|
|
* @param \PhpParser\Node\Expr\BinaryOp\NotIdentical $expr |
|
19
|
|
|
* @param Context $context |
|
20
|
|
|
* @return CompiledExpression |
|
21
|
|
|
*/ |
|
22
|
14 |
|
protected function compile($expr, Context $context) |
|
23
|
|
|
{ |
|
24
|
14 |
|
$left = $context->getExpressionCompiler()->compile($expr->left); |
|
25
|
14 |
|
$right = $context->getExpressionCompiler()->compile($expr->right); |
|
26
|
|
|
|
|
27
|
14 |
|
switch ($left->getType()) { |
|
28
|
14 |
|
case CompiledExpression::INTEGER: |
|
29
|
14 |
|
case CompiledExpression::DOUBLE: |
|
30
|
14 |
|
case CompiledExpression::BOOLEAN: |
|
31
|
14 |
|
case CompiledExpression::NUMBER: |
|
32
|
14 |
|
case CompiledExpression::NULL: |
|
33
|
13 |
|
switch ($right->getType()) { |
|
34
|
13 |
|
case CompiledExpression::INTEGER: |
|
35
|
13 |
|
case CompiledExpression::DOUBLE: |
|
36
|
13 |
|
case CompiledExpression::BOOLEAN: |
|
37
|
13 |
|
case CompiledExpression::NUMBER: |
|
38
|
13 |
|
case CompiledExpression::NULL: |
|
39
|
12 |
|
return new CompiledExpression(CompiledExpression::BOOLEAN, $left->getValue() !== $right->getValue()); |
|
40
|
1 |
|
} |
|
41
|
2 |
|
} |
|
42
|
|
|
|
|
43
|
2 |
|
return new CompiledExpression(CompiledExpression::BOOLEAN); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|