Commit ec192807 authored by Alexander Schnitzler's avatar Alexander Schnitzler Committed by Andreas Fernandez
Browse files

[TASK] Apply rector set php70

    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: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Oliver Klee's avatarOliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 41d48e24
......@@ -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'
......@@ -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,
......
......@@ -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'];
......
......@@ -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 .= '*';
}
......
......@@ -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();
}
}
......
......@@ -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()
......
......@@ -128,7 +128,7 @@ class Richtext
}
$typoScriptArray[$key . '.'] = $this->convertPlainArrayToTypoScriptArray($value);
} else {
$typoScriptArray[$key] = $value === null ? '' : $value;
$typoScriptArray[$key] = $value ?? '';
}
}
return $typoScriptArray;
......
......@@ -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;
}
......
......@@ -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 = [];
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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];
}
......
......@@ -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,
......
......@@ -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 {
......
......@@ -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();
......
......@@ -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);
......
......@@ -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];
......
......@@ -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 = [];
......
......@@ -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();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment