[TASK] Apply rector sets php54 and php55 39/62439/4
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Wed, 27 Nov 2019 17:44:39 +0000 (18:44 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Fri, 29 Nov 2019 12:36:15 +0000 (13:36 +0100)
    php bin/rector process

Both sets php54 and php55 have been applied at the
same time because set php54 didn't result in any
changes.

Releases: master
Resolves: #89789
Change-Id: Idddc487b34abceb300a237bd458659a10db54469
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62439
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Susanne Moog <look@susi.dev>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Susanne Moog <look@susi.dev>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
25 files changed:
rector.yml
typo3/sysext/core/Classes/Localization/Parser/AbstractXmlParser.php
typo3/sysext/core/Classes/Localization/Parser/LocallangXmlParser.php
typo3/sysext/core/Classes/Type/File/ImageInfo.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/extbase/Classes/Object/ObjectManager.php
typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php
typo3/sysext/extbase/Classes/Persistence/Generic/PropertyType.php
typo3/sysext/extbase/Classes/Property/TypeConverter/DateTimeConverter.php
typo3/sysext/extbase/Classes/Utility/DebuggerUtility.php
typo3/sysext/extbase/Classes/Utility/TypeHandlingUtility.php
typo3/sysext/extensionmanager/Classes/Utility/Parser/ExtensionXmlPullParser.php
typo3/sysext/extensionmanager/Classes/Utility/Parser/MirrorXmlPullParser.php
typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetViewHelper.php
typo3/sysext/form/Classes/Domain/Model/FormElements/Date.php
typo3/sysext/form/Classes/Domain/Model/FormElements/DatePicker.php
typo3/sysext/form/Classes/Domain/Model/FormElements/FileUpload.php
typo3/sysext/form/Classes/ViewHelpers/Form/DatePickerViewHelper.php
typo3/sysext/form/Classes/ViewHelpers/Form/TimePickerViewHelper.php
typo3/sysext/install/Classes/ExtensionScanner/Php/GeneratorClassesResolver.php
typo3/sysext/install/Classes/Updates/BackendUserConfigurationUpdate.php
typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php
typo3/sysext/scheduler/Classes/Scheduler.php
typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php
typo3/sysext/workspaces/Classes/Service/WorkspaceService.php

index 8c9aef0..322a93c 100644 (file)
@@ -1,3 +1,11 @@
+services:
+  # php55
+  Rector\Php55\Rector\String_\StringClassNameToClassConstantRector:
+    $classesToSkip:
+      - Error
+      - Locale
+      - mysqli
+
 parameters:
   php_version_features: '7.2'
   auto_import_names: false
@@ -5,3 +13,5 @@ parameters:
     - 'typo3/sysext/*/Classes/'
   sets:
     - 'php53'
+    - 'php54'
+#    - 'php55' # disabled and configured manually via services.
index 7ea8935..4519e0c 100644 (file)
@@ -74,7 +74,7 @@ abstract class AbstractXmlParser implements LocalizationParserInterface
         $xmlContent = file_get_contents($this->sourcePath);
         // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
         $previousValueOfEntityLoader = libxml_disable_entity_loader(true);
-        $rootXmlNode = simplexml_load_string($xmlContent, 'SimpleXMLElement', LIBXML_NOWARNING);
+        $rootXmlNode = simplexml_load_string($xmlContent, \SimpleXMLElement::class, LIBXML_NOWARNING);
         libxml_disable_entity_loader($previousValueOfEntityLoader);
         if (!isset($rootXmlNode) || $rootXmlNode === false) {
             $xmlError = libxml_get_last_error();
index 5e04735..93d47ea 100644 (file)
@@ -183,7 +183,7 @@ class LocallangXmlParser extends AbstractXmlParser
             $xmlContent = file_get_contents($targetPath);
             // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
             $previousValueOfEntityLoader = libxml_disable_entity_loader(true);
-            $rootXmlNode = simplexml_load_string($xmlContent, 'SimpleXMLElement', LIBXML_NOWARNING);
+            $rootXmlNode = simplexml_load_string($xmlContent, \SimpleXMLElement::class, LIBXML_NOWARNING);
             libxml_disable_entity_loader($previousValueOfEntityLoader);
         }
         if (!isset($rootXmlNode) || $rootXmlNode === false) {
index efcc097..6ec48fe 100644 (file)
@@ -120,7 +120,7 @@ class ImageInfo extends FileInfo implements LoggerAwareInterface
         $fileContent = file_get_contents($this->getPathname());
         // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
         $previousValueOfEntityLoader = libxml_disable_entity_loader(true);
-        $xml = simplexml_load_string($fileContent, 'SimpleXMLElement', LIBXML_NOERROR | LIBXML_NOWARNING);
+        $xml = simplexml_load_string($fileContent, \SimpleXMLElement::class, LIBXML_NOERROR | LIBXML_NOWARNING);
 
         // If something went wrong with simpleXml don't try to read information
         if ($xml === false) {
index dd4fd64..9e4f6e6 100644 (file)
@@ -3173,9 +3173,9 @@ class GeneralUtility
      */
     public static function upload_copy_move($source, $destination)
     {
-        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Core\Utility\GeneralUtility']['moveUploadedFile'] ?? null)) {
+        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Utility\GeneralUtility::class]['moveUploadedFile'] ?? null)) {
             $params = ['source' => $source, 'destination' => $destination, 'method' => 'upload_copy_move'];
-            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Core\Utility\GeneralUtility']['moveUploadedFile'] as $hookMethod) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Utility\GeneralUtility::class]['moveUploadedFile'] as $hookMethod) {
                 $fakeThis = false;
                 self::callUserFunction($hookMethod, $params, $fakeThis);
             }
@@ -3210,9 +3210,9 @@ class GeneralUtility
     {
         if (is_uploaded_file($uploadedFileName)) {
             $tempFile = self::tempnam('upload_temp_');
-            if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Core\Utility\GeneralUtility']['moveUploadedFile'] ?? null)) {
+            if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Utility\GeneralUtility::class]['moveUploadedFile'] ?? null)) {
                 $params = ['source' => $uploadedFileName, 'destination' => $tempFile, 'method' => 'upload_to_tempfile'];
-                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\CMS\Core\Utility\GeneralUtility']['moveUploadedFile'] as $hookMethod) {
+                foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Utility\GeneralUtility::class]['moveUploadedFile'] as $hookMethod) {
                     $fakeThis = false;
                     self::callUserFunction($hookMethod, $params, $fakeThis);
                 }
