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

CPS-IT / handlebars / 23361170525

20 Mar 2026 08:24PM UTC coverage: 90.027% (-0.3%) from 90.285%
23361170525

Pull #543

github

web-flow
Merge da28b186c into 86597a598
Pull Request #543: [TASK] Update codebase to match PHPStan level 9

127 of 142 new or added lines in 41 files covered. (89.44%)

7 existing lines in 4 files now uncovered.

1354 of 1504 relevant lines covered (90.03%)

6.84 hits per line

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

94.12
/Classes/Renderer/Helper/ExtendHelper.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "handlebars".
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17

18
namespace CPSIT\Typo3Handlebars\Renderer\Helper;
19

20
use CPSIT\Typo3Handlebars\Attribute;
21
use CPSIT\Typo3Handlebars\Renderer;
22
use DevTheorem\Handlebars;
23

24
/**
25
 * ExtendHelper
26
 *
27
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
28
 * @license GPL-2.0-or-later
29
 * @see https://github.com/shannonmoeller/handlebars-layouts#extend-partial-context-keyvalue-
30
 */
31
#[Attribute\AsHelper('extend')]
32
final readonly class ExtendHelper implements Helper
33
{
34
    public function __construct(
3✔
35
        private Renderer\Renderer $renderer,
36
    ) {}
3✔
37

38
    public function render(
3✔
39
        Handlebars\HelperOptions $options,
40
        ?Renderer\RenderingContext $renderingContext = null,
41
        string $name = '',
42
        mixed ...$arguments,
43
    ): string {
44
        // Custom context is optional
45
        $customContext = [];
3✔
46
        if ($arguments !== []) {
3✔
47
            $customContext = (array)array_pop($arguments);
2✔
48
        }
49

50
        // Create new handlebars layout item
51
        $handlebarsLayout = new Renderer\Component\Layout\HandlebarsLayout($options->fn);
3✔
52

53
        // Add layout to layout stack
54
        $layoutStack = Renderer\Component\Layout\HandlebarsLayoutStack::fromScope($options->scope);
3✔
55
        $layoutStack->push($handlebarsLayout);
3✔
56

57
        // Merge data with supplied data
58
        if (is_array($options->scope)) {
3✔
59
            $variables = array_replace_recursive($options->scope, $customContext, $options->hash);
3✔
60
        } else {
NEW
61
            $variables = array_replace_recursive($customContext, $options->hash);
×
62
        }
63

64
        // Render layout with merged data
65
        try {
66
            return $this->renderer->render(
3✔
67
                new Renderer\RenderingContext($name, $variables, $renderingContext?->getRequest()),
3✔
68
            );
3✔
69
        } finally {
70
            $layoutStack->pop();
3✔
71

72
            Renderer\Component\Layout\HandlebarsLayoutStack::destroyIfEmpty($options->scope);
3✔
73
        }
74
    }
75
}
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