[TASK] Apply rector set php70 92/62592/3
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Tue, 10 Dec 2019 13:26:35 +0000 (14:26 +0100)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Thu, 19 Dec 2019 14:00:05 +0000 (15:00 +0100)
    php bin/rector process

The Rector\Php70\Rector\List_\ListSwapArrayOrderRector rector
has been disabled as this needs proper testing and a separate
patch.

Releases: master
Resolves: #89907
Change-Id: I56b296221622afdc72feb5a48145431efd993ea1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62592
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
25 files changed:
rector.yml
typo3/sysext/backend/Classes/Controller/SiteConfigurationController.php
typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInline.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Classes/Authentication/AbstractUserAuthentication.php
typo3/sysext/core/Classes/Collection/AbstractRecordCollection.php
typo3/sysext/core/Classes/Configuration/Richtext.php
typo3/sysext/core/Classes/Context/LanguageAspect.php
typo3/sysext/core/Classes/Domain/Repository/PageRepository.php
typo3/sysext/core/Classes/Mail/FileSpool.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
typo3/sysext/extensionmanager/Classes/Domain/Model/Mirrors.php
typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionListUtility.php
typo3/sysext/felogin/Classes/Controller/FrontendLoginController.php
typo3/sysext/fluid/Classes/Core/Widget/AjaxWidgetContextHolder.php
typo3/sysext/form/Classes/Domain/Runtime/FormRuntime.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/frontend/Classes/Hooks/TreelistCacheUpdateHooks.php
typo3/sysext/frontend/Tests/Functional/SiteHandling/EnhancerLinkGeneratorTest.php
typo3/sysext/frontend/Tests/Functional/SiteHandling/EnhancerSiteRequestTest.php
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php
typo3/sysext/impexp/Classes/ImportExport.php
typo3/sysext/install/Classes/Controller/UpgradeController.php

index a932b80..bb1ac73 100644 (file)
@@ -14,8 +14,10 @@ parameters:
       - 'class.ext_update.php'
   exclude_rectors:
     - Rector\Php55\Rector\String_\StringClassNameToClassConstantRector
+    - Rector\Php70\Rector\List_\ListSwapArrayOrderRector
   sets:
     - 'php53'
     - 'php54'
     - 'php55'
     - 'php56'
+    - 'php70'
index c9bee8f..4c91421 100644 (file)
@@ -357,7 +357,7 @@ class SiteConfigurationController
                 $this->siteFinder->getSiteByIdentifier($identifier);
                 // Force this identifier to be unique
                 $originalIdentifier = $identifier;
