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

nette / latte / 19616305908

23 Nov 2025 07:01PM UTC coverage: 93.946% (+0.03%) from 93.916%
19616305908

push

github

dg
removed comment /*readonly*/

5261 of 5600 relevant lines covered (93.95%)

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
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;
11

12
use Latte\Compiler\Node;
13
use Latte\Compiler\Position;
14
use Latte\Compiler\PrintContext;
15
use Latte\Helpers;
16

17

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

23

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

33

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

42
                return false;
1✔
43
        }
44

45

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

54
                return null;
1✔
55
        }
56

57

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

63

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

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

82

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

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

100

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