• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nette / latte / 20107372588

10 Dec 2025 05:19PM UTC coverage: 94.875% (-0.09%) from 94.966%
20107372588

push

github

dg
fixed operator ! priority

3 of 3 new or added lines in 1 file covered. (100.0%)

10 existing lines in 3 files now uncovered.

5517 of 5815 relevant lines covered (94.88%)

0.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.59
/src/Latte/Compiler/Nodes/Php/Expression/AssignOpNode.php
1
<?php
2

3
/**
4
 * This file is part of the Latte (https://latte.nette.org)
5
 * Copyright (c) 2008 David Grudl (https://davidgrudl.com)
6
 */
7

8
declare(strict_types=1);
9

10
namespace Latte\Compiler\Nodes\Php\Expression;
11

12
use Latte\CompileException;
13
use Latte\Compiler\Nodes\Php\ExpressionNode;
14
use Latte\Compiler\Nodes\Php\OperatorNode;
15
use Latte\Compiler\Position;
16
use Latte\Compiler\PrintContext;
17
use function in_array;
18

19

20
class AssignOpNode extends ExpressionNode implements OperatorNode
21
{
22
        private const Ops = ['+', '-', '*', '/', '.', '%', '&', '|', '^', '<<', '>>', '**', '??'];
23

24

25
        public function __construct(
1✔
26
                public ExpressionNode $var,
27
                public string $operator,
28
                public ExpressionNode $expr,
29
                public ?Position $position = null,
30
        ) {
31
                if (!in_array($this->operator, self::Ops, true)) {
1✔
32
                        throw new \InvalidArgumentException("Unexpected operator '$this->operator'");
×
33
                }
34
                $this->validate();
1✔
35
        }
1✔
36

37

38
        public function print(PrintContext $context): string
1✔
39
        {
40
                $this->validate();
1✔
41
                return $context->parenthesize($this, $this->var, self::AssocLeft)
1✔
42
                        . ' ' . $this->operator . '= '
1✔
43
                        . $context->parenthesize($this, $this->expr, self::AssocRight);
1✔
44
        }
45

46

47
        public function getOperatorPrecedence(): array
48
        {
49
                return self::AssignPrecedence;
1✔
50
        }
51

52

53
        public function validate(): void
54
        {
55
                if (!$this->var->isWritable()) {
1✔
UNCOV
56
                        throw new CompileException('Cannot write to the expression: ' . $this->var->print(new PrintContext), $this->var->position);
×
57
                }
58
        }
1✔
59

60

61
        public function &getIterator(): \Generator
×
62
        {
UNCOV
63
                yield $this->var;
×
UNCOV
64
                yield $this->expr;
×
65
        }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc