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

nette / latte / 16317387179

16 Jul 2025 10:46AM UTC coverage: 93.699% (-0.1%) from 93.84%
16317387179

push

github

dg
added Helpers::stringOrNull() [Closes #401]

6 of 6 new or added lines in 2 files covered. (100.0%)

57 existing lines in 19 files now uncovered.

5160 of 5507 relevant lines covered (93.7%)

0.94 hits per line

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

97.73
/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

16

17
class ModifierNode extends Node
18
{
19
        public function __construct(
1✔
20
                /** @var FilterNode[] */
21
                public array $filters,
22
                public bool $escape = false,
23
                public bool $check = true,
24
                public ?Position $position = null,
25
        ) {
26
                (function (FilterNode ...$args) {})(...$filters);
1✔
27
        }
1✔
28

29

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

38
                return false;
1✔
39
        }
40

41

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

47

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

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

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

75
                return $expr;
1✔
76
        }
77

78

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

90
                if ($this->escape && empty($noescape)) {
1✔
91
                        $expr = 'LR\Filters::convertTo($ʟ_fi, '
1✔
92
                                . var_export($context->getEscaper()->export(), true) . ', '
1✔
93
                                . $expr
1✔
94
                                . ')';
1✔
95
                }
96

97
                return $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
        }
1✔
107
}
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