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

nette / latte / 16023663319

02 Jul 2025 11:17AM UTC coverage: 93.84% (+0.1%) from 93.694%
16023663319

push

github

dg
Implemented proper handling of HTML attributes based on their types WIP

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

50 existing lines in 18 files now uncovered.

5240 of 5584 relevant lines covered (93.84%)

0.94 hits per line

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

97.14
/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 print(PrintContext $context): string
47
        {
UNCOV
48
                throw new \LogicException('Cannot directly print ModifierNode');
×
49
        }
50

51

52
        public function printSimple(PrintContext $context, string $expr): string
1✔
53
        {
54
                $escape = $this->escape;
1✔
55
                foreach ($this->filters as $filter) {
1✔
56
                        $name = $filter->name->name;
1✔
57
                        if ($name === 'noescape') {
1✔
58
                                $escape = false;
1✔
59
                        } else {
60
                                $expr = $filter->printSimple($context, $expr);
1✔
61
                        }
62
                }
63

64
                $escaper = $context->getEscaper();
1✔
65
                return $escape
1✔
66
                        ? $escaper->escape($expr)
1✔
67
                        : $escaper->escapeMandatory($expr);
1✔
68
        }
69

70

71
        public function printContentAware(PrintContext $context, string $expr): string
1✔
72
        {
73
                $escape = $this->escape;
1✔
74
                foreach ($this->filters as $filter) {
1✔
75
                        $name = $filter->name->name;
1✔
76
                        if ($name === 'noescape') {
1✔
77
                                $escape = false;
1✔
78
                        } else {
79
                                $expr = $filter->printContentAware($context, $expr);
1✔
80
                        }
81
                }
82

83
                return $escape
1✔
84
                        ? $context->getEscaper()->escapeContent($expr)
1✔
85
                        : $expr;
1✔
86
        }
87

88

89
        public function &getIterator(): \Generator
1✔
90
        {
91
                foreach ($this->filters as &$filter) {
1✔
92
                        yield $filter;
1✔
93
                }
94
                Helpers::removeNulls($this->filters);
1✔
95
        }
1✔
96
}
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