[!!!][TASK] Aggregate validator information in class schema 61/55261/13
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Thu, 4 Jan 2018 10:34:42 +0000 (11:34 +0100)
committerFrank Naegler <frank.naegler@typo3.org>
Thu, 29 Mar 2018 13:37:00 +0000 (15:37 +0200)
commit84879ed47fb1b01f6e6334102a906cd65b03cd47
tree99744577178804e2174ba2e96411fad89a3795e6
parentb9026a9f4b477198eef002c2b23121df6dda414b
[!!!][TASK] Aggregate validator information in class schema

This is the first part of many to streamline the resolving of
validators. In this patch, the following changes:

- The class schema aggregates all the information about
  validators that are added via @validate annotations.
  As reflection is involved here, it makes sense to
  put this into the class schema generation and remove
  it from the ActionController.

- Along with this change there have been changes to the
  ValidatorResolver class. Being references only in the
  ActionController, buildMethodArgumentsValidatorConjunctions
  has been deprecated and is no longer used by the core
  itself.

- Also, the methods parseValidatorAnnotation and
  resolveValidatorObjectName have been made public as they
  are now used from outside the ValidatorResolver class.

The main achievements of this patch are getting rid of
runtime reflection by the ActionController and fetching
the necessary information about validators from the class
schema, which at this very moment, is also generated during
runtime but is cached and that cache can be warmed up in
the future. Therefore this change does also improve the
runtime performance of Extbase a bit.

This patch is considered breaking as it removes the support
for adding validators to properties of method arguments via
the following (quite unknown) semantic sugar.

/*
 * @param Model $model
 * @validate $model.property NotEmpty
 */
public function foo(Model $model){}

This possibility is quite unknown and unused in the wild and
as it eases the aggregation of validators it will be removed
without any replacement.

However, whenever a model is validated and a model validator
exists for that model, it will be registered and called
automatically. If not dealing with models but regular objects
or arrays, the recommended way is to write a custom validator
and do the validation manually in that class.

Releases: master
Resolves: #83475
Change-Id: I3c76e722fe084e8346bb27ea5ba8c7ef0f056eda
Reviewed-on: https://review.typo3.org/55261
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
17 files changed:
typo3/sysext/core/Documentation/Changelog/master/Breaking-83475-AggregateValidatorInformationInClassSchema.rst [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/master/Deprecation-83475-AggregateValidatorInformationInClassSchema-1.rst [new file with mode: 0644]
typo3/sysext/core/Documentation/Changelog/master/Deprecation-83475-AggregateValidatorInformationInClassSchema-2.rst [new file with mode: 0644]
typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php
typo3/sysext/extbase/Classes/Reflection/ClassSchema.php
typo3/sysext/extbase/Classes/Validation/ValidatorResolver.php
typo3/sysext/extbase/Tests/Unit/Reflection/ClassSchemaTest.php
typo3/sysext/extbase/Tests/Unit/Reflection/Fixture/DummyClassWithValidateAnnotation.php [deleted file]
typo3/sysext/extbase/Tests/Unit/Reflection/Fixture/DummyController.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Unit/Reflection/Fixture/DummyControllerWithValidateAnnotationWithoutParam.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Unit/Reflection/Fixture/DummyControllerWithValidateAnnotationWithoutParamTypeHint.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Unit/Reflection/Fixture/DummyModel.php
typo3/sysext/extbase/Tests/Unit/Reflection/Fixture/Validation/Validator/DummyValidator.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Unit/Reflection/ReflectionServiceTest.php
typo3/sysext/extbase/Tests/UnitDeprecated/Validation/ValidatorResolverTest.php [new file with mode: 0644]
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallStaticMatcher.php