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

nette / latte / 16317493748

16 Jul 2025 10:49AM UTC coverage: 93.696% (-0.002%) from 93.698%
16317493748

push

github

dg
PrintContent: refactoring and updated operator precedence and associativity table

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

30 existing lines in 15 files now uncovered.

5187 of 5536 relevant lines covered (93.7%)

0.94 hits per line

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

97.67
/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
        public function __construct(
1✔
21
                /** @var FilterNode[] */
22
                public array $filters,
23
                public bool $escape = false,
24
                public bool $check = true,
25
                public ?Position $position = null,
26
        ) {
27
                (function (FilterNode ...$args) {})(...$filters);
1✔
28
        }
1✔
29

30

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

39
                return false;
1✔
40
        }
41

42

43
        public function print(PrintContext $context): string
44
        {
UNCOV
45
                throw new \LogicException('Cannot directly print ModifierNode');
×
46
        }
47

48

49
        public function printSimple(PrintContext $context, string $expr): string
1✔
50
        {
51
                $escape = $this->escape;
1✔
52
                $check = $this->check;
1✔
53
                foreach ($this->filters as $filter) {
1✔
54
                        $name = $filter->name->name;
1✔
55
                        if ($name === 'nocheck' || $name === 'noCheck') {
1✔
56
                                $check = false;
1✔
57
                        } elseif ($name === 'noescape') {
1✔
58
                                $escape = false;
1✔
59
                        } else {
60
                                if ($name === 'datastream' || $name === 'dataStream') {
1✔
61
                                        $check = false;
1✔
62
                                }
63
                                $expr = $filter->printSimple($context, $expr);
1✔
64
                        }
65
                }
66

67
                $escaper = $context->getEscaper();
1✔
68
                if ($check) {
1✔
69
                        $expr = $escaper->check($expr);
1✔
70
                }
71

72
                $expr = $escape
1✔
73
                        ? $escaper->escape($expr)
1✔
74
                        : $escaper->escapeMandatory($expr);
1✔
75

76
                return $expr;
1✔
77
        }
78

79

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

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

97

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