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

[TASK] Require rector/rector

    composer require --dev rector/rector:"^0.5.0"

This commit introduces the requirement to rector/rector to
automatically process code changes by given set of rules.

To make this commit more meaningful, a first set "php53"
has been processed.

Releases: master
Resolves: #89785
Change-Id: I6e2ff9654266458ae9fb6800547ff4712b0b66d8
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62437

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
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: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent ba50c94e
......@@ -5,6 +5,7 @@
/.travis.yml export-ignore
/Build/ export-ignore
/dynamicReturnTypeMeta.json export-ignore
/rector.yml export-ignore
/typo3/sysext/*/Resources/Private/TypeScript/ export-ignore
/typo3/sysext/*/Tests/ export-ignore
/components/testing_framework/ export-ignore
......
This diff is collapsed.
parameters:
php_version_features: '7.2'
auto_import_names: false
paths:
- 'typo3/sysext/*/Classes/'
sets:
- 'php53'
......@@ -858,7 +858,7 @@ class Clipboard
*/
public function elFromTable($matchTable = '', $pad = '')
{
$pad = $pad ? $pad : $this->current;
$pad = $pad ?: $this->current;
$list = [];
if (is_array($this->clipData[$pad]['el'] ?? false)) {
foreach ($this->clipData[$pad]['el'] as $k => $v) {
......
......@@ -123,7 +123,7 @@ class MoveElementController
$this->table = $parsedBody['table'] ?? $queryParams['table'] ?? null;
$this->R_URI = GeneralUtility::sanitizeLocalUrl($parsedBody['returnUrl'] ?? $queryParams['returnUrl'] ?? '');
$this->input_moveUid = $parsedBody['moveUid'] ?? $queryParams['moveUid'] ?? null;
$this->moveUid = $this->input_moveUid ? $this->input_moveUid : $this->page_id;
$this->moveUid = $this->input_moveUid ?: $this->page_id;
$this->makeCopy = $parsedBody['makeCopy'] ?? $queryParams['makeCopy'] ?? 0;
// Select-pages where clause for read-access:
$this->perms_clause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW);
......
......@@ -194,7 +194,7 @@ class SuggestWizardDefaultReceiver
$entry = [
'text' => '<span class="suggest-label">' . $label . '</span><span class="suggest-uid">[' . $uid . ']</span><br />
<span class="suggest-path">' . $croppedPath . '</span>',
'table' => $this->mmForeignTable ? $this->mmForeignTable : $this->table,
'table' => $this->mmForeignTable ?: $this->table,
'label' => strip_tags($label),
'path' => $path,
'uid' => $uid,
......@@ -384,7 +384,7 @@ class SuggestWizardDefaultReceiver
{
// Check for workspace-versions
if ($GLOBALS['BE_USER']->workspace != 0 && BackendUtility::isTableWorkspaceEnabled($this->table)) {
BackendUtility::workspaceOL($this->mmForeignTable ? $this->mmForeignTable : $this->table, $row);
BackendUtility::workspaceOL($this->mmForeignTable ?: $this->table, $row);
}
}
......@@ -401,7 +401,7 @@ class SuggestWizardDefaultReceiver
protected function getRecordPath(&$row, $uid)
{
$titleLimit = max($this->config['maxPathTitleLength'], 0);
if (($this->mmForeignTable ? $this->mmForeignTable : $this->table) === 'pages') {
if (($this->mmForeignTable ?: $this->table) === 'pages') {
$path = BackendUtility::getRecordPath($uid, '', $titleLimit);
// For pages we only want the first (n-1) parts of the path,
// because the n-th part is the page itself
......@@ -420,7 +420,7 @@ class SuggestWizardDefaultReceiver
*/
protected function getLabel($row)
{
return BackendUtility::getRecordTitle($this->mmForeignTable ? $this->mmForeignTable : $this->table, $row, true);
return BackendUtility::getRecordTitle($this->mmForeignTable ?: $this->table, $row, true);
}
/**
......
......@@ -172,7 +172,7 @@ class PageTsBackendLayoutDataProvider implements DataProviderInterface
{
if (!empty($data['config.']['backend_layout.']) && is_array($data['config.']['backend_layout.'])) {
$backendLayout['uid'] = substr($identifier, 0, -1);
$backendLayout['title'] = $data['title'] ? $data['title'] : $backendLayout['uid'];
$backendLayout['title'] = $data['title'] ?: $backendLayout['uid'];
$backendLayout['icon'] = $data['icon'] ?: '';
// Convert PHP array back to plain TypoScript so it can be processed
$config = \TYPO3\CMS\Core\Utility\ArrayUtility::flatten($data['config.']);
......
......@@ -355,7 +355,7 @@ function jumpToUrl(URL) {
*/
public function redirectUrls($thisLocation = '')
{
$thisLocation = $thisLocation ? $thisLocation : GeneralUtility::linkThisScript([
$thisLocation = $thisLocation ?: GeneralUtility::linkThisScript([
'CB' => '',
'SET' => '',
'cmd' => '',
......
......@@ -643,7 +643,7 @@ class ModuleTemplate
*/
public function redirectUrls($thisLocation = '')
{
$thisLocation = $thisLocation ? $thisLocation : GeneralUtility::linkThisScript([
$thisLocation = $thisLocation ?: GeneralUtility::linkThisScript([
'CB' => '',
'SET' => '',
'cmd' => '',
......
......@@ -1221,7 +1221,7 @@ class PageLayoutView implements LoggerAwareInterface
if (!empty($elFromTable) && $this->isPageEditable()) {
$pasteItem = substr(key($elFromTable), 11);
$pasteRecord = BackendUtility::getRecord('tt_content', (int)$pasteItem);
$pasteTitle = $pasteRecord['header'] ? $pasteRecord['header'] : $pasteItem;
$pasteTitle = $pasteRecord['header'] ?: $pasteItem;
$copyMode = $this->clipboard->clipData['normal']['mode'] ? '-' . $this->clipboard->clipData['normal']['mode'] : '';
$addExtOnReadyCode = '
top.pasteIntoLinkTemplate = '
......@@ -1621,7 +1621,7 @@ class PageLayoutView implements LoggerAwareInterface
{
foreach ($fieldArr as $fieldName) {
$ll = htmlspecialchars($this->getLanguageService()->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label']));
$out[$fieldName] = $ll ? $ll : '&nbsp;';
$out[$fieldName] = $ll ?: '&nbsp;';
}
return $out;
}
......@@ -1805,7 +1805,7 @@ class PageLayoutView implements LoggerAwareInterface
$f2 = substr($field, 6);
if ($GLOBALS['TCA'][$f2]) {
$c = $this->numberOfRecords($f2, $row['uid']);
$theData[$field] = ($c ? $c : '');
$theData[$field] = ($c ?: '');
}
} else {
$theData[$field] = $this->getPagesTableFieldValue($field, $row);
......@@ -1981,7 +1981,7 @@ class PageLayoutView implements LoggerAwareInterface
$value = 1;
$label = 'hide';
}
$params = '&data[tt_content][' . ($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid'])
$params = '&data[tt_content][' . ($row['_ORIG_uid'] ?: $row['uid'])
. '][' . $hiddenField . ']=' . $value;
$out .= '<a class="btn btn-default" href="' . htmlspecialchars(BackendUtility::getLinkToDataHandlerAction($params))
. '#element-tt_content-' . $row['uid'] . '" title="' . htmlspecialchars($this->getLanguageService()->getLL($label)) . '">'
......@@ -3194,7 +3194,7 @@ class PageLayoutView implements LoggerAwareInterface
<input class="form-control" type="number" min="0" max="10000" placeholder="10" title="' . htmlspecialchars(
$lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.title.limit')
) . '" name="showLimit" id="showLimit" value="' . htmlspecialchars(
($this->showLimit ? $this->showLimit : '')
($this->showLimit ?: '')
) . '" />
</div>
<div class="form-group col-xs-12">
......
......@@ -1054,7 +1054,7 @@ class DataHandler implements LoggerAwareInterface
}
// Here the "pid" is set IF NOT the old pid was a string pointing to a place in the subst-id array.
list($tscPID) = BackendUtility::getTSCpid($table, $id, $old_pid_value ? $old_pid_value : $fieldArray['pid']);
list($tscPID) = BackendUtility::getTSCpid($table, $id, $old_pid_value ?: $fieldArray['pid']);
if ($status === 'new' && $table === 'pages') {
$TSConfig = BackendUtility::getPagesTSconfig($tscPID)['TCEMAIN.'] ?? [];
if (isset($TSConfig['permissions.']) && is_array($TSConfig['permissions.'])) {
......@@ -5886,7 +5886,7 @@ class DataHandler implements LoggerAwareInterface
$origValueArray = is_array($value) ? $value : explode(',', $value);
// Update the uids of the copied records, but also take care about new records:
foreach ($origValueArray as $childId) {
$newValueArray[] = $this->autoVersionIdMap[$foreignTable][$childId] ? $this->autoVersionIdMap[$foreignTable][$childId] : $childId;
$newValueArray[] = $this->autoVersionIdMap[$foreignTable][$childId] ?: $childId;
}
// Set the changed value to the $incomingFieldArray
$incomingFieldArray[$field] = implode(',', $newValueArray);
......
......@@ -285,7 +285,7 @@ class QueryGenerator
if (is_array($GLOBALS['TCA'][$table])) {
$this->name = $name;
$this->table = $table;
$this->fieldList = $fieldList ? $fieldList : $this->makeFieldList();
$this->fieldList = $fieldList ?: $this->makeFieldList();
$fieldArr = GeneralUtility::trimExplode(',', $this->fieldList, true);
foreach ($fieldArr as $fieldName) {
$fC = $GLOBALS['TCA'][$this->table]['columns'][$fieldName];
......
......@@ -1154,8 +1154,7 @@ class QueryView
) {
if ($this->settings['search_result_labels']) {
$title = $this->languageService->sL($conf['columns'][$fieldName]['label']
? $conf['columns'][$fieldName]['label']
: $fieldName);
?: $fieldName);
} else {
$title = $this->languageService->sL($fieldName);
}
......@@ -1190,8 +1189,7 @@ class QueryView
$out .= htmlspecialchars(
$this->languageService->sL(
$conf['columns'][$fieldName]['label']
? $conf['columns'][$fieldName]['label']
: $fieldName
?: $fieldName
)
);
} else {
......
......@@ -1055,8 +1055,8 @@ class GraphicalFunctions
if ($c + 1 < count($explodedParts)) {
$newResult[] = [
'str' => $cfg['value'],
'fontSize' => $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'],
'fontFile' => $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'],
'fontSize' => $cfg['fontSize'] ?: $part['fontSize'],
'fontFile' => $cfg['fontFile'] ?: $part['fontFile'],
'color' => $cfg['color'],
'xSpaceBefore' => $cfg['xSpaceBefore'],
'xSpaceAfter' => $cfg['xSpaceAfter'],
......
......@@ -307,7 +307,7 @@ class Folder implements FolderInterface
*/
public function addFile($localFilePath, $fileName = null, $conflictMode = DuplicationBehavior::CANCEL)
{
$fileName = $fileName ? $fileName : PathUtility::basename($localFilePath);
$fileName = $fileName ?: PathUtility::basename($localFilePath);
return $this->storage->addFile($localFilePath, $this, $fileName, $conflictMode);
}
......
......@@ -1068,7 +1068,7 @@ class ExtendedTemplateService extends TemplateService
$p_field =
'<input type="hidden" name="' . $fN . '" value="0" />'
. '<label class="btn btn-default btn-checkbox">'
. '<input id="' . $idName . '" type="checkbox" name="' . $fN . '" value="' . ($typeDat['paramstr'] ? $typeDat['paramstr'] : 1) . '" ' . $sel . ' onClick="uFormUrl(' . $aname . ')" />'
. '<input id="' . $idName . '" type="checkbox" name="' . $fN . '" value="' . ($typeDat['paramstr'] ?: 1) . '" ' . $sel . ' onClick="uFormUrl(' . $aname . ')" />'
. '<span class="t3-icon fa"></span>'
. '</label>';
break;
......@@ -1391,7 +1391,7 @@ class ExtendedTemplateService extends TemplateService
break;
case 'boolean':
if ($var) {
$var = $typeDat['paramstr'] ? $typeDat['paramstr'] : 1;
$var = $typeDat['paramstr'] ?: 1;
}
break;
}
......
......@@ -615,7 +615,7 @@ class FrontendLoginController extends AbstractPlugin
$extraHiddenAr = [];
// Check for referer redirect method. if present, save referer in form field
if (GeneralUtility::inList($this->conf['redirectMode'], 'referer') || GeneralUtility::inList($this->conf['redirectMode'], 'refererDomains')) {
$referer = $this->referer ? $this->referer : GeneralUtility::getIndpEnv('HTTP_REFERER');
$referer = $this->referer ?: GeneralUtility::getIndpEnv('HTTP_REFERER');
if ($referer) {
$extraHiddenAr[] = '<input type="hidden" name="referer" value="' . htmlspecialchars($referer) . '" />';
if ($this->piVars['redirectReferrer'] === 'off') {
......
......@@ -5361,7 +5361,7 @@ class ContentObjectRenderer implements LoggerAwareInterface
$spamProtectedMailAddress = str_replace('@', $atLabel, htmlspecialchars($mailAddress));
if ($tsfe->config['config']['spamProtectEmailAddresses_lastDotSubst']) {
$lastDotLabel = trim($tsfe->config['config']['spamProtectEmailAddresses_lastDotSubst']);
$lastDotLabel = $lastDotLabel ? $lastDotLabel : '(dot)';
$lastDotLabel = $lastDotLabel ?: '(dot)';
$spamProtectedMailAddress = preg_replace('/\\.([^\\.]+)$/', $lastDotLabel . '$1', $spamProtectedMailAddress);
}
$linktxt = str_ireplace($mailAddress, $spamProtectedMailAddress, $linktxt);
......
......@@ -382,7 +382,7 @@ abstract class AbstractMenuContentObject
$c_b = 0;
$minItems = (int)($this->mconf['minItems'] ?: $this->conf['minItems']);
$maxItems = (int)($this->mconf['maxItems'] ?: $this->conf['maxItems']);
$begin = $this->parent_cObj->calc($this->mconf['begin'] ? $this->mconf['begin'] : $this->conf['begin']);
$begin = $this->parent_cObj->calc($this->mconf['begin'] ?: $this->conf['begin']);
$minItemsConf = $this->mconf['minItems.'] ?? $this->conf['minItems.'] ?? null;
$minItems = is_array($minItemsConf) ? $this->parent_cObj->stdWrap($minItems, $minItemsConf) : $minItems;
$maxItemsConf = $this->mconf['maxItems.'] ?? $this->conf['maxItems.'] ?? null;
......@@ -668,7 +668,7 @@ abstract class AbstractMenuContentObject
if ($mount_info['overlay']) {
// Overlays should already have their full MPvars calculated:
$MP = $pageLinkBuilder->getMountPointParameterFromRootPointMaps((int)$mount_info['mount_pid']);
$MP = $MP ? $MP : $mount_info['MPvar'];
$MP = $MP ?: $mount_info['MPvar'];
} else {
$MP = ($MP ? $MP . ',' : '') . $mount_info['MPvar'];
}
......@@ -876,7 +876,7 @@ abstract class AbstractMenuContentObject
} else {
// The page record of the 'value'.
$value_rec = $this->sys_page->getPage($specialValue);
$kfieldSrc = $this->conf['special.']['keywordsField.']['sourceField'] ? $this->conf['special.']['keywordsField.']['sourceField'] : 'keywords';
$kfieldSrc = $this->conf['special.']['keywordsField.']['sourceField'] ?: 'keywords';
// keywords.
$kw = trim($this->parent_cObj->keywords($value_rec[$kfieldSrc]));
}
......
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