Skip to content

Commit 64d945d

Browse files
committed
fixed operator ! priority
1 parent 074f9fa commit 64d945d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Latte/Compiler/Nodes/Php/Expression/UnaryOpNode.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ public function print(PrintContext $context): string
4040

4141
public function getOperatorPrecedence(): array
4242
{
43-
return [240, self::AssocRight];
43+
return match ($this->operator) {
44+
'+', '-', '~', '@' => [240, self::AssocRight],
45+
'!' => [220, self::AssocRight],
46+
};
4447
}
4548

4649

tests/phpPrint/operators.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ $test = <<<'XX'
7676
$a or $b,
7777
7878
$a instanceof Foo,
79+
!$a instanceof Foo,
7980
$a instanceof $b,
8081
8182
$a in $b,
@@ -157,6 +158,7 @@ $a and $b,
157158
$a xor $b,
158159
$a or $b,
159160
$a instanceof Foo,
161+
!$a instanceof Foo,
160162
$a instanceof $b,
161163
in_array($a, $b, true),
162164
$a |> $b |> $c,

0 commit comments

Comments
 (0)