@@ -3346,7 +3346,7 @@ class GeneralUtility
     public static function callUserFunction($funcName, &$params, &$ref)
     {
         // Check if we're using a closure and invoke it directly.
-        if (is_object($funcName) && is_a($funcName, 'Closure')) {
+        if (is_object($funcName) && is_a($funcName, \Closure::class)) {
             return call_user_func_array($funcName, [&$params, &$ref]);
         }
         $funcName = trim($funcName);
index 72f0c26..b224e66 100644 (file)
@@ -108,7 +108,7 @@ class ObjectManager implements ObjectManagerInterface
      */
     public function get(string $objectName, ...$constructorArguments): object
     {
-        if ($objectName === 'DateTime') {
+        if ($objectName === \DateTime::class) {
             return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($objectName, ...$constructorArguments);
         }
 
index 5494f81..76ca311 100644 (file)
@@ -258,7 +258,7 @@ class DataMapper
                     case 'array':
                         // $propertyValue = $this->mapArray($row[$columnName]); // Not supported, yet!
                         break;
-                    case 'SplObjectStorage':
+                    case \SplObjectStorage::class:
                     case Persistence\ObjectStorage::class:
                         $propertyValue = $this->mapResultToPropertyValue(
                             $object,
@@ -560,12 +560,12 @@ class DataMapper
             $propertyValue = $result;
         } else {
             $property = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName);
-            if (in_array($property->getType(), ['array', 'ArrayObject', 'SplObjectStorage', Persistence\ObjectStorage::class], true)) {
+            if (in_array($property->getType(), ['array', \ArrayObject::class, \SplObjectStorage::class, Persistence\ObjectStorage::class], true)) {
                 $objects = [];
                 foreach ($result as $value) {
                     $objects[] = $value;
                 }
-                if ($property->getType() === 'ArrayObject') {
+                if ($property->getType() === \ArrayObject::class) {
                     $propertyValue = new \ArrayObject($objects);
                 } elseif ($property->getType() === Persistence\ObjectStorage::class) {
                     $propertyValue = new Persistence\ObjectStorage();
index d4d1399..80ee6a7 100644 (file)
@@ -185,7 +185,7 @@ class PropertyType
     /**
      * String constant for type name as used in serialization.
      */
-    const TYPENAME_WEAKREFERENCE = 'WeakReference';
+    const TYPENAME_WEAKREFERENCE = \WeakReference::class;
 
     /**
      * String constant for type name as used in serialization.
index f1feed0..6f54380 100644 (file)
@@ -77,7 +77,7 @@ class DateTimeConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\Abstra
     /**
      * @var string
      */
-    protected $targetType = 'DateTime';
+    protected $targetType = \DateTime::class;
 
     /**
      * @var int
index 3ffa8a7..25efe68 100644 (file)
@@ -408,7 +408,7 @@ class DebuggerUtility
                     $dump .= '<span class="extbase-debug-closure">}</span>';
                 }
             } else {
-                if (get_class($object) === 'stdClass') {
+                if (get_class($object) === \stdClass::class) {
                     $objReflection = new \ReflectionObject($object);
                     $properties = $objReflection->getProperties();
                 } else {
index afa4583..e4ef324 100644 (file)
@@ -32,7 +32,7 @@ class TypeHandlingUtility
     /**
      * @var array
      */
-    protected static $collectionTypes = ['array', 'ArrayObject', 'SplObjectStorage', \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class];
+    protected static $collectionTypes = ['array', \ArrayObject::class, \SplObjectStorage::class, \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class];
 
     /**
      * Returns an array with type information, including element type for
index 0d56611..d106c21 100644 (file)
@@ -48,7 +48,7 @@ class ExtensionXmlPullParser extends AbstractExtensionXmlParser
     public function parseXml($file)
     {
         $this->createParser();
-        if (!(is_object($this->objXml) && get_class($this->objXml) === 'XMLReader')) {
+        if (!(is_object($this->objXml) && get_class($this->objXml) === \XMLReader::class)) {
             throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Unable to create XML parser.', 1342640540);
         }
         if ($this->objXml->open($file, 'utf-8') === false) {
index b220fee..6eb5c99 100644 (file)
@@ -45,7 +45,7 @@ class MirrorXmlPullParser extends AbstractMirrorXmlParser
     public function parseXml($file)
     {
         $this->createParser();
-        if (!(is_object($this->objXml) && get_class($this->objXml) === 'XMLReader')) {
+        if (!(is_object($this->objXml) && get_class($this->objXml) === \XMLReader::class)) {
             throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException('Unable to create XML parser.', 1342640820);
         }
         if ($this->objXml->open($file, 'utf-8') === false) {
index cd56056..6464ec4 100644 (file)
@@ -182,7 +182,7 @@ abstract class AbstractWidgetViewHelper extends AbstractViewHelper
         if (!isset($this->controller) || !$this->controller instanceof \TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetController) {
             throw new \TYPO3\CMS\Fluid\Core\Widget\Exception\MissingControllerException(
                 'initiateSubRequest() can not be called if there is no valid controller extending ' .
-                'TYPO3\\CMS\\Fluid\\Core\\Widget\\AbstractWidgetController' .
+                \TYPO3\CMS\Fluid\Core\Widget\AbstractWidgetController::class .
                 ' Got "' . ($this->controller ? get_class($this->controller) : gettype($this->controller)) .
                 '" in class "' . static::class . '".',
                 1289422564
index c4d9dcf..360e845 100644 (file)
@@ -31,7 +31,7 @@ class Date extends AbstractFormElement implements StringableFormElementInterface
      */
     public function initializeFormElement()
     {
-        $this->setDataType('DateTime');
+        $this->setDataType(\DateTime::class);
         parent::initializeFormElement();
     }
 
index 14bc841..71f0bb8 100644 (file)
@@ -31,7 +31,7 @@ class DatePicker extends AbstractFormElement implements StringableFormElementInt
      */
     public function initializeFormElement()
     {
-        $this->setDataType('DateTime');
+        $this->setDataType(\DateTime::class);
         parent::initializeFormElement();
     }
 
index 87c7def..f13e899 100644 (file)
@@ -29,7 +29,7 @@ class FileUpload extends AbstractFormElement
      */
     public function initializeFormElement()
     {
-        $this->setDataType('TYPO3\CMS\Extbase\Domain\Model\FileReference');
+        $this->setDataType(\TYPO3\CMS\Extbase\Domain\Model\FileReference::class);
         parent::initializeFormElement();
     }
 }
index 271e9f4..c1df915 100644 (file)
@@ -132,7 +132,7 @@ class DatePickerViewHelper extends AbstractFormFieldViewHelper
             return $date;
         }
         if ($date !== null) {
-            $date = $this->propertyMapper->convert($date, 'DateTime');
+            $date = $this->propertyMapper->convert($date, \DateTime::class);
             if (!$date instanceof \DateTime) {
                 return null;
             }
index 4f3d445..99f0b88 100644 (file)
@@ -105,7 +105,7 @@ class TimePickerViewHelper extends AbstractFormFieldViewHelper
             return $date;
         }
         if ($date !== null) {
-            $date = $this->propertyMapper->convert($date, 'DateTime');
+            $date = $this->propertyMapper->convert($date, \DateTime::class);
             if (!$date instanceof \DateTime) {
                 return null;
             }
index 52a44ec..92319ec 100644 (file)
@@ -42,7 +42,7 @@ class GeneratorClassesResolver extends NodeVisitorAbstract
     {
         if ($node instanceof StaticCall
             && $node->class instanceof FullyQualified
-            && $node->class->toString() === 'TYPO3\CMS\Core\Utility\GeneralUtility'
+            && $node->class->toString() === \TYPO3\CMS\Core\Utility\GeneralUtility::class
             && $node->name->name === 'makeInstance'
             && isset($node->args[0]->value)
             && $node->args[0]->value instanceof String_
index 908949e..801e302 100644 (file)
@@ -119,7 +119,7 @@ class BackendUserConfigurationUpdate implements UpgradeWizardInterface
 
     private function unserializeUserConfig(string $userConfig)
     {
-        return unserialize($userConfig, ['allowed_classes' => ['stdClass']]);
+        return unserialize($userConfig, ['allowed_classes' => [\stdClass::class]]);
     }
 
     private function getAffectedBackendUsers(): iterable
index 5c0ab4a..7ee5ddd 100644 (file)
@@ -871,7 +871,7 @@ class SchedulerModuleController
                 /** @var \TYPO3\CMS\Scheduler\Task\AbstractTask|ProgressProviderInterface $task */
                 $task = unserialize($schedulerRecord['serialized_task_object']);
                 $class = get_class($task);
-                if ($class === '__PHP_Incomplete_Class' && preg_match('/^O:[0-9]+:"(?P<classname>.+?)"/', $schedulerRecord['serialized_task_object'], $matches) === 1) {
+                if ($class === \__PHP_Incomplete_Class::class && preg_match('/^O:[0-9]+:"(?P<classname>.+?)"/', $schedulerRecord['serialized_task_object'], $matches) === 1) {
                     $class = $matches['classname'];
                 }
                 $tasks[$taskIndex]['tasks'][$recordIndex]['class'] = $class;
index e435f95..a788ce1 100644 (file)
@@ -450,7 +450,7 @@ class Scheduler implements SingletonInterface, LoggerAwareInterface
      */
     public function isValidTaskObject($task)
     {
-        return $task instanceof Task\AbstractTask && get_class($task->getExecution()) !== '__PHP_Incomplete_Class';
+        return $task instanceof Task\AbstractTask && get_class($task->getExecution()) !== \__PHP_Incomplete_Class::class;
     }
 
     /**
index 8c9272d..55dd1cc 100644 (file)
@@ -395,7 +395,7 @@ class TypoScriptTemplateModuleController
         } else {
             $urlParameters['e'] = ['constants' => 1];
         }
-        $urlParameters['SET'] = ['function' => 'TYPO3\\CMS\\Tstemplate\\Controller\\TypoScriptTemplateInformationModuleFunctionController'];
+        $urlParameters['SET'] = ['function' => \TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController::class];
         $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
         $url = (string)$uriBuilder->buildUriFromRoute('web_ts', $urlParameters);
         return '<a href="' . htmlspecialchars($url) . '">' . htmlspecialchars($title) . '</a>';
index d158948..8faa0b3 100644 (file)
@@ -799,7 +799,7 @@ class WorkspaceService implements SingletonInterface
             'pageId' => $pageId,
             'versionsOnPageCache' => &$this->versionsOnPageCache,
         ];
-        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService']['hasPageRecordVersions'] ?? [] as $hookFunction) {
+        foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Workspaces\Service\WorkspaceService::class]['hasPageRecordVersions'] ?? [] as $hookFunction) {
             GeneralUtility::callUserFunction($hookFunction, $parameters, $this);
         }
 
@@ -936,7 +936,7 @@ class WorkspaceService implements SingletonInterface
                 'tableName' => $tableName,
                 'pagesWithVersionsInTable' => &$this->pagesWithVersionsInTable,
             ];
-            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['TYPO3\\CMS\\Workspaces\\Service\\WorkspaceService']['fetchPagesWithVersionsInTable'] ?? [] as $hookFunction) {
+            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Workspaces\Service\WorkspaceService::class]['fetchPagesWithVersionsInTable'] ?? [] as $hookFunction) {
                 GeneralUtility::callUserFunction($hookFunction, $parameters, $this);
             }
         }