Conditions | 2 |
Paths | 2 |
Total Lines | 23 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
1 | <?php |
||
16 | public function fix(NodeSearch $nodeSearch): bool |
||
17 | { |
||
18 | $found = false; |
||
19 | |||
20 | /** @var Node\Expr\BinaryOp\Spaceship $node */ |
||
21 | foreach ($nodeSearch->eachType(Node\Expr\BinaryOp\Spaceship::class) as $node) { |
||
22 | $found = true; |
||
23 | |||
24 | $newNode = new Node\Expr\Ternary( |
||
25 | new Node\Expr\BinaryOp\Smaller($node->left, $node->right), |
||
26 | new Node\Scalar\LNumber(-1), |
||
27 | new Node\Expr\Ternary( |
||
28 | new Node\Expr\BinaryOp\Equal($node->left, $node->right), |
||
29 | new Node\Scalar\LNumber(0), |
||
30 | new Node\Scalar\LNumber(1) |
||
31 | ) |
||
32 | ); |
||
33 | |||
34 | $nodeSearch->replaceNode($node, $newNode); |
||
35 | } |
||
36 | |||
37 | return $found; |
||
38 | } |
||
39 | } |
||
40 |