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

FluidTYPO3 / flux / 27757675993

18 Jun 2026 11:55AM UTC coverage: 89.162% (-3.5%) from 92.646%
27757675993

push

github

NamelessCoder
[TASK] Address last phpstan warnings

6228 of 6985 relevant lines covered (89.16%)

40.84 hits per line

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

92.86
/Classes/Form/Field.php
1
<?php
2
namespace FluidTYPO3\Flux\Form;
3

4
/*
5
 * This file is part of the FluidTYPO3/Flux project under GPLv2 or later.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.md file that was distributed with this source code.
9
 */
10

11
use TYPO3\CMS\Core\Utility\GeneralUtility;
12

13
/**
14
 * Generic TCA field
15
 */
16
class Field extends AbstractFormField
17
{
18
    protected string $type = 'input';
19
    protected ?string $displayCond = null;
20
    protected ?string $onChange = null;
21

22
    public function buildConfiguration(): array
23
    {
24
        $config = [
12✔
25
            'default' => $this->getDefault(),
12✔
26
        ];
12✔
27
        if ($this->getClearable()) {
12✔
28
            $config['fieldWizard']['fluxClearValue'] = [
×
29
                'renderType' => 'fluxClearValue',
×
30
            ];
×
31
        }
32
        return $config;
12✔
33
    }
34

35
    public static function create(array $settings = []): FieldInterface
36
    {
37
        if (!isset($settings['config']['type']) && !isset($settings['type'])) {
28✔
38
            throw new \UnexpectedValueException(
4✔
39
                'Field construction requires at least a "type", defined either as "type" or "config.type" property',
4✔
40
                1667227598
4✔
41
            );
4✔
42
        }
43
        $settings['config']['type'] = $settings['config']['type'] ?? $settings['type'];
24✔
44
        $settings['displayCondition'] = $settings['displayCond'] ?? null;
24✔
45
        unset($settings['type'], $settings['displayCond']);
24✔
46

47
        /** @var FieldInterface $field */
48
        $field = GeneralUtility::makeInstance(static::class);
24✔
49
        foreach ($settings as $propertyName => $value) {
24✔
50
            $setterMethodName = 'set' . ucfirst($propertyName);
24✔
51
            if (method_exists($field, $setterMethodName)) {
24✔
52
                $field->$setterMethodName($value);
24✔
53
            }
54
        }
55
        return $field;
24✔
56
    }
57

58
    /**
59
     * Creates a TCEforms configuration array based on the
60
     * configuration stored in this ViewHelper. Calls the
61
     * expected-to-be-overridden stub method getConfiguration()
62
     * to return the TCE field configuration - see that method
63
     * for information about how to implement that method.
64
     */
65
    public function build(): array
66
    {
67
        $filterClosure = function ($value) {
8✔
68
            return $value !== null && $value !== '';
8✔
69
        };
8✔
70

71
        $configuration = array_replace($this->buildConfiguration(), $this->getConfig());
8✔
72

73
        $fieldStructureArray = [
8✔
74
            'label' => $this->getLabel(),
8✔
75
            'description' => $this->getDescription(),
8✔
76
            'exclude' => intval($this->getExclude()),
8✔
77
            'config' => array_filter($configuration, $filterClosure),
8✔
78
            'displayCond' => $this->getDisplayCondition(),
8✔
79
            'onChange' => $this->getOnChange(),
8✔
80
        ];
8✔
81

82
        $fieldStructureArray = array_filter($fieldStructureArray, $filterClosure);
8✔
83
        return $fieldStructureArray;
8✔
84
    }
85

86
    public function getType(): string
87
    {
88
        return $this->type;
4✔
89
    }
90

91
    public function setType(string $type): self
92
    {
93
        $this->type = $type;
4✔
94

95
        return $this;
4✔
96
    }
97

98
    public function getOnChange(): ?string
99
    {
100
        return $this->onChange;
12✔
101
    }
102

103
    public function setOnChange(?string $onChange): self
104
    {
105
        $this->onChange = $onChange;
16✔
106

107
        return $this;
16✔
108
    }
109
}
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