Commit 4e457d36 authored by Wouter Wolters's avatar Wouter Wolters Committed by Benni Mack
Browse files

[TASK] Update php-cs-fixer to 2.5.0

Add 2 new rules

* no_superfluous_elseif
* no_useless_else

Both rules only apply if the if-statement contains a return. If this
is the case the obsolete else/elseif part is dropped.

Resolves: #82183
Releases: master,8.7
Change-Id: I94dfa6b5b96cbc3e350bd778f1796dda1a4d955a
Reviewed-on: https://review.typo3.org/53791

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 4bc4fb02
......@@ -78,6 +78,8 @@ return PhpCsFixer\Config::create()
'no_short_bool_cast' => true,
'no_unneeded_control_parentheses' => true,
'phpdoc_no_empty_return' => true,
'phpdoc_trim' => true
'phpdoc_trim' => true,
'no_superfluous_elseif' => true,
'no_useless_else' => true,
])
->setFinder($finder);
......@@ -1779,16 +1779,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v2.4.1",
"version": "v2.5.0",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
"reference": "b4983586c8e7b1f99ec05dd1e75c8b673315da70"
"reference": "63aad575ec2a29d50eb6c3b5cbc17430b28895b2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/b4983586c8e7b1f99ec05dd1e75c8b673315da70",
"reference": "b4983586c8e7b1f99ec05dd1e75c8b673315da70",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/63aad575ec2a29d50eb6c3b5cbc17430b28895b2",
"reference": "63aad575ec2a29d50eb6c3b5cbc17430b28895b2",
"shasum": ""
},
"require": {
......@@ -1798,7 +1798,7 @@
"gecko-packages/gecko-php-unit": "^2.0",
"php": "^5.6 || >=7.0 <7.2",
"sebastian/diff": "^1.4",
"symfony/console": "^3.0",
"symfony/console": "^3.2",
"symfony/event-dispatcher": "^3.0",
"symfony/filesystem": "^3.0",
"symfony/finder": "^3.0",
......@@ -1814,6 +1814,7 @@
"require-dev": {
"johnkary/phpunit-speedtrap": "^1.1",
"justinrainbow/json-schema": "^5.0",
"php-cs-fixer/accessible-object": "^1.0",
"phpunit/phpunit": "^4.8.35 || ^5.4.3",
"satooshi/php-coveralls": "^1.0",
"symfony/phpunit-bridge": "^3.2.2"
......@@ -1826,11 +1827,6 @@
"php-cs-fixer"
],
"type": "application",
"extra": {
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"psr-4": {
"PhpCsFixer\\": "src/"
......@@ -1858,7 +1854,7 @@
}
],
"description": "A tool to automatically fix PHP code style",
"time": "2017-08-22T14:11:01+00:00"
"time": "2017-08-22T14:15:09+00:00"
},
{
"name": "gecko-packages/gecko-php-unit",
......
......@@ -114,16 +114,15 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
{
if ($this->hasDropDown()) {
return $this->getFluidTemplateObject('ClearCacheToolbarItem.html')->render();
} else {
$view = $this->getFluidTemplateObject('ClearCacheToolbarItemSingle.html');
$cacheAction = end($this->cacheActions);
$view->assignMultiple([
}
$view = $this->getFluidTemplateObject('ClearCacheToolbarItemSingle.html');
$cacheAction = end($this->cacheActions);
$view->assignMultiple([
'link' => $cacheAction['href'],
'title' => $cacheAction['title'],
'iconIdentifier' => $cacheAction['iconIdentifier'],
]);
return $view->render();
}
return $view->render();
}
/**
......
......@@ -655,9 +655,8 @@ class ShortcutToolbarItem implements ToolbarItemInterface
if ($affectedRows === 1) {
return 'success';
} else {
return 'failed';
}
return 'failed';
}
/**
......
......@@ -47,8 +47,8 @@ class ConditionMatcher extends AbstractConditionMatcher
$result = $this->evaluateConditionCommon($key, $value);
if (is_bool($result)) {
return $result;
} else {
switch ($key) {
}
switch ($key) {
case 'usergroup':
$groupList = $this->getGroupList();
$values = GeneralUtility::trimExplode(',', $value, true);
......@@ -95,7 +95,7 @@ class ConditionMatcher extends AbstractConditionMatcher
return $conditionResult;
}
}
}
return false;
}
......
......@@ -775,9 +775,8 @@ class BackendController
// start in module:
top.startInModule = [' . GeneralUtility::quoteJSvalue($startModule) . ', ' . GeneralUtility::quoteJSvalue($moduleParameters) . '];
';
} else {
return '';
}
return '';
}
/**
......
......@@ -508,12 +508,11 @@ class NewContentElementController extends AbstractModule
// Remove element all together:
unset($wizardItems[$key]);
break;
} else {
// Add the parameter:
$wizardItems[$key]['params'] .= '&defVals[tt_content][' . $fN . ']=' . rawurlencode($this->getLanguageService()->sL($fV));
$tmp = explode('_', $key);
$headersUsed[$tmp[0]] = $tmp[0];
}
// Add the parameter:
$wizardItems[$key]['params'] .= '&defVals[tt_content][' . $fN . ']=' . rawurlencode($this->getLanguageService()->sL($fV));
$tmp = explode('_', $key);
$headersUsed[$tmp[0]] = $tmp[0];
}
}
}
......
......@@ -1804,30 +1804,26 @@ class EditDocumentController extends AbstractModule
// that is handled inside DataHandler then and in the interface it would clearly be an error of
// links if the user accesses such a scenario)
return $reqRecord;
} else {
// The input record was online and an offline version must be found or made:
// Look for version of this workspace:
$versionRec = BackendUtility::getWorkspaceVersionOfRecord(
}
// The input record was online and an offline version must be found or made:
// Look for version of this workspace:
$versionRec = BackendUtility::getWorkspaceVersionOfRecord(
$this->getBackendUser()->workspace,
$table,
$reqRecord['uid'],
'uid,pid,t3ver_oid'
);
return is_array($versionRec) ? $versionRec : $reqRecord;
}
} else {
// This means that editing cannot occur on this record because it was not supporting versioning
// which is required inside an offline workspace.
return false;
return is_array($versionRec) ? $versionRec : $reqRecord;
}
} else {
// In ONLINE workspace, just return the originally requested record:
return $reqRecord;
// This means that editing cannot occur on this record because it was not supporting versioning
// which is required inside an offline workspace.
return false;
}
} else {
// Return FALSE because the table/uid was not found anyway.
return false;
// In ONLINE workspace, just return the originally requested record:
return $reqRecord;
}
// Return FALSE because the table/uid was not found anyway.
return false;
}
/**
......
......@@ -192,10 +192,9 @@ class FileController
return $response
->withHeader('Location', GeneralUtility::locationHeaderUrl($this->redirect))
->withStatus(303);
} else {
// empty response
return $response;
}
// empty response
return $response;
}
/**
......
......@@ -273,10 +273,9 @@ class LoginController
*/
throw new \RuntimeException('Login-error: Yeah, that\'s a classic. No cookies, no TYPO3. ' .
'Please accept cookies from TYPO3 - otherwise you\'ll not be able to use the system.', 1294586846);
} else {
// try it once again - that might be needed for auto login
$this->redirectToURL = 'index.php?commandLI=setCookie';
}
// try it once again - that might be needed for auto login
$this->redirectToURL = 'index.php?commandLI=setCookie';
}
$redirectToUrl = (string)$this->getBackendUserAuthentication()->getTSConfigVal('auth.BE.redirectToURL');
if (empty($redirectToUrl)) {
......
......@@ -622,10 +622,9 @@ class NewRecordController extends AbstractModule
$ret = strnatcasecmp($this->tRows[$a]['title'], $this->tRows[$b]['title']);
}
return $ret;
} else {
// Return alphabetic order
return strnatcasecmp($this->tRows[$a]['title'], $this->tRows[$b]['title']);
}
// Return alphabetic order
return strnatcasecmp($this->tRows[$a]['title'], $this->tRows[$b]['title']);
}
/**
......
......@@ -164,19 +164,18 @@ class NewMultiplePagesController
foreach ($newPagesData as $identifier => $data) {
if (!trim($data['title'])) {
continue;
}
$commandArray['pages'][$identifier]['hidden'] = $hidePages;
$commandArray['pages'][$identifier]['nav_hide'] = $hidePagesInMenu;
$commandArray['pages'][$identifier]['title'] = $data['title'];
$commandArray['pages'][$identifier]['doktype'] = $data['doktype'];
if ($firstRecord) {
$firstRecord = false;
$commandArray['pages'][$identifier]['pid'] = $firstPid;
} else {
$commandArray['pages'][$identifier]['hidden'] = $hidePages;
$commandArray['pages'][$identifier]['nav_hide'] = $hidePagesInMenu;
$commandArray['pages'][$identifier]['title'] = $data['title'];
$commandArray['pages'][$identifier]['doktype'] = $data['doktype'];
if ($firstRecord) {
$firstRecord = false;
$commandArray['pages'][$identifier]['pid'] = $firstPid;
} else {
$commandArray['pages'][$identifier]['pid'] = '-' . $previousIdentifier;
}
$previousIdentifier = $identifier;
$commandArray['pages'][$identifier]['pid'] = '-' . $previousIdentifier;
}
$previousIdentifier = $identifier;
}
if (!empty($commandArray)) {
......
......@@ -653,9 +653,8 @@ class PageLayoutController
->execute()
->fetch();
return $overlayRecord['title'];
} else {
return $this->pageinfo['title'];
}
return $this->pageinfo['title'];
}
/**
......
......@@ -356,8 +356,7 @@ class BackendModuleRepository implements \TYPO3\CMS\Core\SingletonInterface
if ($iconRegistry->isRegistered($iconIdentifier)) {
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
return $iconFactory->getIcon($iconIdentifier)->render();
} else {
return '';
}
return '';
}
}
......@@ -232,9 +232,8 @@ class PaletteAndSingleContainer extends AbstractContainer
if ($foundRealElement) {
return $resultStructure;
} else {
return [];
}
return [];
}
/**
......
......@@ -146,8 +146,7 @@ class OtherLanguageContent extends AbstractNode
'</span>';
}
return implode('<br />', $imgs);
} else {
return nl2br(htmlspecialchars($value));
}
return nl2br(htmlspecialchars($value));
}
}
......@@ -40,17 +40,16 @@ class SelectIcons extends AbstractNode
foreach ($selectItems as $item) {
if ($item[1] === '--div--') {
continue;
} else {
$icon = !empty($item[2]) ? FormEngineUtility::getIconHtml($item[2], $item[0], $item[0]) : '';
if ($icon) {
$selectIcons[] = [
}
$icon = !empty($item[2]) ? FormEngineUtility::getIconHtml($item[2], $item[0], $item[0]) : '';
if ($icon) {
$selectIcons[] = [
'title' => $item[0],
'icon' => $icon,
'index' => $selectItemCounter,
];
}
$selectItemCounter++;
}
$selectItemCounter++;
}
$html = [];
......
......@@ -45,10 +45,9 @@ class DatabaseRowDateTimeFields implements FormDataProviderInterface
} else {
$result['databaseRow'][$column] = null;
}
} else {
// its a UNIX timestamp! We do not modify this here, as it will only be treated as a datetime because
// of eval being set to "date" or "datetime". This is handled in InputTextElement then.
}
// its a UNIX timestamp! We do not modify this here, as it will only be treated as a datetime because
// of eval being set to "date" or "datetime". This is handled in InputTextElement then.
}
return $result;
}
......
......@@ -874,9 +874,8 @@ class EvaluateDisplayConditions implements FormDataProviderInterface
{
if ($condition['isNew']) {
return !((int)$condition['uid'] > 0);
} else {
return (int)$condition['uid'] > 0;
}
return (int)$condition['uid'] > 0;
}
/**
......
......@@ -68,7 +68,8 @@ class TcaColumnsProcessFieldLabels implements FormDataProviderInterface
if ($aShowItemFieldArray['fieldName'] === '--div--') {
// tabs are not of interest here
continue;
} elseif ($aShowItemFieldArray['fieldName'] === '--palette--') {
}
if ($aShowItemFieldArray['fieldName'] === '--palette--') {
// showitem references to a palette field. unpack the palette and process
// label overrides that may be in there.
if (!isset($result['processedTca']['palettes'][$aShowItemFieldArray['paletteName']]['showitem'])) {
......
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