[CLEANUP] Replace count with empty in EXT:core 64/40964/2
authorStephan Großberndt <stephan@grossberndt.de>
Tue, 7 Jul 2015 15:37:04 +0000 (17:37 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 9 Jul 2015 20:40:40 +0000 (22:40 +0200)
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 <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/core/Classes/Cache/Backend/FileBackend.php
typo3/sysext/core/Classes/Configuration/TypoScript/ConditionMatching/AbstractConditionMatcher.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/Database/PreparedStatement.php
typo3/sysext/core/Classes/Database/RelationHandler.php
typo3/sysext/core/Classes/Error/DebugExceptionHandler.php
typo3/sysext/core/Classes/FrontendEditing/FrontendEditingController.php
typo3/sysext/core/Classes/Html/RteHtmlParser.php
typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php

index 3afac38..e8f7a3d 100644 (file)
@@ -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;
index 2e35def..d5078b4 100644 (file)
@@ -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);
index 786084f..fba7422 100644 (file)
@@ -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
index 7020350..3f7d19d 100644 (file)
@@ -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
index f41ec0d..9abf5a4 100644 (file)
@@ -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));
index dfd684f..5cf8755 100644 (file)
@@ -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++) {
index 958fe36..6a926ca 100644 (file)
@@ -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']);
index 5bff145..d9ddcd8 100644 (file)
@@ -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'];
index 7ddbff0..414432e 100644 (file)
@@ -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, '=');
index 4ae2001..8eaa2c0 100755 (executable)
@@ -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])) {