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

CPS-IT / handlebars-forms / 23544127297

25 Mar 2026 01:40PM UTC coverage: 0.726% (-0.002%) from 0.728%
23544127297

push

github

eliashaeussler
[BUGFIX] Don't try to load a non-string value from ValueCollector

0 of 2 new or added lines in 1 file covered. (0.0%)

7 of 964 relevant lines covered (0.73%)

0.03 hits per line

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

0.0
/Classes/ContentObject/ContextAwareContentObjectFactory.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "handlebars_forms".
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\Typo3HandlebarsForms\ContentObject;
19

20
use Psr\Http\Message;
21
use Symfony\Component\DependencyInjection;
22
use TYPO3\CMS\Frontend;
23

24
/**
25
 * ContextAwareContentObjectFactory
26
 *
27
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
28
 * @license GPL-2.0-or-later
29
 *
30
 * @internal
31
 */
32
#[DependencyInjection\Attribute\AsDecorator(Frontend\ContentObject\ContentObjectFactory::class)]
33
final class ContextAwareContentObjectFactory extends Frontend\ContentObject\ContentObjectFactory
34
{
35
    public function __construct(
×
36
        #[DependencyInjection\Attribute\AutowireDecorated]
37
        private readonly Frontend\ContentObject\ContentObjectFactory $inner,
38
        private readonly Context\ValueCollector $valueCollector,
39
    ) {
40
        // Missing constructor call is intended.
41
    }
×
42

43
    public function getContentObject(
×
44
        string $name,
45
        Message\ServerRequestInterface $request,
46
        Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer,
47
    ): ?Frontend\ContentObject\AbstractContentObject {
48
        $contentObject = $this->inner->getContentObject($name, $request, $contentObjectRenderer);
×
49

50
        if ($contentObject === null) {
×
51
            return null;
×
52
        }
53

54
        return new class ($contentObject, $this->valueCollector) extends Frontend\ContentObject\AbstractContentObject {
×
55
            public function __construct(
56
                private readonly Frontend\ContentObject\AbstractContentObject $contentObject,
57
                private readonly Context\ValueCollector $valueCollector,
58
            ) {}
×
59

60
            /**
61
             * @param array<string|int, mixed> $conf
62
             */
63
            public function render($conf = [])
64
            {
65
                $value = $this->contentObject->render($conf);
×
66

NEW
67
                if (!is_string($value)) {
×
NEW
68
                    return $value;
×
69
                }
70

71
                if (!$this->valueCollector->has($value)) {
×
72
                    return $value;
×
73
                }
74

75
                $resolvedValue = $this->valueCollector->load($value);
×
76

77
                if (!is_scalar($resolvedValue)) {
×
78
                    return $value;
×
79
                }
80

81
                return (string)$resolvedValue;
×
82
            }
83
        };
×
84
    }
85
}
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