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

nette / latte / 29701425453

19 Jul 2026 07:51PM UTC coverage: 94.359% (+0.1%) from 94.22%
29701425453

push

github

dg
{include parent} and {include this} work inside dynamically named blocks

The name of the enclosing block is resolved at runtime from the stack of
blocks being currently rendered, which is shared along the inheritance
chain. Previously this was a compile error, or, when the dynamic block
was nested inside a static one, the include silently bound to the outer
static block.

To be released in 3.1.

20 of 22 new or added lines in 2 files covered. (90.91%)

138 existing lines in 40 files now uncovered.

6273 of 6648 relevant lines covered (94.36%)

0.94 hits per line

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

95.24
/src/Latte/Compiler/Nodes/Php/ArrayItemNode.php
1
<?php declare(strict_types=1);
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
namespace Latte\Compiler\Nodes\Php;
9

10
use Latte\Compiler\Node;
11
use Latte\Compiler\Position;
12
use Latte\Compiler\PrintContext;
13

14

15
/**
16
 * Array item with optional key, reference, and spread operator.
17
 */
18
class ArrayItemNode extends Node
19
{
20
        public function __construct(
1✔
21
                public ExpressionNode $value,
22
                public ExpressionNode|IdentifierNode|null $key = null,
23
                public bool $byRef = false,
24
                public bool $unpack = false,
25
                public ?Position $position = null,
26
                public ?Position $end = null,
27
        ) {
28
        }
1✔
29

30

31
        public function print(PrintContext $context): string
1✔
32
        {
33
                $key = match (true) {
1✔
34
                        $this->key instanceof ExpressionNode => $this->key->print($context) . ' => ',
1✔
35
                        $this->key instanceof IdentifierNode => $context->encodeString($this->key->name) . ' => ',
1✔
36
                        $this->key === null => '',
1✔
37
                };
38
                return $key
39
                        . ($this->byRef ? '&' : '')
1✔
40
                        . ($this->unpack ? '...' : '')
1✔
41
                        . $this->value->print($context);
1✔
42
        }
43

44

45
        public function toArgument(): ArgumentNode
46
        {
47
                $key = match (true) {
1✔
48
                        $this->key instanceof Scalar\StringNode => new IdentifierNode($this->key->value),
1✔
49
                        $this->key instanceof IdentifierNode => $this->key,
1✔
50
                        $this->key === null => null,
1✔
UNCOV
51
                        default => throw new \InvalidArgumentException('The expression used in the key cannot be converted to an argument.'),
×
52
                };
53
                return new ArgumentNode($this->value, $this->byRef, $this->unpack, $key, $this->position);
1✔
54
        }
55

56

57
        public function &getIterator(): \Generator
1✔
58
        {
59
                if ($this->key) {
1✔
60
                        yield $this->key;
1✔
61
                }
62
                yield $this->value;
1✔
63
        }
1✔
64
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc