Commit 63fd158d authored by Stefan Neufeind's avatar Stefan Neufeind
Browse files

[TASK] Remove ternary operator where not needed

The usage of the ternary operator just for conversion to boolean like
... ? TRUE : FALSE
is be replaced by a normal (bool) typecast.

Change-Id: Ia32f63b423ffa7e066c9cf8bb002dde51b419bfa
Resolves: #68063
Releases: master
Reviewed-on: http://review.typo3.org/41110

Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
parent 1c7d7b75
......@@ -48,7 +48,7 @@ class HelpToolbarItem implements ToolbarItemInterface {
* @return bool TRUE
*/
public function checkAccess() {
$result = $this->helpModuleMenu ? TRUE : FALSE;
$result = (bool)$this->helpModuleMenu;
return $result;
}
......
......@@ -47,7 +47,7 @@ class FlexFormLanguageContainer extends AbstractContainer {
$langDisabled = (bool)$flexFormDataStructureArray['meta']['langDisable'];
$flexFormRowData['meta']['currentLangId'] = array();
// Look up page language overlays
$checkPageLanguageOverlay = $this->getBackendUserAuthentication()->getTSConfigVal('options.checkPageLanguageOverlay') ? TRUE : FALSE;
$checkPageLanguageOverlay = (bool)$this->getBackendUserAuthentication()->getTSConfigVal('options.checkPageLanguageOverlay');
$pageOverlays = array();
if ($checkPageLanguageOverlay) {
$whereClause = 'pid=' . (int)$row['pid'] . BackendUtility::deleteClause('pages_language_overlay')
......
......@@ -77,7 +77,7 @@ class FullRecordContainer extends AbstractContainer {
array_unshift($fieldsArray, '--div--;LLL:EXT:lang/locallang_core.xlf:labels.generalTab');
}
// If first tab has no label definition, add "general" label
$firstTabHasLabel = count(GeneralUtility::trimExplode(';', $fieldsArray[0])) > 1 ? TRUE : FALSE;
$firstTabHasLabel = count(GeneralUtility::trimExplode(';', $fieldsArray[0])) > 1;
if (!$firstTabHasLabel) {
$fieldsArray[0] = '--div--;LLL:EXT:lang/locallang_core.xlf:labels.generalTab';
}
......
......@@ -119,7 +119,7 @@ class InlineRecordContainer extends AbstractContainer {
// Get configuration:
$collapseAll = isset($config['appearance']['collapseAll']) && $config['appearance']['collapseAll'];
$expandAll = isset($config['appearance']['collapseAll']) && !$config['appearance']['collapseAll'];
$ajaxLoad = isset($config['appearance']['ajaxLoad']) && !$config['appearance']['ajaxLoad'] ? FALSE : TRUE;
$ajaxLoad = !isset($config['appearance']['ajaxLoad']) || $config['appearance']['ajaxLoad'];
if ($isNewRecord) {
// Show this record expanded or collapsed
$isExpanded = $expandAll || (!$collapseAll ? 1 : 0);
......@@ -429,9 +429,9 @@ class InlineRecordContainer extends AbstractContainer {
$isParentExisting = MathUtility::canBeInterpretedAsInteger($parentUid);
$tcaTableCtrl = &$GLOBALS['TCA'][$foreign_table]['ctrl'];
$tcaTableCols = &$GLOBALS['TCA'][$foreign_table]['columns'];
$isPagesTable = $foreign_table == 'pages' ? TRUE : FALSE;
$isPagesTable = $foreign_table === 'pages';
$isOnSymmetricSide = RelationHandler::isOnSymmetricSide($parentUid, $config, $rec);
$enableManualSorting = $tcaTableCtrl['sortby'] || $config['MM'] || !$isOnSymmetricSide && $config['foreign_sortby'] || $isOnSymmetricSide && $config['symmetric_sortby'] ? TRUE : FALSE;
$enableManualSorting = $tcaTableCtrl['sortby'] || $config['MM'] || !$isOnSymmetricSide && $config['foreign_sortby'] || $isOnSymmetricSide && $config['symmetric_sortby'];
$nameObject = $this->inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->globalOptions['inlineFirstPid']);
$nameObjectFt = $nameObject . '-' . $foreign_table;
$nameObjectFtId = $nameObjectFt . '-' . $rec['uid'];
......
......@@ -439,7 +439,7 @@ class SingleFieldContainer extends AbstractContainer {
} else {
$label = $GLOBALS['TCA'][$table]['ctrl']['label'];
}
return $level['config']['foreign_table'] === $table && $label == $field ? TRUE : FALSE;
return $level['config']['foreign_table'] === $table && $label === $field;
}
/**
......@@ -578,7 +578,7 @@ class SingleFieldContainer extends AbstractContainer {
}
}
// Return the result for '%AND' (if nothing was checked, TRUE is returned)
return $localEntries == $localMatches ? TRUE : FALSE;
return $localEntries === $localMatches;
}
/**
......@@ -588,7 +588,7 @@ class SingleFieldContainer extends AbstractContainer {
* @return bool Returns TRUE, if the object is an associative array
*/
protected function isAssociativeArray($object) {
return is_array($object) && !empty($object) && array_keys($object) !== range(0, sizeof($object) - 1) ? TRUE : FALSE;
return is_array($object) && !empty($object) && array_keys($object) !== range(0, sizeof($object) - 1);
}
/**
......
......@@ -144,8 +144,8 @@ class SelectTreeElement extends AbstractFormElement {
$width = 280;
$appearance = $PA['fieldConf']['config']['treeConfig']['appearance'];
if (is_array($appearance)) {
$header = $appearance['showHeader'] ? TRUE : FALSE;
$expanded = $appearance['expandAll'] === TRUE;
$header = (bool)$appearance['showHeader'];
$expanded = (bool)$appearance['expandAll'];
if (isset($appearance['width'])) {
$width = (int)$appearance['width'];
}
......
......@@ -233,7 +233,7 @@ class ElementConditionMatcher {
break;
case 'BIT':
case '!BIT':
$result = ((int)$fieldValue & $operand) ? TRUE : FALSE;
$result = (bool)((int)$fieldValue & $operand);
if ($operator[0] === '!') {
$result = !$result;
}
......
......@@ -1883,7 +1883,7 @@ function jumpToUrl(URL) {
*/
public function collapseableSection($title, $html, $id, $saveStatePointer = '') {
GeneralUtility::logDeprecatedFunction();
$hasSave = $saveStatePointer ? TRUE : FALSE;
$hasSave = (bool)$saveStatePointer;
$collapsedStyle = ($collapsedClass = '');
if ($hasSave) {
/** @var $userSettingsController \TYPO3\CMS\Backend\Controller\UserSettingsController */
......
......@@ -182,7 +182,7 @@ class IconUtility {
$deleted = FALSE;
// Set, if a page-record (only pages!) has the extend-to-subpages flag set.
$protectSection = FALSE;
$noIconFound = $row['_NO_ICON_FOUND'] ? TRUE : FALSE;
$noIconFound = (bool)$row['_NO_ICON_FOUND'];
// + $shaded which is also boolean!
// Icon state based on "enableFields":
if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
......@@ -939,8 +939,8 @@ class IconUtility {
'fe_group' => FALSE,
'deleted' => FALSE,
'protectedSection' => FALSE,
'nav_hide' => $row['nav_hide'] ? TRUE : FALSE,
'noIconFound' => $row['_NO_ICON_FOUND'] ? TRUE : FALSE
'nav_hide' => (bool)$row['nav_hide'],
'noIconFound' => (bool)$row['_NO_ICON_FOUND']
);
// Icon state based on "enableFields":
if (is_array($tcaCtrl['enablecolumns'])) {
......
......@@ -618,7 +618,7 @@ abstract class AbstractUserAuthentication {
if (!$this->newSessionID) {
// Read user session
$authInfo['userSession'] = $this->fetchUserSession($skipSessionUpdate);
$haveSession = is_array($authInfo['userSession']) ? TRUE : FALSE;
$haveSession = is_array($authInfo['userSession']);
}
if ($this->writeDevLog) {
if ($haveSession) {
......@@ -1004,7 +1004,7 @@ abstract class AbstractUserAuthentication {
$statement->execute(array(':ses_id' => $id));
$row = $statement->fetch(\TYPO3\CMS\Core\Database\PreparedStatement::FETCH_NUM);
$statement->free();
return $row[0] ? TRUE : FALSE;
return (bool)$row[0];
}
/**
......
......@@ -229,7 +229,7 @@ class Bootstrap {
public function checkIfEssentialConfigurationExists() {
$configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager;
$this->setEarlyInstance(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class, $configurationManager);
return (!file_exists($configurationManager->getLocalConfigurationFileLocation()) || !file_exists(PATH_typo3conf . 'PackageStates.php')) ? FALSE : TRUE;
return file_exists($configurationManager->getLocalConfigurationFileLocation()) && file_exists(PATH_typo3conf . 'PackageStates.php');
}
/**
......
......@@ -3112,7 +3112,7 @@ class DataHandler {
// IRRE with a pointer field (database normalization):
if ($tcaFieldConf['foreign_field']) {
// if the record was imported, sorting was also imported, so skip this
$skipSorting = $this->callFromImpExp ? TRUE : FALSE;
$skipSorting = (bool)$this->callFromImpExp;
// update record in intermediate table (sorting & pointer uid to parent record)
$dbAnalysis->writeForeignField($tcaFieldConf, $id, 0, $skipSorting);
$newValue = $keepTranslation ? 0 : $dbAnalysis->countItems(FALSE);
......@@ -6107,7 +6107,7 @@ class DataHandler {
*/
public function tableReadOnly($table) {
// Returns TRUE if table is readonly
return $GLOBALS['TCA'][$table]['ctrl']['readOnly'] ? TRUE : FALSE;
return (bool)$GLOBALS['TCA'][$table]['ctrl']['readOnly'];
}
/**
......@@ -6118,7 +6118,7 @@ class DataHandler {
*/
public function tableAdminOnly($table) {
// Returns TRUE if table is admin-only
return $GLOBALS['TCA'][$table]['ctrl']['adminOnly'] ? TRUE : FALSE;
return (bool)$GLOBALS['TCA'][$table]['ctrl']['adminOnly'];
}
/**
......
......@@ -151,7 +151,7 @@ class ExtDirectApi {
* @return string $javascriptNamespaces
*/
protected function getExtDirectApi(array $filterNamespaces) {
$noCache = GeneralUtility::_GET('no_cache') ? TRUE : FALSE;
$noCache = (bool)GeneralUtility::_GET('no_cache');
// Look up into the cache
$cacheIdentifier = 'ExtDirectApi';
$cacheHash = md5($cacheIdentifier . implode(',', $filterNamespaces) . GeneralUtility::getIndpEnv('TYPO3_SSL') . serialize($this->settings) . TYPO3_MODE . GeneralUtility::getIndpEnv('HTTP_HOST'));
......
......@@ -3456,7 +3456,7 @@ Connection: close
if (self::cmpIP($_SERVER['REMOTE_ADDR'], $proxySSL)) {
$retVal = TRUE;
} else {
$retVal = $_SERVER['SSL_SESSION_ID'] || strtolower($_SERVER['HTTPS']) === 'on' || (string)$_SERVER['HTTPS'] === '1' ? TRUE : FALSE;
$retVal = $_SERVER['SSL_SESSION_ID'] || strtolower($_SERVER['HTTPS']) === 'on' || (string)$_SERVER['HTTPS'] === '1';
}
break;
case '_ARRAY':
......@@ -3949,11 +3949,7 @@ Connection: close
* @return bool TRUE if the page should be hidden
*/
static public function hideIfNotTranslated($l18n_cfg_fieldValue) {
if ($GLOBALS['TYPO3_CONF_VARS']['FE']['hidePagesIfNotTranslatedByDefault']) {
return $l18n_cfg_fieldValue & 2 ? FALSE : TRUE;
} else {
return $l18n_cfg_fieldValue & 2 ? TRUE : FALSE;
}
return $GLOBALS['TYPO3_CONF_VARS']['FE']['hidePagesIfNotTranslatedByDefault'] XOR ($l18n_cfg_fieldValue & 2);
}
/**
......@@ -3964,7 +3960,7 @@ Connection: close
* @return bool
*/
static public function hideIfDefaultLanguage($localizationConfiguration) {
return $localizationConfiguration & 1;
return (bool)($localizationConfiguration & 1);
}
/**
......
......@@ -98,7 +98,7 @@ class Request implements \TYPO3\CMS\Extbase\Mvc\RequestInterface {
* @return void
*/
public function setDispatched($flag) {
$this->dispatched = $flag ? TRUE : FALSE;
$this->dispatched = (bool)$flag;
}
/**
......
......@@ -114,12 +114,11 @@ class Request implements RequestInterface {
* Sets the dispatched flag
*
* @param bool $flag If this request has been dispatched
*
* @return void
* @api
*/
public function setDispatched($flag) {
$this->dispatched = $flag ? TRUE : FALSE;
$this->dispatched = (bool)$flag;
}
/**
......
......@@ -496,7 +496,7 @@ class TemplateParser {
if (preg_match(self::$SCAN_PATTERN_CDATA, $templateElement, $matchedVariables) > 0) {
$this->textHandler($state, $matchedVariables[1]);
} elseif (preg_match($regularExpression_openingViewHelperTag, $templateElement, $matchedVariables) > 0) {
$this->openingViewHelperTagHandler($state, $matchedVariables['NamespaceIdentifier'], $matchedVariables['MethodIdentifier'], $matchedVariables['Attributes'], ($matchedVariables['Selfclosing'] === '' ? FALSE : TRUE));
$this->openingViewHelperTagHandler($state, $matchedVariables['NamespaceIdentifier'], $matchedVariables['MethodIdentifier'], $matchedVariables['Attributes'], ($matchedVariables['Selfclosing'] !== ''));
} elseif (preg_match($regularExpression_closingViewHelperTag, $templateElement, $matchedVariables) > 0) {
$this->closingViewHelperTagHandler($state, $matchedVariables['NamespaceIdentifier'], $matchedVariables['MethodIdentifier']);
} else {
......
......@@ -59,13 +59,10 @@ class ContentContentObject extends AbstractContentObject {
$slideCollect = 0;
}
$slideCollectReverse = isset($conf['slide.']['collectReverse.']) ? (int)$this->cObj->stdWrap($conf['slide.']['collectReverse'], $conf['slide.']['collectReverse.']) : (int)$conf['slide.']['collectReverse'];
$slideCollectReverse = $slideCollectReverse ? TRUE : FALSE;
$slideCollectFuzzy = isset($conf['slide.']['collectFuzzy.']) ? (int)$this->cObj->stdWrap($conf['slide.']['collectFuzzy'], $conf['slide.']['collectFuzzy.']) : (int)$conf['slide.']['collectFuzzy'];
if ($slideCollectFuzzy) {
$slideCollectFuzzy = TRUE;
} else {
$slideCollectFuzzy = FALSE;
}
$slideCollectReverse = (bool)$slideCollectReverse;
$slideCollectFuzzy = isset($conf['slide.']['collectFuzzy.'])
? (bool)$this->cObj->stdWrap($conf['slide.']['collectFuzzy'], $conf['slide.']['collectFuzzy.'])
: (bool)$conf['slide.']['collectFuzzy'];
if (!$slideCollect) {
$slideCollectFuzzy = TRUE;
}
......
......@@ -4110,7 +4110,7 @@ class ContentObjectRenderer {
$chars = (int)$options[0];
$absChars = abs($chars);
$replacementForEllipsis = trim($options[1]);
$crop2space = trim($options[2]) === '1' ? TRUE : FALSE;
$crop2space = trim($options[2]) === '1';
// Split $content into an array(even items in the array are outside the tags, odd numbers are tag-blocks).
$tags = 'a|b|blockquote|body|div|em|font|form|h1|h2|h3|h4|h5|h6|i|li|map|ol|option|p|pre|sub|sup|select|span|strong|table|thead|tbody|tfoot|td|textarea|tr|u|ul|br|hr|img|input|area|link';
// @todo We should not crop inside <script> tags.
......
......@@ -3621,7 +3621,7 @@ class TypoScriptFrontendController {
header(
trim($options['header']),
// "replace existing headers" is turned on by default, unless turned off
($options['replace'] === '0' ? FALSE : TRUE),
($options['replace'] !== '0'),
((int)$options['httpResponseCode'] ?: NULL)
);
}
......
Markdown is supported
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