#106584Re-add the manual argument registration for "href" and "src"
Description
Original Report: https://github.com/TYPO3/Fluid/issues/1043
Hello all,
my phpstorm reads the registered arguments, and gives me some errors when using some viewhelper.
Here is a brief list, may not be complete:
“f:image” doesn’t declare “alt”, but needs it
“f:asset.css” doesn’t declare “href”, but needs it
“f:asset.script” doesn’t declare “src” and “type” , but needs / uses it
would be nice to have those back :)
Have a nice day
Daniel Kruse
Reviews 1
History 810
-
Garvin Hicking commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2025-04-17T07:36:34+00:00" > 04/17/25, 07:36 </span> -
Daniel Kruse commented <span data-processor="relativetime" data-value="2025-04-17T07:55:19+00:00" > 04/17/25, 07:55 </span>
Well, i give you the code for the CssViewHelper:
public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('disabled', 'bool', 'Define whether or not the described stylesheet should be loaded and applied to the document.'); $this->registerArgument('useNonce', 'bool', 'Whether to use the global nonce value', false, false); $this->registerArgument('identifier', 'string', 'Use this identifier within templates to only inject your CSS once, even though it is added multiple times.', true); $this->registerArgument('priority', 'boolean', 'Define whether the CSS should be included before other CSS. CSS will always be output in the <head> tag.', false, false); $this->registerArgument('inline', 'bool', 'Define whether or not the referenced file should be loaded as inline styles (Only to be used if \'href\' is set).', false, false); } public function render(): string { $identifier = (string)$this->arguments['identifier']; $attributes = $this->tag->getAttributes(); // boolean attributes shall output attr="attr" if set if ($this->arguments['disabled'] ?? false) { $attributes['disabled'] = 'disabled'; } $file = $attributes['href'] ?? null; unset($attributes['href']); $options = [ 'priority' => $this->arguments['priority'], 'useNonce' => $this->arguments['useNonce'], ]; /* shortend here */ return ''; }and the parent function:
public function initializeArguments() { $this->registerArgument('additionalAttributes', 'array', 'Additional tag attributes. They will be added directly to the resulting HTML tag.'); $this->registerArgument('data', 'array', 'Additional data-* attributes. They will each be added with a "data-" prefix.'); $this->registerArgument('aria', 'array', 'Additional aria-* attributes. They will each be added with a "aria-" prefix.'); }in this case, it would be nice to register the optional argument “href” like this again
$this->registerArgument('href', 'string', 'The path to the css file', false, null);i think, this is the reason why phpStorm (with a typo3 plugin) thinks the href is not a valid argument.
Same applies to the other issue i mentionedThank you
-
Garvin Hicking changed description <span data-processor="relativetime" data-value="2025-04-17T08:35:53+00:00" > 04/17/25, 08:35 </span>
-
Simon Praetorius commented <span data-processor="relativetime" data-value="2025-04-17T09:34:10+00:00" > 04/17/25, 09:34 </span>
Can you add a list here of arguments you would like to re-add? As already mentioned, this should only include arguments that have special handling in the ViewHelper and are not just passed through. Then we can discuss which ones we could add again, which would also help in the automatic ViewHelper reference.
What we shouldn’t do is add a lot of them, which will make it harder again to find the arguments that are actually relevant for the ViewHelper’s behavior.
-
Daniel Kruse commented <span data-processor="relativetime" data-value="2025-04-17T09:43:35+00:00" > 04/17/25, 09:43 </span>
I had my list open for some weeks, and i only missed these three arguments.
f:asset.css -> href
f:asset.script -> src
f:image -> alt
(so my collegues won’t forget the alt text)don’t know where “type” (above) came from, but this sums it up for me
-
Rico Sonntag commented and changed priority
Should haveMust have <span data-processor="relativetime" data-value="2025-06-13T10:27:29+00:00" > 06/13/25, 10:27 </span>This just caught my attention. PHPStorm is warning me that various attributes are obsolete, even though they aren’t, based on the code. What was the reason for removing the attributes from the ViewHelpers (https://github.com/TYPO3-CMS/fluid/commit/aa378389fe58edb168a3952db3ba692f1d72bf6e)? All attributes used in a ViewHelper should be listed in “initializeArguments” so that PHPStorm extensions (e.g., https://plugins.jetbrains.com/plugin/11151-typo3-fluid—enterprise) can read them and suggest them during autocompletion. How else would you know which attributes the ViewHelper supports? There’s no point in digging through all the ViewHelpers to see if there’s a hidden attribute.
-
Simon Praetorius commented <span data-processor="relativetime" data-value="2025-06-13T13:27:49+00:00" > 06/13/25, 13:27 </span>
Daniel Kruse wrote in #note-5:
> f:asset.css -> href
> f:asset.script -> src
> f:image -> altI think those three would be valid to add as registered arguments, since all of them are used in the PHP code of these ViewHelpers. If you’re able to, feel free to provide a patch. Also, don’t hesitate to contact me directly if there are any questions about that.
> PHPStorm is warning me that various attributes are obsolete
The key feature is this one: https://github.com/TYPO3/Fluid/pull/859. So the rule is now: All tag-based ViewHelpers support any attribute. That is also how we implemented it in the XSD generator that ships with TYPO3 v13 out-of-the-box: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/13.2/Feature-104114-CommandToGenerateFluidSchemaFiles.html
-
Gerrit Code Review pushed patch set 1 for main to change 95397 status
Needs FeedbackUnder Review <span data-processor="relativetime" data-value="2026-08-24T16:20:53+00:00" > 08/24/26, 16:20 </span> -
Gerrit Code Review pushed patch set 2 for main to change 95397 <span data-processor="relativetime" data-value="2026-08-24T16:29:50+00:00" > 08/24/26, 16:29 </span>
-
Benjamin Kott commented and changed status
Under ReviewResolved done0 %100 % <span data-processor="relativetime" data-value="2026-08-26T05:35:11+00:00" > 08/26/26, 05:35 </span>Applied in changeset commit:1af492d7bd5978f927d37fe05a56d4aafd4055bf.
Can you elaborate why PHPStorm draws this conclusion? The mentioned attributes are not mandatory; they are neither listed as ‘required’ in the VH itself, nor in the XSD definition of our viewhelpers.
I guess that PHPStorm tries to be clever and see that a ‘script’ or ‘image’ or ‘css’ tag is used here, and tries to apply “HTML knowledge”.
This would though be a bug in PHPStorm, not TYPO3, and would need adjustments in PHPStorm.
Maybe if you can find out more about this we could address it, otherwise we would need to close the issue on our side…?
Thanks for bringing this up,
Garvin