[TASK] Deprecate unneeded RawValidator 94/55294/2
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Sun, 7 Jan 2018 13:34:48 +0000 (14:34 +0100)
committerGeorg Ringer <georg.ringer@gmail.com>
Mon, 8 Jan 2018 10:31:22 +0000 (11:31 +0100)
The RawValidator is a useless Validator that is
automatically attached to all method params that
are annotated with "@param mixed".

This is due to the recognition of the pseudo type
"mixed" in ValidatorResolver::getValidatorType which
converts mixed into Raw and which then is responsible
for creating that RawValidator for the param.

However, this is completely useless as the Validator
does not validate. Hence, it will be deprecated and
removed in TYPO3 v10.0 without any replacement.

Releases: master
Resolves: #83503
Change-Id: Id3bc1418224e01983d6a3c13b759d6c8a4f764f3
Reviewed-on: https://review.typo3.org/55294
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Henning Liebe <h.liebe@neusta.de>
Reviewed-by: Eugene Kenah Djomo <kdeugene@yahoo.fr>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
typo3/sysext/core/Documentation/Changelog/master/Deprecation-83503-DeprecateUnneededRawValidator.rst [new file with mode: 0644]
typo3/sysext/extbase/Classes/Validation/Validator/RawValidator.php
typo3/sysext/extbase/Tests/Unit/Validation/Validator/RawValidatorTest.php [deleted file]
typo3/sysext/extbase/Tests/UnitDeprecated/Validation/Validator/RawValidatorTest.php [new file with mode: 0644]
typo3/sysext/install/Configuration/ExtensionScanner/Php/ClassNameMatcher.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83503-DeprecateUnneededRawValidator.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83503-DeprecateUnneededRawValidator.rst
new file mode 100644 (file)
index 0000000..bcc04a7
--- /dev/null
@@ -0,0 +1,32 @@
+.. include:: ../../Includes.txt
+
+=====================================================
+Deprecation: #83503 - Deprecate unneeded RawValidator
+=====================================================
+
+See :issue:`83503`
+
+Description
+===========
+
+The `RawValidator` does not actually validate anything at all. It was meant to be some kind of NullObject to prevent a `NoSuchValidatorException` when resolving a validator from the detected type of a param. As these Exceptions are caught, the Validator is not needed any more and will be removed.
+
+
+Impact
+======
+
+If you rely on the `RawValidator` you will need to implement it yourself.
+
+
+Affected Installations
+======================
+
+All installations that use the `RawValidator`. As the validator does not validate anything the chances are high that it does not affect anyone at all.
+
+
+Migration
+=========
+
+If needed, create the Validator yourself.
+
+.. index:: PHP-API, PartiallyScanned
index 266c67c..06adf1c 100644 (file)
@@ -17,11 +17,24 @@ namespace TYPO3\CMS\Extbase\Validation\Validator;
 /**
  * A validator which accepts any input.
  *
- * @api
+ * @deprecated
  */
 class RawValidator extends AbstractValidator
 {
     /**
+     * @param array $options
+     */
+    public function __construct(array $options = [])
+    {
+        trigger_error(
+            __CLASS__ . ' is deprecated and will be removed in TYPO3 v10.0.',
+            E_USER_DEPRECATED
+        );
+
+        parent::__construct($options);
+    }
+
+    /**
      * This validator is always valid.
      *
      * @param mixed $value The value that should be validated (not used here)
diff --git a/typo3/sysext/extbase/Tests/Unit/Validation/Validator/RawValidatorTest.php b/typo3/sysext/extbase/Tests/Unit/Validation/Validator/RawValidatorTest.php
deleted file mode 100644 (file)
index d168a52..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-namespace TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator;
-
-/*                                                                        *
- * This script belongs to the Extbase framework.                          *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU Lesser General Public License as published by the *
- * Free Software Foundation, either version 3 of the License, or (at your *
- * option) any later version.                                             *
- *                                                                        *
- * This script is distributed in the hope that it will be useful, but     *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
- * General Public License for more details.                               *
- *                                                                        *
- * You should have received a copy of the GNU Lesser General Public       *
- * License along with the script.                                         *
- * If not, see http://www.gnu.org/licenses/lgpl.html                      *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-
-/**
- * Testcase for the raw validator
- *
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- */
-class RawValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\AbstractValidatorTestcase
-{
-    /**
-     * @var string
-     */
-    protected $validatorClassName = \TYPO3\CMS\Extbase\Validation\Validator\RawValidator::class;
-
-    /**
-     * @test
-     */
-    public function theRawValidatorAlwaysReturnsNoErrors()
-    {
-        $rawValidator = new \TYPO3\CMS\Extbase\Validation\Validator\RawValidator([]);
-        $this->assertFalse($rawValidator->validate('simple1expression')->hasErrors());
-        $this->assertFalse($rawValidator->validate('')->hasErrors());
-        $this->assertFalse($rawValidator->validate(null)->hasErrors());
-        $this->assertFalse($rawValidator->validate(false)->hasErrors());
-        $this->assertFalse($rawValidator->validate(new \ArrayObject())->hasErrors());
-    }
-}
diff --git a/typo3/sysext/extbase/Tests/UnitDeprecated/Validation/Validator/RawValidatorTest.php b/typo3/sysext/extbase/Tests/UnitDeprecated/Validation/Validator/RawValidatorTest.php
new file mode 100644 (file)
index 0000000..fb1bcd3
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+namespace TYPO3\CMS\Extbase\Tests\UnitDeprecated\Validation\Validator;
+
+/*                                                                        *
+ * This script belongs to the Extbase framework.                          *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * Testcase for the raw validator
+ *
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class RawValidatorTest extends \TYPO3\CMS\Extbase\Tests\Unit\Validation\Validator\AbstractValidatorTestcase
+{
+    /**
+     * @var string
+     */
+    protected $validatorClassName = \TYPO3\CMS\Extbase\Validation\Validator\RawValidator::class;
+
+    /**
+     * @test
+     */
+    public function theRawValidatorAlwaysReturnsNoErrors()
+    {
+        $rawValidator = new \TYPO3\CMS\Extbase\Validation\Validator\RawValidator([]);
+        $this->assertFalse($rawValidator->validate('simple1expression')->hasErrors());
+        $this->assertFalse($rawValidator->validate('')->hasErrors());
+        $this->assertFalse($rawValidator->validate(null)->hasErrors());
+        $this->assertFalse($rawValidator->validate(false)->hasErrors());
+        $this->assertFalse($rawValidator->validate(new \ArrayObject())->hasErrors());
+    }
+}
index 06c4d74..921b6f6 100644 (file)
@@ -524,4 +524,9 @@ return [
             'Breaking-82426-ExtJSAndExtDirectRemoval.rst',
         ],
     ],
+    'TYPO3\CMS\Extbase\Validation\Validator\RawValidator' => [
+        'restFiles' => [
+            'Deprecation-83503-DeprecateUnneededRawValidator.rst',
+        ],
+    ],
 ];