[TASK] Deprecate @cli annotation 37/58037/3
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Sat, 25 Aug 2018 12:27:25 +0000 (14:27 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Sat, 25 Aug 2018 12:54:47 +0000 (14:54 +0200)
Back then, the PHPDoc annotation `@cli` was added to indicate
Extbase CommandController commands to be usable on CLI only
instead of also be usable as a scheduler task.

The scheduler implementation will be refactored in TYPO3 10
and the execution of commands from the backend will vanish.
Therefore it will not be necessary any more to define if
commands can only be used on the command line or not.
In the future, all commands will only be executable
from the command line.

Releases: master
Resolves: #85977
Change-Id: I52330517b51c5c747177cab55e34a721a0df5f67
Reviewed-on: https://review.typo3.org/58037
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Build/Scripts/annotationChecker.php
typo3/sysext/core/Documentation/Changelog/master/Deprecation-85977-DeprecateCliAnnotation.rst [new file with mode: 0644]
typo3/sysext/extbase/Classes/Command/HelpCommandController.php
typo3/sysext/extbase/Classes/Mvc/Cli/Command.php
typo3/sysext/extbase/Classes/Reflection/ClassSchema.php
typo3/sysext/extbase/Tests/Unit/Mvc/Cli/CommandTest.php
typo3/sysext/extbase/Tests/Unit/Mvc/Cli/Fixture/Command/MockCCommandController.php
typo3/sysext/extbase/Tests/UnitDeprecated/Mvc/Cli/CommandTest.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/UnitDeprecated/Mvc/Cli/Fixture/Command/MockCCommandController.php [new file with mode: 0644]
typo3/sysext/extensionmanager/Classes/Command/ExtensionCommandController.php
typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodAnnotationMatcher.php

index 4e89a94..cc664eb 100755 (executable)
@@ -62,8 +62,10 @@ class NodeVisitor extends NodeVisitorAbstract
                     'env',
                     // PHPCheckStyle
                     'SuppressWarnings', 'noinspection',
-                    // Extbase related (deprecated)
-                    'transient', 'cli', 'flushesCaches',
+                    // Extbase related (deprecated), will be removed in TYPO3 v10.0
+                    'transient',
+                    'cli', // this is still used in Extbase\Tests\UnitDeprecated
+                    'flushesCaches',
                     // Extbase related
                     'TYPO3\\\\CMS\\\\Extbase\\\\Annotation\\\\Inject', 'Extbase\\\\Inject', 'Inject',
                     'TYPO3\\\\CMS\\\\Extbase\\\\Annotation\\\\Validate', 'Extbase\\\\Validate', 'Validate',
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85977-DeprecateCliAnnotation.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-85977-DeprecateCliAnnotation.rst
new file mode 100644 (file)
index 0000000..271d3b0
--- /dev/null
@@ -0,0 +1,35 @@
+.. include:: ../../Includes.txt
+
+===============================================
+Deprecation: #85977 - Deprecate @cli annotation
+===============================================
+
+See :issue:`85977`
+
+Description
+===========
+
+Back then, the PHPDoc annotation `@cli` was added to indicate Extbase CommandController commands to be usable on CLI only instead of also be usable as a scheduler task.
+
+The scheduler implementation will be refactored in TYPO3 10 and the execution of commands from the backend will vanish. Therefore it will not be necessary any more to define if commands can only be used on the command line or not. In the future, all commands will only be executable from the command line.
+
+
+Impact
+======
+
+Using @cli will log a deprecation warning.
+Once removed from your commands, they will appear in the list of executable executable commands in the scheduler module.
+
+
+Affected Installations
+======================
+
+All installations that make use of command controllers that are tagged with @cli.
+
+
+Migration
+=========
+
+There is none.
+
+.. index:: FullyScanned, ext:scheduler
index cf0216b..993a246 100644 (file)
@@ -63,7 +63,6 @@ class HelpCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandCon
      * ./typo3/sysext/core/bin/typo3 extbase:help <command identifier>
      *
      * @param string $commandIdentifier Identifier of a command for more details
-     * @cli
      */
     public function helpCommand($commandIdentifier = null)
     {
index 974d69d..c9c5400 100644 (file)
@@ -243,6 +243,8 @@ class Command
      * Tells if this command is meant to be used on CLI only.
      *
      * @return bool
+     *
+     * todo: deprecate/remove method in TYPO3 10.x while refactoring the scheduler implementation
      */
     public function isCliOnly()
     {
index 48bd7a3..f5b16e5 100644 (file)
@@ -414,6 +414,16 @@ class ClassSchema
             }
 
             foreach ($docCommentParser->getTagsValues() as $tag => $values) {
+                if ($tag === 'cli') {
+                    trigger_error(
+                        sprintf(
+                            'Method %s::%s is tagged with @cli which is deprecated and will be removed in TYPO3 v10.0.',
+                            $reflectionClass->getName(),
+                            $reflectionMethod->getName()
+                        ),
+                        E_USER_DEPRECATED
+                    );
+                }
                 if ($tag === 'ignorevalidation') {
                     trigger_error(
                         sprintf(
index a3536f3..ddaee20 100644 (file)
@@ -107,25 +107,6 @@ class CommandTest extends UnitTestCase
         static::assertTrue($commandController->isInternal());
     }
 
-    public function testIsCliOnly()
-    {
-        $commandController = GeneralUtility::makeInstance(ObjectManager::class)->get(
-            Command::class,
-            MockCCommandController::class,
-            'empty'
-        );
-
-        static::assertFalse($commandController->isCliOnly());
-
-        $commandController = GeneralUtility::makeInstance(ObjectManager::class)->get(
-            Command::class,
-            MockCCommandController::class,
-            'cliOnly'
-        );
-
-        static::assertTrue($commandController->isCliOnly());
-    }
-
     public function testIsFlushinCaches()
     {
         $commandController = GeneralUtility::makeInstance(ObjectManager::class)->get(
index 463c0b4..b2c17c2 100644 (file)
@@ -18,13 +18,6 @@ class MockCCommandController extends \TYPO3\CMS\Extbase\Mvc\Cli\Command
     }
 
     /**
-     * @cli
-     */
-    public function cliOnlyCommand()
-    {
-    }
-
-    /**
      * @flushesCaches
      */
     public function flushingCachesCommand()
diff --git a/typo3/sysext/extbase/Tests/UnitDeprecated/Mvc/Cli/CommandTest.php b/typo3/sysext/extbase/Tests/UnitDeprecated/Mvc/Cli/CommandTest.php
new file mode 100644 (file)
index 0000000..c4d0173
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+declare(strict_types = 1);
+
+namespace TYPO3\CMS\Extbase\Tests\UnitDeprecated\Mvc\Cli;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Mvc\Cli\Command;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
+use TYPO3\CMS\Extbase\Tests\UnitDeprecated\Mvc\Cli\Fixture\Command\MockCCommandController;
+use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
+
+/**
+ * Test case
+ */
+class CommandTest extends UnitTestCase
+{
+    /**
+     * @var bool Reset singletons created by subject
+     */
+    protected $resetSingletonInstances = true;
+
+    public function testIsCliOnly()
+    {
+        $commandController = GeneralUtility::makeInstance(ObjectManager::class)->get(
+            Command::class,
+            MockCCommandController::class,
+            'empty'
+        );
+
+        static::assertFalse($commandController->isCliOnly());
+
+        $commandController = GeneralUtility::makeInstance(ObjectManager::class)->get(
+            Command::class,
+            MockCCommandController::class,
+            'cliOnly'
+        );
+
+        static::assertTrue($commandController->isCliOnly());
+    }
+}
diff --git a/typo3/sysext/extbase/Tests/UnitDeprecated/Mvc/Cli/Fixture/Command/MockCCommandController.php b/typo3/sysext/extbase/Tests/UnitDeprecated/Mvc/Cli/Fixture/Command/MockCCommandController.php
new file mode 100644 (file)
index 0000000..d27b835
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+declare(strict_types = 1);
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+namespace TYPO3\CMS\Extbase\Tests\UnitDeprecated\Mvc\Cli\Fixture\Command;
+
+/**
+ * Another mock CLI Command
+ */
+class MockCCommandController extends \TYPO3\CMS\Extbase\Mvc\Cli\Command
+{
+    /**
+     * @cli
+     */
+    public function cliOnlyCommand()
+    {
+    }
+}
index b972138..72dbf9a 100644 (file)
@@ -48,7 +48,6 @@ class ExtensionCommandController extends CommandController
      * recognised extension folder paths in TYPO3.
      *
      * @param string $extensionKey
-     * @cli
      */
     public function installCommand($extensionKey)
     {
@@ -66,7 +65,6 @@ class ExtensionCommandController extends CommandController
      * recognised extension folder paths in TYPO3.
      *
      * @param string $extensionKey
-     * @cli
      */
     public function uninstallCommand($extensionKey)
     {
@@ -80,8 +78,6 @@ class ExtensionCommandController extends CommandController
      *
      * This command is only needed during development. The extension manager takes care
      * creating or updating this info properly during extension (de-)activation.
-     *
-     * @cli
      */
     public function dumpClassLoadingInformationCommand()
     {
index 3aafed7..b2d056f 100644 (file)
@@ -6,4 +6,9 @@ return [
             'Deprecation-83094-ReplaceIgnorevalidationWithTYPO3CMSExtbaseAnnotationIgnoreValidation.rst',
         ],
     ],
+    '@cli' => [
+        'restFiles' => [
+            'Deprecation-85977-DeprecateCliAnnotation.rst',
+        ],
+    ],
 ];