#107883Incorrect union type handling in view helpers
Description
In some situations the following exception gets thrown:
The argument "format" was registered with type "Vendor\Ext\Domain\Enum\DateFormat|string", but is of type "Vendor\Ext\Domain\Enum\DateFormat" in view helper "Vendor\Ext\ViewHelpers\DateViewHelper".
I created a custom view helper with an argument with a union type (`DateFormat|string`). `DateFormat` is a string-backed PHP enum.
public function initializeArguments(): void
{
$this->registerArgument(
'format',
DateFormat::class . '|string',
'Description',
false,
DateFormat::Alphabetical
);
}
<vendor:ext.date />
^ use default for `format`
When I change the default value in PHP (`DateFormat::Alphabetical->DateFormat::Numerical`) or the `required`-argument and reload the page, the exception is thrown.
When I clear all TYPO3 caches the exception will not be thrown anymore.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 2
-
Daniel Corn changed subject
# Incorrect union type handling in view helpersIncorrect union type handling in view helpers <span data-processor="relativetime" data-value="2025-10-28T11:41:25+00:00" > 10/28/25, 11:41 </span> -
Garvin Hicking commented and changed status
NewClosed <span data-processor="relativetime" data-value="2025-11-02T11:12:51+00:00" > 11/02/25, 11:12 </span>
Hi!
Union types like that are not supported by current fluid. The upcoming v5 will have that: https://github.com/TYPO3/Fluid/commit/4dc0cc54007d0867ad0bc57578b5c0859ff0966b
So for now you’ll have to accept “mixed” and have distinction/validation performed yourself inside your VH.
HTH!