• 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

57.14
/src/Latte/Compiler/Nodes/Php/Expression/ArrayNode.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\Expression;
11

12
use Latte\Compiler\Nodes\Php\ArgumentNode;
13
use Latte\Compiler\Nodes\Php\ArrayItemNode;
14
use Latte\Compiler\Nodes\Php\ExpressionNode;
15
use Latte\Compiler\Position;
16
use Latte\Compiler\PrintContext;
17
use Latte\Helpers;
18
use const PHP_VERSION_ID;
19

20

21
class ArrayNode extends ExpressionNode
22
{
23
        public function __construct(
1✔
24
                /** @var array<ArrayItemNode> */
25
                public array $items = [],
26
                public ?Position $position = null,
27
        ) {
28
                (function (ArrayItemNode ...$args) {})(...$items);
1✔
29
        }
1✔
30

31

32
        /** @return ArgumentNode[] */
33
        public function toArguments(): array
34
        {
35
                return array_map(fn(ArrayItemNode $item) => $item->toArgument(), $this->items);
1✔
36
        }
37

38

39
        public function print(PrintContext $context): string
1✔
40
        {
41
                // Converts [...$var] -> $var, because PHP 8.0 doesn't support unpacking with string keys
42
                if (PHP_VERSION_ID < 80100) {
1✔
43
                        $res = '[';
×
44
                        $merge = false;
×
45
                        foreach ($this->items as $item) {
×
46
                                if ($item->unpack) {
×
47
                                        $res .= '], ' . $item->value->print($context) . ', [';
×
48
                                        $merge = true;
×
49
                                } else {
UNCOV
50
                                        $res .= $item->print($context) . ', ';
×
51
                                }
52
                        }
53

UNCOV
54
                        $res = str_ends_with($res, ', ') ? substr($res, 0, -2) : $res;
×
55
                        return $merge ? "array_merge($res])" : $res . ']';
×
56
                }
57

58
                return '[' . $context->implode($this->items) . ']';
1✔
59
        }
60

61

62
        public function &getIterator(): \Generator
1✔
63
        {
64
                foreach ($this->items as &$item) {
1✔
65
                        yield $item;
1✔
66
                }
67
                Helpers::removeNulls($this->items);
1✔
68
        }
1✔
69
}
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