-                $identifier = $identifier . '-' . str_replace('.', '', uniqid((string)mt_rand(), true));
+                $identifier = $identifier . '-' . str_replace('.', '', uniqid((string)random_int(0, mt_getrandmax()), true));
                 $message = sprintf(
                     $languageService->sL('LLL:EXT:backend/Resources/Private/Language/locallang_siteconfiguration.xlf:validation.identifierRenamed.message'),
                     $originalIdentifier,
index f079333..14a57ce 100644 (file)
@@ -99,7 +99,7 @@ class TcaInline extends AbstractDatabaseRecordProvider implements FormDataProvid
             // If the parent is a page, use the uid(!) of the (new?) page as pid for the child records:
             if ($table === 'pages') {
                 $liveVersionId = BackendUtility::getLiveVersionIdOfRecord('pages', $row['uid']);
-                $pid = $liveVersionId === null ? $row['uid'] : $liveVersionId;
+                $pid = $liveVersionId ?? $row['uid'];
             } elseif ($row['pid'] < 0) {
                 $prevRec = BackendUtility::getRecord($table, abs($row['pid']));
                 $pid = $prevRec['pid'];
index bd1f9ba..5d5b64f 100644 (file)
@@ -2021,7 +2021,7 @@ class BackendUtility
         // If this field is a password field, then hide the password by changing it to a random number of asterisk (*)
         if (!empty($theColConf['eval']) && stripos($theColConf['eval'], 'password') !== false) {
             $l = '';
-            $randomNumber = rand(5, 12);
+            $randomNumber = random_int(5, 12);
             for ($i = 0; $i < $randomNumber; $i++) {
                 $l .= '*';
             }
index b97742b..b75abf1 100644 (file)
@@ -380,7 +380,7 @@ abstract class AbstractUserAuthentication implements LoggerAwareInterface
             GeneralUtility::callUserFunction($funcName, $_params, $this);
         }
         // If we're lucky we'll get to clean up old sessions
-        if (rand() % 100 <= $this->gc_probability) {
+        if (random_int(0, mt_getrandmax()) % 100 <= $this->gc_probability) {
             $this->gc();
         }
     }
index bae0b82..8437395 100644 (file)
@@ -354,7 +354,7 @@ abstract class AbstractRecordCollection implements RecordCollectionInterface, Pe
      */
     public function persist()
     {
-        $uid = $this->getIdentifier() == 0 ? 'NEW' . rand(100000, 999999) : $this->getIdentifier();
+        $uid = $this->getIdentifier() == 0 ? 'NEW' . random_int(100000, 999999) : $this->getIdentifier();
         $data = [
             trim(static::$storageTableName) => [
                 $uid => $this->getPersistableDataArray()
index 3563bb7..fa291d7 100644 (file)
@@ -128,7 +128,7 @@ class Richtext
                 }
                 $typoScriptArray[$key . '.'] = $this->convertPlainArrayToTypoScriptArray($value);
             } else {
-                $typoScriptArray[$key] = $value === null ? '' : $value;
+                $typoScriptArray[$key] = $value ?? '';
             }
         }
         return $typoScriptArray;
index 430b642..9c75db0 100644 (file)
@@ -90,7 +90,7 @@ class LanguageAspect implements AspectInterface
     {
         $this->overlayType = $overlayType;
         $this->id = $id;
-        $this->contentId = $contentId === null ? $this->id : $contentId;
+        $this->contentId = $contentId ?? $this->id;
         $this->fallbackChain = $fallbackChain;
     }
 
index d19d702..7138edd 100644 (file)
@@ -925,7 +925,7 @@ class PageRepository implements LoggerAwareInterface
                 $pageArray = $this->getMenu($idArray[0] ?: $thisUid, '*', 'sorting', 'AND pages.doktype<199 AND pages.doktype!=' . self::DOKTYPE_BE_USER_SECTION);
                 $pO = 0;
                 if ($shortcutMode == self::SHORTCUT_MODE_RANDOM_SUBPAGE && !empty($pageArray)) {
-                    $pO = (int)rand(0, count($pageArray) - 1);
+                    $pO = (int)random_int(0, count($pageArray) - 1);
                 }
                 $c = 0;
                 $page = [];
index 6e6dbdf..c842640 100644 (file)
@@ -195,7 +195,7 @@ class FileSpool extends AbstractTransport implements DelayedTransportInterface,
         $ret = '';
         $strlen = strlen($base);
         for ($i = 0; $i < $count; ++$i) {
-            $ret .= $base[((int)rand(0, $strlen - 1))];
+            $ret .= $base[((int)random_int(0, $strlen - 1))];
         }
 
         return $ret;
index 8a2c3ea..39d5d23 100644 (file)
@@ -3275,7 +3275,7 @@ class GeneralUtility
             $tempFileName = $temporaryPath . PathUtility::basename(tempnam($temporaryPath, $filePrefix));
         } else {
             do {
-                $tempFileName = $temporaryPath . $filePrefix . mt_rand(1, PHP_INT_MAX) . $fileSuffix;
+                $tempFileName = $temporaryPath . $filePrefix . random_int(1, PHP_INT_MAX) . $fileSuffix;
             } while (file_exists($tempFileName));
             touch($tempFileName);
             clearstatcache(null, $tempFileName);
index 2c2011c..57c43a1 100644 (file)
@@ -3203,7 +3203,7 @@ class GeneralUtilityTest extends UnitTestCase
 
         // set random values for mtime
         foreach ($structure as $structureLevel1Key => $structureLevel1Content) {
-            $newMtime = rand();
+            $newMtime = random_int(0, mt_getrandmax());
             if (is_array($structureLevel1Content)) {
                 foreach ($structureLevel1Content as $structureLevel2Key => $structureLevel2Content) {
                     touch($vfsUrl . '/' . $structureLevel1Key . '/' . $structureLevel2Key, $newMtime);
index e1c832d..e4388cd 100644 (file)
@@ -75,7 +75,7 @@ class Mirrors extends AbstractEntity
         $sumMirrors = count($this->mirrors);
         if ($sumMirrors > 0) {
             if (!is_int($this->currentMirror)) {
-                $this->currentMirror = rand(0, $sumMirrors - 1);
+                $this->currentMirror = random_int(0, $sumMirrors - 1);
             }
             return $this->mirrors[$this->currentMirror];
         }
index 79ada72..b41ea5b 100644 (file)
@@ -232,11 +232,11 @@ class ExtensionListUtility implements \SplObserver
             0,
             (int)$subject->getAlldownloadcounter(),
             (int)$subject->getDownloadcounter(),
-            $subject->getTitle() !== null ? $subject->getTitle() : '',
+            $subject->getTitle() ?? '',
             $subject->getOwnerusername(),
-            $subject->getAuthorname() !== null ? $subject->getAuthorname() : '',
-            $subject->getAuthoremail() !== null ? $subject->getAuthoremail() : '',
-            $subject->getAuthorcompany() !== null ? $subject->getAuthorcompany() : '',
+            $subject->getAuthorname() ?? '',
+            $subject->getAuthoremail() ?? '',
+            $subject->getAuthorcompany() ?? '',
             (int)$subject->getLastuploaddate(),
             $subject->getT3xfilemd5(),
             $this->repositoryUid,
index 9a29b06..db30705 100644 (file)
@@ -979,7 +979,7 @@ class FrontendLoginController extends AbstractPlugin
     {
         $pass = '';
         while ($len--) {
-            $char = rand(0, 35);
+            $char = random_int(0, 35);
             if ($char < 10) {
                 $pass .= '' . $char;
             } else {
index 348741f..d9897ed 100644 (file)
@@ -81,7 +81,7 @@ class AjaxWidgetContextHolder implements \TYPO3\CMS\Core\SingletonInterface
      */
     public function store(\TYPO3\CMS\Fluid\Core\Widget\WidgetContext $widgetContext)
     {
-        $ajaxWidgetId = md5(uniqid(mt_rand(), true));
+        $ajaxWidgetId = md5(uniqid(random_int(0, mt_getrandmax()), true));
         $widgetContext->setAjaxWidgetIdentifier($ajaxWidgetId);
         $this->widgetContexts[$ajaxWidgetId] = $widgetContext;
         $this->storeWidgetContexts();
index aaf9178..252f73d 100644 (file)
@@ -349,15 +349,15 @@ class FormRuntime implements RootRenderableInterface, \ArrayAccess
             }
 
             $elementsCount = count($this->currentPage->getElements());
-            $randomElementNumber = mt_rand(0, $elementsCount - 1);
-            $honeypotName = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 0, mt_rand(5, 26));
+            $randomElementNumber = random_int(0, $elementsCount - 1);
+            $honeypotName = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'), 0, random_int(5, 26));
 
             $referenceElement = $this->currentPage->getElements()[$randomElementNumber];
             $honeypotElement = $this->currentPage->createElement($honeypotName, $renderingOptions['honeypot']['formElementToUse']);
             $validator = $this->objectManager->get(EmptyValidator::class);
 
             $honeypotElement->addValidator($validator);
-            if (mt_rand(0, 1) === 1) {
+            if (random_int(0, 1) === 1) {
                 $this->currentPage->moveElementAfter($honeypotElement, $referenceElement);
             } else {
                 $this->currentPage->moveElementBefore($honeypotElement, $referenceElement);
index 3aeb208..787ec4f 100644 (file)
@@ -2998,7 +2998,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
         $last = '' . (count($temp) - 1);
         // Take a random item if requested
         if ($listNum === 'rand') {
-            $listNum = rand(0, count($temp) - 1);
+            $listNum = random_int(0, count($temp) - 1);
         }
         $index = $this->calc(str_ireplace('last', $last, $listNum));
         return $temp[$index];
index 3800513..13e3fe4 100644 (file)
@@ -2788,7 +2788,7 @@ class TypoScriptFrontendController implements LoggerAwareInterface
     protected function initializeSearchWordData($searchWords)
     {
         $this->sWordRegEx = '';
-        $this->sWordList = $searchWords === null ? '' : $searchWords;
+        $this->sWordList = $searchWords ?? '';
         if (is_array($this->sWordList)) {
             $space = !empty($this->config['config']['sword_standAlone'] ?? null) ? '[[:space:]]' : '';
             $regexpParts = [];
index e634a07..a39eaeb 100644 (file)
@@ -225,7 +225,7 @@ class TreelistCacheUpdateHooks
         }
         // From time to time clean the cache from expired entries
         // (theoretically every 1000 calls)
-        $randomNumber = rand(1, 1000);
+        $randomNumber = random_int(1, 1000);
         if ($randomNumber === 500) {
             $this->removeExpiredCacheEntries();
         }
index 885d9e3..866cab6 100644 (file)
@@ -134,8 +134,8 @@ class EnhancerLinkGeneratorTest extends AbstractTestCase
                 ];
             }
         }
-        $templatePrefix = isset($templateOptions['prefix']) ? $templateOptions['prefix'] : '';
-        $templateSuffix = isset($templateOptions['suffix']) ? $templateOptions['suffix'] : '';
+        $templatePrefix = $templateOptions['prefix'] ?? '';
+        $templateSuffix = $templateOptions['suffix'] ?? '';
         return $this->keysFromTemplate(
             $dataSet,
             $templatePrefix . 'enhancer:%1$s, lang:%3$d' . $templateSuffix,
index f1d8ee5..0659557 100644 (file)
@@ -141,8 +141,8 @@ class EnhancerSiteRequestTest extends AbstractTestCase
                 ];
             }
         }
-        $templatePrefix = isset($templateOptions['prefix']) ? $templateOptions['prefix'] : '';
-        $templateSuffix = isset($templateOptions['suffix']) ? $templateOptions['suffix'] : '';
+        $templatePrefix = $templateOptions['prefix'] ?? '';
+        $templateSuffix = $templateOptions['suffix'] ?? '';
         return $this->keysFromTemplate(
             $dataSet,
             $templatePrefix . 'enhancer:%1$s, lang:%3$d' . $templateSuffix,
index 462345b..03c5bea 100644 (file)
@@ -1607,7 +1607,7 @@ class ContentObjectRendererTest extends UnitTestCase
      */
     public function getDataWithTypePage(): void
     {
-        $uid = mt_rand();
+        $uid = random_int(0, mt_getrandmax());
         $GLOBALS['TSFE']->page['uid'] = $uid;
         self::assertEquals($uid, $this->subject->getData('page:uid'));
     }
@@ -1758,7 +1758,7 @@ class ContentObjectRendererTest extends UnitTestCase
      */
     public function getDataWithTypeParentRecordNumber(): void
     {
-        $recordNumber = mt_rand();
+        $recordNumber = random_int(0, mt_getrandmax());
         $this->subject->parentRecordNumber = $recordNumber;
         self::assertEquals($recordNumber, $this->subject->getData('cobj:parentRecordNumber'));
     }
@@ -1854,7 +1854,7 @@ class ContentObjectRendererTest extends UnitTestCase
      */
     public function getDataWithTypeDebugPage(): void
     {
-        $uid = mt_rand();
+        $uid = random_int(0, mt_getrandmax());
         $GLOBALS['TSFE']->page = ['uid' => $uid];
 
         $expectedResult = 'array(1item)uid=>' . $uid . '(integer)';
index 951fc4c..4ea1d36 100644 (file)
@@ -950,7 +950,7 @@ abstract class ImportExport
     {
         $temporaryPath = Environment::getVarPath() . '/transient/';
         do {
-            $temporaryFolderName = $temporaryPath . 'export_temp_files_' . mt_rand(1, PHP_INT_MAX);
+            $temporaryFolderName = $temporaryPath . 'export_temp_files_' . random_int(1, PHP_INT_MAX);
         } while (is_dir($temporaryFolderName));
         GeneralUtility::mkdir($temporaryFolderName);
         return $temporaryFolderName;
index a560b72..14cf4d1 100644 (file)
@@ -710,7 +710,7 @@ class UpgradeController extends AbstractController
         $preparedMatches = [];
         foreach ($matches as $match) {
             $preparedHit = [];
-            $preparedHit['uniqueId'] = str_replace('.', '', uniqid((string)mt_rand(), true));
+            $preparedHit['uniqueId'] = str_replace('.', '', uniqid((string)random_int(0, mt_getrandmax()), true));
             $preparedHit['message'] = $match['message'];
             $preparedHit['line'] = $match['line'];
             $preparedHit['indicator'] = $match['indicator'];
@@ -739,7 +739,7 @@ class UpgradeController extends AbstractController
                 array_pop($version);
                 // something like "8.2" .. "8.7" .. "master"
                 $parsedRestFile['version'] = array_pop($version);
-                $parsedRestFile['uniqueId'] = str_replace('.', '', uniqid((string)mt_rand(), true));
+                $parsedRestFile['uniqueId'] = str_replace('.', '', uniqid((string)random_int(0, mt_getrandmax()), true));
                 $preparedHit['restFiles'][] = $parsedRestFile;
             }
             $preparedMatches[] = $preparedHit;