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

nette / latte / 22359082277

24 Feb 2026 04:03PM UTC coverage: 93.959% (+0.05%) from 93.907%
22359082277

push

github

dg
fixed operator ! priority

5273 of 5612 relevant lines covered (93.96%)

0.94 hits per line

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

97.5
/src/Latte/Compiler/Nodes/Php/ModifierNode.php
1
<?php declare(strict_types=1);
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
namespace Latte\Compiler\Nodes\Php;
9

10
use Latte\Compiler\Node;
11
use Latte\Compiler\Position;
12
use Latte\Compiler\PrintContext;
13
use Latte\Helpers;
14

15

16
class ModifierNode extends Node
17
{
18
        /** @deprecated */
19
        public bool $check = true;
20

21

22
        public function __construct(
1✔
23
                /** @var FilterNode[] */
24
                public array $filters,
25
                public bool $escape = false,
26
                public ?Position $position = null,
27
        ) {
28
                (function (FilterNode ...$args) {})(...$filters);
1✔
29
        }
1✔
30

31

32
        public function hasFilter(string $name): bool
1✔
33
        {
34
                foreach ($this->filters as $filter) {
1✔
35
                        if ($filter->name->name === $name) {
1✔
36
                                return true;
1✔
37
                        }
38
                }
39

40
                return false;
1✔
41
        }
42

43

44
        public function removeFilter(string $name): ?FilterNode
1✔
45
        {
46
                foreach ($this->filters as $i => $filter) {
1✔
47
                        if ($filter->name->name === $name) {
1✔
48
                                return array_splice($this->filters, $i, 1)[0];
1✔
49
                        }
50
                }
51

52
                return null;
1✔
53
        }
54

55

56
        public function print(PrintContext $context): string
57
        {
58
                throw new \LogicException('Cannot directly print ModifierNode');
×
59
        }
60

61

62
        public function printSimple(PrintContext $context, string $expr): string
1✔
63
        {
64
                $escape = $this->escape;
1✔
65
                foreach ($this->filters as $filter) {
1✔
66
                        $name = $filter->name->name;
1✔
67
                        if ($name === 'noescape') {
1✔
68
                                $escape = false;
1✔
69
                        } else {
70
                                $expr = $filter->printSimple($context, $expr);
1✔
71
                        }
72
                }
73

74
                $escaper = $context->getEscaper();
1✔
75
                return $escape
1✔
76
                        ? $escaper->escape($expr)
1✔
77
                        : $escaper->escapeMandatory($expr);
1✔
78
        }
79

80

81
        public function printContentAware(PrintContext $context, string $expr): string
1✔
82
        {
83
                $escape = $this->escape;
1✔
84
                foreach ($this->filters as $filter) {
1✔
85
                        $name = $filter->name->name;
1✔
86
                        if ($name === 'noescape') {
1✔
87
                                $escape = false;
1✔
88
                        } else {
89
                                $expr = $filter->printContentAware($context, $expr);
1✔
90
                        }
91
                }
92

93
                return $escape
1✔
94
                        ? $context->getEscaper()->escapeContent($expr)
1✔
95
                        : $expr;
1✔
96
        }
97

98

99
        public function &getIterator(): \Generator
1✔
100
        {
101
                foreach ($this->filters as &$filter) {
1✔
102
                        yield $filter;
1✔
103
                }
104
                Helpers::removeNulls($this->filters);
1✔
105
        }
1✔
106
}
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