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

filhocodes / twig-stack-extension / 3931621931

pending completion
3931621931

Pull #5

github

GitHub
Merge 139b3f647 into b1bf7c8a8
Pull Request #5: Add PHP 8.2 to the tests

160 of 171 relevant lines covered (93.57%)

3.65 hits per line

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

100.0
/src/NodeVisitors/StackNodeVisitor.php
1
<?php
2
declare(strict_types=1);
3

4
namespace FilhoCodes\TwigStackExtension\NodeVisitors;
5

6
use FilhoCodes\TwigStackExtension\Nodes\BodyNode;
7
use Twig\Environment;
8
use Twig\Node\ModuleNode;
9
use Twig\Node\Node;
10
use Twig\NodeVisitor\NodeVisitorInterface;
11

12
/**
13
 * StackNodeVisitor
14
 *
15
 * Handle the Twig Nodes in order to enable the stack feature of this
16
 * extension.
17
 */
18
final class StackNodeVisitor implements NodeVisitorInterface
19
{
20
    /**
21
     * @inheritDoc
22
     */
23
    public function enterNode(Node $node, Environment $env): Node
24
    {
25
        return $node;
4✔
26
    }
27

28
    /**
29
     * @inheritDoc
30
     */
31
    public function leaveNode(Node $node, Environment $env): ?Node
32
    {
33
        if (!($node instanceof ModuleNode)) {
4✔
34
            return $node;
4✔
35
        }
36

37
        if ($node->hasNode('body') && !$node->hasNode('parent')) {
4✔
38
            $body = $node->getNode('body');
4✔
39
            $node->setNode('body', new BodyNode($body));
4✔
40
        }
41

42
        return $node;
4✔
43
    }
44

45
    /**
46
     * @inheritDoc
47
     */
48
    public function getPriority()
49
    {
50
        return -10;
4✔
51
    }
52
}
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