Feature: #108227 - Allow
#[IgnoreValidation] and
#[Validate] attributes for method parameters
See forge#108227
Description
The Extbase attributes
# and
# can
now be used for controller action method parameters.
This extends the current validation behavior of these attributes, where either (1) the complete method or (2) a single parameter is taken into account for validation. While this works fine for (1), using these attributes in context of (2) raises some concerns regarding
- duplication of parameter names,
- validation of the existence of a configured parameter, and
- unnecessary complexity regarding reflection-based handling of these parameters.
History
When the attributes were originally implemented as Doctrine annotations, the only possible way to implement behavior (2) was to add the appropriate annotation to the method-related annotation.
Since forge#107229, annotations are no longer used in Extbase, and PHP attributes are the only remaining successor in this area. Since PHP attributes support placement at specific method parameters, the existing attributes can safely rewritten to be placed (1) at a specific method or (2) at a specific method parameter.
Usage with method parameters
The capabilities of the existing attributes are expanded to allow placement at method parameters as well. The previous behavior (defining validation-related behavior at method level using the existing attribute properties) is now deprecated and will be removed with TYPO3 v15 (see deprecation notice).
Impact
By allowing the usage of both
# and
#
attributes at method parameter level, the previous error-prone behavior is
now hardened. In addition, this change improves developer experience and pushes
the Extbase ecosystem towards a modernized architecture.