TYPO3 / Fluid

Fluid template rendering engine - Standalone version
GNU Lesser General Public License v3.0
153 stars 93 forks source link

[TASK] Introduce type hints to ViewHelper-related API #918

Closed s2b closed 1 month ago

s2b commented 1 month ago

With v4 of Fluid, the goal is to not break any custom ViewHelpers out there. Thus, we only apply type hints to ViewHelper-related API for cases where we can be reasonably sure that it won't break ViewHelpers.

AbstractViewHelper is extended directly by custom ViewHelpers, so we can only type hint private properties.

ViewHelperInvoker and ViewHelperResolver are APIs that are implemented by frameworks that use Fluid for templating, so stricter types don't affect ViewHelper implementations. Still, there are some cases in which we won't enforce types because it is unclear if there are edge cases out there where the supplied types actually match existing PHPDOC annotations. For example, we can't really be sure if templates or ViewHelpers always return strings, so we stay away from those type hints for now.

TagBuilder, ArgumentDefinition and ViewHelperVariableContainer are often utilized from within ViewHelpers. However, because of their respected isolated functionality, we can be pretty sure about the types and thus apply them for most methods and properties.