Commit 4722b6cf authored by Markus Klein's avatar Markus Klein Committed by Stefan Neufeind
Browse files

[CLEANUP] Replace strlen() with === for zero length check

It is faster to compare a string with === '' to find out if it's empty
than to run strlen() on it.

The replacement rules are applied as follows:
 *    if (strlen($str))
   => if ((string)$str !== '')
 *    if (!is_string($str) || strlen($str) === 0)
   => if (!is_string($str) || $str === '')
 * If it can be seen easily that $str is a string,
   the typecast is omitted.

Change-Id: I888d70e42f925bd57ad23b873b72d6a38acb39ef
Resolves: #54091
Releases: master
Reviewed-on: http://review.typo3.org/27794


Reviewed-by: Mathias Schreiber's avatarMathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber's avatarMathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
parent d38972b9
......@@ -44,9 +44,13 @@ class TranslationConfigurationProvider {
}
$languageIconTitles[0] = array(
'uid' => 0,
'title' => strlen($modSharedTSconfig['properties']['defaultLanguageLabel']) ? $modSharedTSconfig['properties']['defaultLanguageLabel'] . ' (' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage') . ')' : $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage'),
'title' => $modSharedTSconfig['properties']['defaultLanguageLabel'] !== ''
? $modSharedTSconfig['properties']['defaultLanguageLabel'] . ' (' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage') . ')'
: $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage'),
'ISOcode' => 'DEF',
'flagIcon' => strlen($modSharedTSconfig['properties']['defaultLanguageFlag']) ? 'flags-' . $modSharedTSconfig['properties']['defaultLanguageFlag'] : 'empty-empty'
'flagIcon' => $modSharedTSconfig['properties']['defaultLanguageFlag'] !== ''
? 'flags-' . $modSharedTSconfig['properties']['defaultLanguageFlag']
: 'empty-empty'
);
// Set "All" language:
$languageIconTitles[-1] = array(
......@@ -68,7 +72,7 @@ class TranslationConfigurationProvider {
$languageIconTitles[$row['uid']]['ISOcode'] = $staticLangRow['lg_iso_2'];
}
}
if (strlen($row['flag'])) {
if ($row['flag'] !== '') {
$languageIconTitles[$row['uid']]['flagIcon'] = IconUtility::mapRecordTypeToSpriteIconName('sys_language', $row);
}
}
......
......@@ -1296,7 +1296,9 @@ class EditDocumentController {
'uid' => 0,
'pid' => 0,
'hidden' => 0,
'title' => strlen($modSharedTSconfig['properties']['defaultLanguageLabel']) ? $modSharedTSconfig['properties']['defaultLanguageLabel'] . ' (' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage') . ')' : $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage'),
'title' => $modSharedTSconfig['properties']['defaultLanguageLabel'] !== ''
? $modSharedTSconfig['properties']['defaultLanguageLabel'] . ' (' . $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage') . ')'
: $GLOBALS['LANG']->sl('LLL:EXT:lang/locallang_mod_web_list.xlf:defaultLanguage'),
'flag' => $modSharedTSconfig['properties']['defaultLanguageFlag']
)
);
......
......@@ -269,7 +269,7 @@ class PageTreeNavigationController {
*/
public function initializeTemporaryDBmount() {
// Set/Cancel Temporary DB Mount:
if (strlen($this->setTempDBmount)) {
if ((string)$this->setTempDBmount !== '') {
$set = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->setTempDBmount, 0);
if ($set > 0 && $GLOBALS['BE_USER']->isInWebMount($set)) {
// Setting...:
......
......@@ -443,7 +443,7 @@ class FormsController extends AbstractWizardController {
case 'input':
case 'password':
if (strlen(trim($confData['specialEval']))) {
if (trim($confData['specialEval']) !== '') {
$hiddenFields[] = '<input type="hidden" name="FORMCFG[c][' . ($k + 1) * 2 . '][specialEval]" value="' . htmlspecialchars($confData['specialEval']) . '" />';
}
break;
......@@ -662,7 +662,7 @@ class FormsController extends AbstractWizardController {
if (trim($vv['extra'])) {
$tArr[2] = trim($vv['extra']);
}
if (strlen($vv['specialEval'])) {
if ($vv['specialEval'] !== '') {
// Preset blank default value so position 3 can get a value...
$thisLine[2] = '';
$thisLine[3] = $vv['specialEval'];
......@@ -676,7 +676,7 @@ class FormsController extends AbstractWizardController {
if ((int)$vv['max']) {
$tArr[1] = (int)$vv['max'];
}
if (strlen($vv['specialEval'])) {
if ($vv['specialEval'] !== '') {
// Preset blank default value so position 3 can get a value...
$thisLine[2] = '';
$thisLine[3] = $vv['specialEval'];
......
......@@ -213,7 +213,7 @@ class SuggestDefaultReceiver {
$searchWholePhrase = $this->config['searchWholePhrase'];
$searchString = $this->params['value'];
$searchUid = (int)$searchString;
if (strlen($searchString)) {
if ($searchString !== '') {
$searchString = $GLOBALS['TYPO3_DB']->quoteStr($searchString, $this->table);
$likeCondition = ' LIKE \'' . ($searchWholePhrase ? '%' : '') . $GLOBALS['TYPO3_DB']->escapeStrForLike($searchString, $this->table) . '%\'';
// Search in all fields given by label or label_alt
......@@ -239,7 +239,7 @@ class SuggestDefaultReceiver {
}
}
// add an additional search condition comment
if (isset($this->config['searchCondition']) && strlen($this->config['searchCondition']) > 0) {
if (isset($this->config['searchCondition']) && $this->config['searchCondition'] !== '') {
$this->selectClause .= ' AND ' . $this->config['searchCondition'];
}
// add the global clauses to the where-statement
......
......@@ -75,7 +75,7 @@ class TreeElement extends AbstractFormElement {
$item->checked = in_array($additionalItem[1], $selectedNodes);
if (file_exists(PATH_typo3 . $additionalItem[3])) {
$item->icon = $additionalItem[3];
} elseif (strlen(trim($additionalItem[3]))) {
} elseif (trim($additionalItem[3]) !== '') {
$item->iconCls = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconClasses($additionalItem[3]);
}
$itemArray[] = $item;
......
......@@ -683,14 +683,14 @@ abstract class AbstractTreeView {
* @return string The title.
*/
public function getTitleStr($row, $titleLen = 30) {
if ($this->ext_showNavTitle && strlen(trim($row['nav_title'])) > 0) {
if ($this->ext_showNavTitle && trim($row['nav_title']) !== '') {
$title = '<span title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tca.xlf:title', TRUE) . ' ' . htmlspecialchars(trim($row['title'])) . '">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['nav_title'], $titleLen)) . '</span>';
} else {
$title = htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['title'], $titleLen));
if (strlen(trim($row['nav_title'])) > 0) {
if (trim($row['nav_title']) !== '') {
$title = '<span title="' . $GLOBALS['LANG']->sL('LLL:EXT:cms/locallang_tca.xlf:pages.nav_title', TRUE) . ' ' . htmlspecialchars(trim($row['nav_title'])) . '">' . $title . '</span>';
}
$title = strlen(trim($row['title'])) == 0 ? '<em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', TRUE) . ']</em>' : $title;
$title = trim($row['title']) === '' ? '<em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', TRUE) . ']</em>' : $title;
}
return $title;
}
......
......@@ -2722,11 +2722,11 @@ class BackendUtility {
$beUser = static::getBackendUserAuthentication();
$viewLanguageOrder = $beUser->getTSConfigVal('options.view.languageOrder');
if (strlen($viewLanguageOrder) > 0) {
if ((string)$viewLanguageOrder !== '') {
$suffix = '';
// Find allowed languages (if none, all are allowed!)
$allowedLanguages = NULL;
if (!$beUser->user['admin'] && strlen($beUser->groupData['allowed_languages'])) {
if (!$beUser->user['admin'] && $beUser->groupData['allowed_languages'] !== '') {
$allowedLanguages = array_flip(explode(',', $beUser->groupData['allowed_languages']));
}
// Traverse the view order, match first occurrence:
......@@ -3691,7 +3691,7 @@ class BackendUtility {
$parserList = implode(',', array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['softRefParser_GL'])) . ',' . $parserList;
}
// Return immediately if list is blank:
if (!strlen($parserList)) {
if ($parserList === '') {
return FALSE;
}
// Otherwise parse the list:
......
......@@ -635,7 +635,7 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
) {
$grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name']) .
' (' . $this->getLanguageService()->getLL('noAccess') . ')', '', '');
} elseif (isset($columnConfig['name']) && strlen($columnConfig['name']) > 0) {
} elseif (isset($columnConfig['name']) && $columnConfig['name'] !== '') {
$grid .= $this->tt_content_drawColHeader($this->getLanguageService()->sL($columnConfig['name'])
. ' (' . $this->getLanguageService()->getLL('notAssigned') . ')', '', '');
} else {
......@@ -1813,7 +1813,7 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
// Remove disallowed languages
if (count($langSelItems) > 1
&& !$this->getBackendUser()->user['admin']
&& strlen($this->getBackendUser()->groupData['allowed_languages'])
&& $this->getBackendUser()->groupData['allowed_languages'] !== ''
) {
$allowed_languages = array_flip(explode(',', $this->getBackendUser()->groupData['allowed_languages']));
if (count($allowed_languages)) {
......
......@@ -1159,8 +1159,8 @@ class BackendUserAuthentication extends \TYPO3\CMS\Core\Authentication\AbstractU
$TSConf = array('value' => NULL, 'properties' => NULL);
$parts = GeneralUtility::trimExplode('.', $objectString, TRUE, 2);
$key = $parts[0];
if (strlen($key) > 0) {
if (count($parts) > 1 && strlen($parts[1]) > 0) {
if ($key !== '') {
if (count($parts) > 1 && $parts[1] !== '') {
// Go on, get the next level
if (is_array($config[$key . '.'])) {
$TSConf = $this->getTSConfig($parts[1], $config[$key . '.']);
......
......@@ -143,7 +143,7 @@ class RedisBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend impleme
\TYPO3\CMS\Core\Utility\GeneralUtility::sysLog('Could not connect to redis server.', 'core', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR);
}
if ($this->connected) {
if (strlen($this->password)) {
if ($this->password !== '') {
$success = $this->redis->auth($this->password);
if (!$success) {
throw new \TYPO3\CMS\Core\Cache\Exception('The given password was not accepted by the redis server.', 1279765134);
......@@ -320,7 +320,7 @@ class RedisBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend impleme
if ($this->connected) {
$storedEntry = $this->redis->get(self::IDENTIFIER_DATA_PREFIX . $entryIdentifier);
}
if ($this->compression && strlen($storedEntry) > 0) {
if ($this->compression && (string)$storedEntry !== '') {
$storedEntry = gzuncompress($storedEntry);
}
return $storedEntry;
......
......@@ -178,7 +178,7 @@ class Typo3DatabaseBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend
if (is_array($cacheEntry)) {
$cacheEntry = $cacheEntry['content'];
}
if ($this->compression && strlen($cacheEntry)) {
if ($this->compression && (string)$cacheEntry !== '') {
$cacheEntry = gzuncompress($cacheEntry);
}
return $cacheEntry !== NULL ? $cacheEntry : FALSE;
......
......@@ -1670,11 +1670,11 @@ class CharsetConverter {
return $string;
} else {
if ($len > 0) {
if (strlen($string[$i])) {
if (isset($string[$i])) {
return substr($string, 0, $i) . $crop;
}
} else {
if (strlen($string[$i - 1])) {
if (isset($string[$i - 1])) {
return $crop . substr($string, $i);
}
}
......@@ -1868,7 +1868,7 @@ class CharsetConverter {
return $str;
}
$out = '';
for ($i = 0; strlen($str[$i]); $i++) {
for ($i = 0; isset($str[$i]); $i++) {
$c = $str[$i];
if (isset($map[$c])) {
$out .= $map[$c];
......@@ -1932,7 +1932,7 @@ class CharsetConverter {
*/
public function utf8_strlen($str) {
$n = 0;
for ($i = 0; strlen($str[$i]); $i++) {
for ($i = 0; isset($str[$i]); $i++) {
$c = ord($str[$i]);
// Single-byte (0xxxxxx)
if (!($c & 128)) {
......@@ -2045,7 +2045,7 @@ class CharsetConverter {
$i = strlen($str) - 1;
$d = -1;
}
for (; strlen($str[$i]) && $n < $p; $i += $d) {
for (; isset($str[$i]) && $n < $p; $i += $d) {
$c = (int)ord($str[$i]);
// single-byte (0xxxxxx)
if (!($c & 128)) {
......@@ -2055,7 +2055,7 @@ class CharsetConverter {
$n++;
}
}
if (!strlen($str[$i])) {
if (!isset($str[$i])) {
// Offset beyond string length
return FALSE;
}
......@@ -2092,7 +2092,7 @@ class CharsetConverter {
$n++;
}
}
if (!strlen($str[$i])) {
if (!isset($str[$i])) {
// Offset beyond string length
return FALSE;
}
......@@ -2123,7 +2123,7 @@ class CharsetConverter {
default:
return $str;
}
for ($i = 0; strlen($str[$i]); $i++) {
for ($i = 0; isset($str[$i]); $i++) {
$c = ord($str[$i]);
// single-byte (0xxxxxx)
if (!($c & 128)) {
......@@ -2168,7 +2168,7 @@ class CharsetConverter {
*/
public function euc_strtrunc($str, $len, $charset) {
$sjis = $charset === 'shift_jis';
for ($i = 0; strlen($str[$i]) && $i < $len; $i++) {
for ($i = 0; isset($str[$i]) && $i < $len; $i++) {
$c = ord($str[$i]);
if ($sjis) {
if ($c >= 128 && $c < 160 || $c >= 224) {
......@@ -2180,7 +2180,7 @@ class CharsetConverter {
}
}
}
if (!strlen($str[$i])) {
if (!isset($str[$i])) {
return $str;
}
// string shorter than supplied length
......@@ -2232,7 +2232,7 @@ class CharsetConverter {
public function euc_strlen($str, $charset) {
$sjis = $charset === 'shift_jis';
$n = 0;
for ($i = 0; strlen($str[$i]); $i++) {
for ($i = 0; isset($str[$i]); $i++) {
$c = ord($str[$i]);
if ($sjis) {
if ($c >= 128 && $c < 160 || $c >= 224) {
......@@ -2269,7 +2269,7 @@ class CharsetConverter {
$i = strlen($str) - 1;
$d = -1;
}
for (; strlen($str[$i]) && $n < $p; $i += $d) {
for (; isset($str[$i]) && $n < $p; $i += $d) {
$c = ord($str[$i]);
if ($sjis) {
if ($c >= 128 && $c < 160 || $c >= 224) {
......@@ -2282,7 +2282,7 @@ class CharsetConverter {
}
$n++;
}
if (!strlen($str[$i])) {
if (!isset($str[$i])) {
return FALSE;
}
// offset beyond string length
......@@ -2323,7 +2323,7 @@ class CharsetConverter {
}
$sjis = $charset === 'shift_jis';
$out = '';
for ($i = 0; strlen($str[$i]); $i++) {
for ($i = 0; isset($str[$i]); $i++) {
$mbc = $str[$i];
$c = ord($mbc);
if ($sjis) {
......
......@@ -472,7 +472,7 @@ class SystemEnvironmentBuilder {
*/
static protected function getPathSiteByRelativePathPart($relativePathPart) {
$entryScriptDirectory = self::getUnifiedDirectoryNameWithTrailingSlash(PATH_thisScript);
if (strlen($relativePathPart) > 0) {
if ($relativePathPart !== '') {
$pathSite = substr($entryScriptDirectory, 0, -strlen($relativePathPart));
} else {
$pathSite = $entryScriptDirectory;
......
......@@ -2339,7 +2339,7 @@ class DataHandler {
}
$this->databaseConnection->sql_free_result($res);
// If the new value is there:
$value = strlen($newValue) ? $newValue : $value;
$value = $newValue !== '' ? $newValue : $value;
}
return $value;
}
......@@ -3437,7 +3437,7 @@ class DataHandler {
// Process references and files, currently that means only the files, prepending absolute paths:
$dataValue = $this->copyRecord_procFilesRefs($dsConf, $uid, $dataValue);
// If references are set for this field, set flag so they can be corrected later (in ->remapListedDBRecords())
if (($this->isReferenceField($dsConf) || $this->getInlineFieldType($dsConf) !== FALSE) && strlen($dataValue)) {
if (($this->isReferenceField($dsConf) || $this->getInlineFieldType($dsConf) !== FALSE) && (string)$dataValue !== '') {
$dataValue = $this->copyRecord_procBasedOnFieldType($table, $uid, $field, $dataValue, array(), $dsConf, $realDestPid);
$this->registerDBList[$table][$uid][$field] = 'FlexForm_reference';
}
......@@ -3988,15 +3988,17 @@ class DataHandler {
foreach ($GLOBALS['TCA'][$Ttable]['columns'] as $fN => $fCfg) {
// Check if we are just prefixing:
if ($fCfg['l10n_mode'] == 'prefixLangTitle') {
if (($fCfg['config']['type'] == 'text' || $fCfg['config']['type'] == 'input') && strlen($row[$fN])) {
if (($fCfg['config']['type'] == 'text' || $fCfg['config']['type'] == 'input') && (string)$row[$fN] !== '') {
list($tscPID) = BackendUtility::getTSCpid($table, $uid, '');
$TSConfig = $this->getTCEMAIN_TSconfig($tscPID);
if (isset($TSConfig['translateToMessage']) && !empty($TSConfig['translateToMessage'])) {
if (!empty($TSConfig['translateToMessage'])) {
$translateToMsg = $GLOBALS['LANG'] ? $GLOBALS['LANG']->sL($TSConfig['translateToMessage']) : $TSConfig['translateToMessage'];
$translateToMsg = @sprintf($translateToMsg, $langRec['title']);
}
if (!strlen($translateToMsg)) {
$translateToMsg = 'Translate to ' . $langRec['title'] . ':';
} else {
$translateToMsg = @sprintf($TSConfig['translateToMessage'], $langRec['title']);
}
$overrideValues[$fN] = '[' . $translateToMsg . '] ' . $row[$fN];
}
......@@ -4981,7 +4983,7 @@ class DataHandler {
// Extract parameters:
list($table, $uid, $field) = $pParams;
// If references are set for this field, set flag so they can be corrected later:
if ($this->isReferenceField($dsConf) && strlen($dataValue)) {
if ($this->isReferenceField($dsConf) && (string)$dataValue !== '') {
$vArray = $this->remapListedDBRecords_procDBRefs($dsConf, $dataValue, $uid, $table);
if (is_array($vArray)) {
$dataValue = implode(',', $vArray);
......
......@@ -817,7 +817,7 @@ class QueryGenerator {
}
} else {
$singleValue = $row[$fieldName];
if (strlen($singleValue) && !stristr($singleValue, '_')) {
if ($singleValue !== '' && !stristr($singleValue, '_')) {
$dontPrefixFirstTable = 1;
}
}
......
......@@ -828,7 +828,7 @@ class QueryView {
}
} else {
$singleValue = $row[$fieldName];
if (strlen($singleValue) && !stristr($singleValue, '_')) {
if ($singleValue !== '' && !stristr($singleValue, '_')) {
$dontPrefixFirstTable = 1;
}
}
......
......@@ -401,7 +401,7 @@ class ReferenceIndex {
}
}
// Soft References:
if (strlen($value) && ($softRefs = BackendUtility::explodeSoftRefParserList($conf['softref']))) {
if ((string)$value !== '' && ($softRefs = BackendUtility::explodeSoftRefParserList($conf['softref']))) {
$softRefValue = $value;
foreach ($softRefs as $spKey => $spParams) {
$softRefObj = BackendUtility::softRefParserObj($spKey);
......@@ -409,7 +409,7 @@ class ReferenceIndex {
$resultArray = $softRefObj->findRef($table, $field, $uid, $softRefValue, $spKey, $spParams);
if (is_array($resultArray)) {
$outRow[$field]['softrefs']['keys'][$spKey] = $resultArray['elements'];
if (strlen($resultArray['content'])) {
if ((string)$resultArray['content'] !== '') {
$softRefValue = $resultArray['content'];
}
}
......@@ -471,7 +471,7 @@ class ReferenceIndex {
$this->temp_flexRelations['db'][$structurePath] = $resultsFromDatabase;
}
// Soft References:
if ((is_array($dataValue) || strlen($dataValue)) && $softRefs = BackendUtility::explodeSoftRefParserList($dsConf['softref'])) {
if ((is_array($dataValue) || (string)$dataValue !== '') && $softRefs = BackendUtility::explodeSoftRefParserList($dsConf['softref'])) {
$softRefValue = $dataValue;
foreach ($softRefs as $spKey => $spParams) {
$softRefObj = BackendUtility::softRefParserObj($spKey);
......@@ -479,7 +479,7 @@ class ReferenceIndex {
$resultArray = $softRefObj->findRef($table, $field, $uid, $softRefValue, $spKey, $spParams, $structurePath);
if (is_array($resultArray) && is_array($resultArray['elements'])) {
$this->temp_flexRelations['softrefs'][$structurePath]['keys'][$spKey] = $resultArray['elements'];
if (strlen($resultArray['content'])) {
if ((string)$resultArray['content'] !== '') {
$softRefValue = $resultArray['content'];
}
}
......
......@@ -27,7 +27,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
*
* Example of usage
* Soft References:
* if ($conf['softref'] && strlen($value)) { // Check if a TCA configured field has softreferences defined (see TYPO3 Core API document)
* if ($conf['softref'] && (strong)$value !== '')) { // Check if a TCA configured field has softreferences defined (see TYPO3 Core API document)
* $softRefs = \TYPO3\CMS\Backend\Utility\BackendUtility::explodeSoftRefParserList($conf['softref']); // Explode the list of softreferences/parameters
* foreach($softRefs as $spKey => $spParams) { // Traverse soft references
* $softRefObj = &\TYPO3\CMS\Backend\Utility\BackendUtility::softRefParserObj($spKey); // create / get object
......@@ -631,7 +631,7 @@ class SoftReferenceIndex {
// Link-data del
$link_param = trim($link_params_parts[0]);
if (strlen($link_params_parts[1])) {
if ((string)$link_params_parts[1] !== '') {
$finalTagParts['anchor'] = trim($link_params_parts[1]);
}
......@@ -643,7 +643,7 @@ class SoftReferenceIndex {
}
// Checking if the id-parameter is an alias.
if (strlen($link_param)) {
if ((string)$link_param !== '') {
if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($link_param)) {
$finalTagParts['alias'] = $link_param;
$link_param = $this->getPageIdFromAlias($link_param);
......@@ -744,11 +744,11 @@ class SoftReferenceIndex {
);
}
// Add type if applicable
if (strlen($tLP['type'])) {
if ((string)$tLP['type'] !== '') {
$content .= ',' . $tLP['type'];
}
// Add anchor if applicable
if (strlen($tLP['anchor'])) {
if ((string)$tLP['anchor'] !== '') {
// Anchor is assumed to point to a content elements:
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($tLP['anchor'])) {
// Initialize a new entry because we have a new relation:
......@@ -780,7 +780,7 @@ class SoftReferenceIndex {
}
}
// Finally, for all entries that was rebuild with tokens, add target, class, title and additionalParams in the end:
if (strlen($content) && isset($tLP['target']) && $tLP['target'] !== '') {
if ($content !== '' && isset($tLP['target']) && $tLP['target'] !== '') {
$content .= ' ' . $tLP['target'];
if (isset($tLP['class']) && $tLP['class'] !== '') {
$content .= ' "' . $tLP['class'] . '"';
......
......@@ -431,7 +431,7 @@ class SqlParser {
$result['TABLE'] = $this->nextPart($parseString, '^([[:alnum:]_]+)[[:space:]]*\\(', TRUE);
if ($result['TABLE']) {
// While the parseString is not yet empty:
while (strlen($parseString) > 0) {
while ($parseString !== '') {
// Getting key
if ($key = $this->nextPart($parseString, '^(KEY|PRIMARY KEY|UNIQUE KEY|UNIQUE)([[:space:]]+|\\()')) {
$key = $this->normalizeKeyword($key);
......@@ -683,7 +683,7 @@ class SqlParser {
public function parseFieldList(&$parseString, $stopRegex = '') {
$stack = array();
// Contains the parsed content
if (strlen($parseString) === 0) {
if ($parseString === '') {
return $stack;
}
// @todo - should never happen, why does it?
......@@ -700,7 +700,7 @@ class SqlParser {
// Parse any SQL hint / comments
$stack[$pnt]['comments'] = $this->nextPart($parseString, '^(\\/\\*.*\\*\\/)');
// $parseString is continuously shortened by the process and we keep parsing it till it is zero:
while (strlen($parseString)) {
while ($parseString !== '') {
// Checking if we are inside / outside parenthesis (in case of a function like count(), max(), min() etc...):
// Inside parenthesis here (does NOT detect if values in quotes are used, the only token is ")" or "("):
if ($level > 0) {
......@@ -784,7 +784,7 @@ class SqlParser {
return $stack;
}
// Looking for comma (since the stop-keyword did not trigger a return...)
if (strlen($parseString) && !$this->nextPart($parseString, '^(,)')) {
if ($parseString !== '' && !$this->nextPart($parseString, '^(,)')) {
return $this->parseError('No comma found as expected in parseFieldList()', $parseString);
}
// Increasing pointer:
......@@ -856,7 +856,7 @@ class SqlParser {
// Recursivity brake.
$loopExit = 0;
// $parseString is continously shortend by the process and we keep parsing it till it is zero:
while (strlen($parseString)) {
while ($parseString !== '') {
// Looking for the table:
if ($stack[$pnt]['table'] = $this->nextPart($parseString, '^([[:alnum:]_]+)(,|[[:space:]]+)')) {
// Looking for stop-keywords before fetching potential table alias:
......@@ -935,7 +935,7 @@ class SqlParser {
return $stack;
}
// Looking for comma:
if (strlen($parseString) && !$this->nextPart($parseString, '^(,)')) {
if ($parseString !== '' && !$this->nextPart($parseString, '^(,)')) {
return $this->parseError('No comma found as expected in parseFromTables()', $parseString);
}
// Increasing pointer:
......@@ -973,7 +973,7 @@ class SqlParser {
// Recursivity brake.
$loopExit = 0;
// $parseString is continuously shortened by the process and we keep parsing it till it is zero:
while (strlen($parseString)) {
while ($parseString !== '') {
// Look for next parenthesis level:
$newLevel = $this->nextPart($parseString, '^([(])');
// If new level is started, manage stack/pointers:
......@@ -1102,7 +1102,7 @@ class SqlParser {
}
// See if the value is calculated:
$stack[$level][$pnt[$level]]['calc'] = $this->nextPart($parseString, '^(' . $calcOperators . ')');
if (strlen($stack[$level][$pnt[$level]]['calc'])) {
if ((string)$stack[$level][$pnt[$level]]['calc'] !== '') {
// Finding value for calculation:
$calc_value = $this->getValue($parseString);
$stack[$level][$pnt[$level]]['calc_value'] = $calc_value;
......@@ -1120,7 +1120,7 @@ class SqlParser {
}
}
$stack[$level][$pnt[$level]]['comparator'] = $this->nextPar