Commit 19cf9671 authored by Stephan Großberndt's avatar Stephan Großberndt Committed by Anja Leichsenring
Browse files

[CLEANUP] Replace count with empty in EXT:core

Replace occurrences of count() with matching empty() pendants.

Resolves: #67961
Releases: master
Change-Id: I0f06ac003d4a155d86f269a8e80c5183fec71354
Reviewed-on: http://review.typo3.org/40964


Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent f0eadf2f
......@@ -360,7 +360,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
protected function findCacheFilesByIdentifier($entryIdentifier) {
$pattern = $this->cacheDirectory . $entryIdentifier;
$filesFound = glob($pattern);
if ($filesFound === FALSE || count($filesFound) === 0) {
if ($filesFound === FALSE || empty($filesFound)) {
return FALSE;
}
return $filesFound;
......
......@@ -504,7 +504,7 @@ abstract class AbstractConditionMatcher {
*/
protected function getVariableCommon(array $vars) {
$value = NULL;
if (count($vars) == 1) {
if (count($vars) === 1) {
$value = $this->getGlobal($vars[0]);
} else {
$splitAgain = explode('|', $vars[1], 2);
......
......@@ -2989,7 +2989,7 @@ class DataHandler {
if (substr($ik, 0, 3) == 'ID-') {
$newIndexCounter++;
// Set mapping index
$this->newIndexMap[$ik] = (is_array($dataValues_current[$key]['el']) && count($dataValues_current[$key]['el']) ? max(array_keys($dataValues_current[$key]['el'])) : 0) + $newIndexCounter;
$this->newIndexMap[$ik] = (is_array($dataValues_current[$key]['el']) && !empty($dataValues_current[$key]['el']) ? max(array_keys($dataValues_current[$key]['el'])) : 0) + $newIndexCounter;
// Transfer values
$dataValues[$key]['el'][$this->newIndexMap[$ik]] = $dataValues[$key]['el'][$ik];
// Unset original
......
......@@ -166,7 +166,7 @@ class PreparedStatement {
$this->parameters = array();
// Test if named placeholders are used
if ($this->hasNamedPlaceholders($query) || count($precompiledQueryParts) > 0) {
if ($this->hasNamedPlaceholders($query) || !empty($precompiledQueryParts)) {
$this->statement = NULL;
} else {
// Only question mark placeholders are used
......
......@@ -464,7 +464,7 @@ class RelationHandler {
return $a['id'] < $b['id'] ? -1 : 1;
}
);
} elseif (count($this->tableArray) == 1) {
} elseif (count($this->tableArray) === 1) {
reset($this->tableArray);
$table = key($this->tableArray);
$uidList = implode(',', current($this->tableArray));
......
......@@ -199,7 +199,8 @@ Uncaught TYPO3 Exception ' . $exceptionCodeNumber . $exception->getMessage() . L
$phpFile = @file($filePathAndName);
if (is_array($phpFile)) {
$startLine = $lineNumber > 2 ? $lineNumber - 2 : 1;
$endLine = $lineNumber < count($phpFile) - 2 ? $lineNumber + 3 : count($phpFile) + 1;
$phpFileCount = count($phpFile);
$endLine = $lineNumber < $phpFileCount - 2 ? $lineNumber + 3 : $phpFileCount + 1;
if ($endLine > $startLine) {
$codeSnippet = '<br /><span style="font-size:10px;">' . $filePathAndName . ':</span><br /><pre>';
for ($line = $startLine; $line < $endLine; $line++) {
......
......@@ -512,7 +512,7 @@ class FrontendEditingController {
$perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
if ($table == 'pages') {
// Rootpage
if (count($GLOBALS['TSFE']->config['rootLine']) == 1) {
if (count($GLOBALS['TSFE']->config['rootLine']) === 1) {
unset($allow['move']);
unset($allow['hide']);
unset($allow['delete']);
......
......@@ -586,7 +586,7 @@ class RteHtmlParser extends \TYPO3\CMS\Core\Html\HtmlParser {
}
}
// Only if href, target, class and tile are the only attributes, we can alter the link!
if (!count($attribArray_copy)) {
if (empty($attribArray_copy)) {
// Quoting class and title attributes if they contain spaces
$attribArray['class'] = preg_match('/ /', $attribArray['class']) ? '"' . $attribArray['class'] . '"' : $attribArray['class'];
$attribArray['title'] = preg_match('/ /', $attribArray['title']) ? '"' . $attribArray['title'] . '"' : $attribArray['title'];
......
......@@ -1144,7 +1144,7 @@ class ExtendedTemplateService extends TemplateService {
}
$label = $this->getLanguageService()->sL($params['label']);
$label_parts = explode(':', $label, 2);
if (count($label_parts) == 2) {
if (count($label_parts) === 2) {
$head = trim($label_parts[0]);
$body = trim($label_parts[1]);
} else {
......@@ -1405,7 +1405,7 @@ class ExtendedTemplateService extends TemplateService {
if (isset($this->objReg[$key])) {
$lineNum = $this->objReg[$key];
$parts = explode('=', $this->raw[$lineNum], 2);
if (count($parts) == 2) {
if (count($parts) === 2) {
$parts[1] = $theValue;
}
$this->raw[$lineNum] = implode($parts, '=');
......
......@@ -371,11 +371,11 @@ class GeneralUtility {
*/
static public function cmpIPv4($baseIP, $list) {
$IPpartsReq = explode('.', $baseIP);
if (count($IPpartsReq) == 4) {
if (count($IPpartsReq) === 4) {
$values = self::trimExplode(',', $list, TRUE);
foreach ($values as $test) {
$testList = explode('/', $test);
if (count($testList) == 2) {
if (count($testList) === 2) {
list($test, $mask) = $testList;
} else {
$mask = FALSE;
......@@ -422,7 +422,7 @@ class GeneralUtility {
$values = self::trimExplode(',', $list, TRUE);
foreach ($values as $test) {
$testList = explode('/', $test);
if (count($testList) == 2) {
if (count($testList) === 2) {
list($test, $mask) = $testList;
} else {
$mask = FALSE;
......@@ -502,7 +502,7 @@ class GeneralUtility {
}
// Count 2 if if address has hidden zero blocks
$chunks = explode('::', $address);
if (count($chunks) == 2) {
if (count($chunks) === 2) {
$chunksLeft = explode(':', $chunks[0]);
$chunksRight = explode(':', $chunks[1]);
$left = count($chunksLeft);
......@@ -622,7 +622,9 @@ class GeneralUtility {
foreach ($values as $test) {
$hostNameParts = explode('.', $test);
// To match hostNameParts can only be shorter (in case of wildcards) or equal
if (count($hostNameParts) > count($baseHostNameParts)) {
$hostNamePartsCount = count($hostNameParts);
$baseHostNamePartsCount = count($baseHostNameParts);
if ($hostNamePartsCount > $baseHostNamePartsCount) {
continue;
}
$yes = TRUE;
......@@ -632,10 +634,10 @@ class GeneralUtility {
// Wildcard valid for one or more hostname-parts
$wildcardStart = $index + 1;
// Wildcard as last/only part always matches, otherwise perform recursive checks
if ($wildcardStart < count($hostNameParts)) {
if ($wildcardStart < $hostNamePartsCount) {
$wildcardMatched = FALSE;
$tempHostName = implode('.', array_slice($hostNameParts, $index + 1));
while ($wildcardStart < count($baseHostNameParts) && !$wildcardMatched) {
while ($wildcardStart < $baseHostNamePartsCount && !$wildcardMatched) {
$tempBaseHostName = implode('.', array_slice($baseHostNameParts, $wildcardStart));
$wildcardMatched = self::cmpFQDN($tempBaseHostName, $tempHostName);
$wildcardStart++;
......@@ -858,7 +860,7 @@ class GeneralUtility {
*/
static public function dirname($path) {
$p = self::revExplode('/', $path, 2);
return count($p) == 2 ? $p[0] : '';
return count($p) === 2 ? $p[0] : '';
}
/**
......@@ -4133,7 +4135,7 @@ Connection: close
}
// Call function or method:
$parts = explode('->', $funcRef);
if (count($parts) == 2) {
if (count($parts) === 2) {
// Class
// Check if class/method exists:
if (class_exists($parts[0])) {
......
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