[CLEANUP] Replace count with empty in EXT:install 67/40967/2
authorStephan Großberndt <stephan@grossberndt.de>
Tue, 7 Jul 2015 16:20:21 +0000 (18:20 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 7 Jul 2015 17:35:28 +0000 (19:35 +0200)
Replace occurrences of count() with matching empty() pendants.

Resolves: #67964
Releases: master
Change-Id: I1ee543bc6484060c6ac7bd1b4d4f47b255b36296
Reviewed-on: http://review.typo3.org/40967
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
14 files changed:
typo3/sysext/install/Classes/Controller/AbstractController.php
typo3/sysext/install/Classes/Controller/Action/Step/DatabaseData.php
typo3/sysext/install/Classes/Controller/Action/Step/DatabaseSelect.php
typo3/sysext/install/Classes/Controller/Action/Step/EnvironmentAndFolders.php
typo3/sysext/install/Classes/Controller/Action/Tool/AllConfiguration.php
typo3/sysext/install/Classes/Controller/Action/Tool/CleanUp.php
typo3/sysext/install/Classes/Controller/Action/Tool/Configuration.php
typo3/sysext/install/Classes/Controller/Action/Tool/UpgradeWizard.php
typo3/sysext/install/Classes/Controller/StepController.php
typo3/sysext/install/Classes/Service/CoreUpdateService.php
typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php
typo3/sysext/install/Classes/Service/SqlSchemaMigrationService.php
typo3/sysext/install/Classes/SystemEnvironment/Check.php
typo3/sysext/install/Classes/ViewHelpers/Be/ContainerViewHelper.php

index ce963de..9f573c7 100644 (file)
@@ -102,7 +102,7 @@ class AbstractController {
        protected function checkSessionToken() {
                $postValues = $this->getPostValues();
                $tokenOk = FALSE;
-               if (count($postValues) > 0) {
+               if (!empty($postValues)) {
                        // A token must be given as soon as there is POST data
                        if (isset($postValues['token'])) {
                                /** @var $formProtection \TYPO3\CMS\Core\FormProtection\InstallToolFormProtection */
index da2d12e..7774cb6 100644 (file)
@@ -79,7 +79,7 @@ class DatabaseData extends AbstractStepAction {
        public function needsExecution() {
                $result = FALSE;
                $existingTables = $this->getDatabaseConnection()->admin_get_tables();
-               if (count($existingTables) === 0) {
+               if (empty($existingTables)) {
                        $result = TRUE;
                }
                return $result;
index 28d2e14..0b01948 100644 (file)
@@ -70,7 +70,7 @@ class DatabaseSelect extends AbstractStepAction {
                        $this->databaseConnection->sql_select_db();
                        $existingTables = $this->databaseConnection->admin_get_tables();
                        $isInitialInstallation = $configurationManager->getConfigurationValueByPath('SYS/isInitialInstallationInProgress');
-                       if (!$isInitialInstallation || count($existingTables) === 0) {
+                       if (!$isInitialInstallation || empty($existingTables)) {
                                $localConfigurationPathValuePairs['DB/database'] = $postValues['existing'];
                        }
                } else {
index 5d1af2a..cfed481 100644 (file)
@@ -109,10 +109,7 @@ class EnvironmentAndFolders extends AbstractStepAction {
                $structureErrors = $statusUtility->filterBySeverity($structureMessages, 'error');
                $this->view->assign('structureErrors', $structureErrors);
 
-               if (count($environmentStatus['error']) > 0
-                       || count($environmentStatus['warning']) > 0
-                       || count($structureErrors) > 0
-               ) {
+               if (!empty($environmentStatus['error']) || !empty($environmentStatus['warning']) || !empty($structureErrors)) {
                        $this->view->assign('errorsOrWarningsFromStatus', TRUE);
                }
                $this->assignSteps();
index 7751ef7..35f4a36 100644 (file)
@@ -172,7 +172,7 @@ class AllConfiguration extends Action\AbstractAction {
                                        }
                                }
                        }
-                       if (count($statusObjects)) {
+                       if (!empty($statusObjects)) {
                                /** @var \TYPO3\CMS\Core\Configuration\ConfigurationManager $configurationManager */
                                $configurationManager = $this->objectManager->get(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
                                $configurationManager->setLocalConfigurationValuesByPathValuePairs($configurationPathValuePairs);
index 45426ae..e953bc1 100644 (file)
@@ -133,7 +133,7 @@ class CleanUp extends Action\AbstractAction {
                                $clearedTables[] = $tableName;
                        }
                }
-               if (count($clearedTables)) {
+               if (!empty($clearedTables)) {
                        /** @var OkStatus $message */
                        $message = $this->objectManager->get(OkStatus::class);
                        $message->setTitle('Cleared tables');
index 90a9c85..d138761 100644 (file)
@@ -60,7 +60,7 @@ class Configuration extends Action\AbstractAction {
        protected function activate() {
                $configurationValues = $this->featureManager->getConfigurationForSelectedFeaturePresets($this->postValues['values']);
 
-               if (count($configurationValues) > 0) {
+               if (!empty($configurationValues)) {
                        $this->configurationManager->setLocalConfigurationValuesByPathValuePairs($configurationValues);
                        /** @var $message \TYPO3\CMS\Install\Status\StatusInterface */
                        $message = $this->objectManager->get(\TYPO3\CMS\Install\Status\OkStatus::class);
index a50d559..1b08b80 100644 (file)
@@ -287,13 +287,13 @@ class UpgradeWizard extends Action\AbstractAction {
                $currentTableDefinition = $sqlHandler->getFieldDefinitions_database();
                $updateTableDefinition = $sqlHandler->getDatabaseExtra($neededTableDefinition, $currentTableDefinition);
                $updateStatements = $sqlHandler->getUpdateSuggestions($updateTableDefinition);
-               if (isset($updateStatements['create_table']) && count($updateStatements['create_table']) > 0) {
+               if (isset($updateStatements['create_table']) && !empty($updateStatements['create_table'])) {
                        $sqlHandler->performUpdateQueries($updateStatements['create_table'], $updateStatements['create_table']);
                }
-               if (isset($updateStatements['add']) && count($updateStatements['add']) > 0) {
+               if (isset($updateStatements['add']) && !empty($updateStatements['add'])) {
                        $sqlHandler->performUpdateQueries($updateStatements['add'], $updateStatements['add']);
                }
-               if (isset($updateStatements['change']) && count($updateStatements['change']) > 0) {
+               if (isset($updateStatements['change']) && !empty($updateStatements['change'])) {
                        $sqlHandler->performUpdateQueries($updateStatements['change'], $updateStatements['change']);
                }
        }
index 3be79a1..07eb784 100644 (file)
@@ -397,7 +397,7 @@ class StepController extends AbstractController {
                        }
                        $action->setController('step');
                        $action->setAction('environmentAndFolders');
-                       if (count($errorMessagesFromExecute) > 0) {
+                       if (!empty($errorMessagesFromExecute)) {
                                $action->setMessages($errorMessagesFromExecute);
                        }
                        $this->output($action->handle());
index 6d82ad5..63d107b 100644 (file)
@@ -166,7 +166,7 @@ class CoreUpdateService {
                $folderStructureFacade = $this->objectManager->get(DefaultFactory::class)->getStructure();
                $folderStructureErrors = $statusUtility->filterBySeverity($folderStructureFacade->getStatus(), 'error');
                $folderStructureWarnings = $statusUtility->filterBySeverity($folderStructureFacade->getStatus(), 'warning');
-               if (count($folderStructureErrors) > 0 || count($folderStructureWarnings) > 0) {
+               if (!empty($folderStructureErrors) || !empty($folderStructureWarnings)) {
                        $success = FALSE;
                        /** @var $message StatusInterface */
                        $message = $this->objectManager->get(ErrorStatus::class);
index 4670dc6..2f8e72b 100644 (file)
@@ -268,7 +268,7 @@ class SilentConfigurationUpgradeService {
                                $changedValues['GFX/gdlib'] = 0;
                        }
                }
-               if (count($changedValues) > 0) {
+               if (!empty($changedValues)) {
                        $this->configurationManager->setLocalConfigurationValuesByPathValuePairs($changedValues);
                        $this->throwRedirectException();
                }
@@ -330,7 +330,7 @@ class SilentConfigurationUpgradeService {
                                $changedValues['GFX/thumbnails'] = 0;
                        }
                }
-               if (count($changedValues) > 0) {
+               if (!empty($changedValues)) {
                        $this->configurationManager->setLocalConfigurationValuesByPathValuePairs($changedValues);
                        $this->throwRedirectException();
                }
@@ -376,7 +376,7 @@ class SilentConfigurationUpgradeService {
                                }
                        }
                }
-               if (count($changedValues) > 0) {
+               if (!empty($changedValues)) {
                        $this->configurationManager->setLocalConfigurationValuesByPathValuePairs($changedValues);
                        $this->throwRedirectException();
                }
index 3fce9c7..3879708 100644 (file)
@@ -152,7 +152,7 @@ class SqlSchemaMigrationService {
         */
        public function getCollationForCharset($charset) {
                // Load character sets, if not cached already
-               if (!count($this->character_sets)) {
+               if (empty($this->character_sets)) {
                        if (method_exists($GLOBALS['TYPO3_DB'], 'admin_get_charsets')) {
                                $this->character_sets = $GLOBALS['TYPO3_DB']->admin_get_charsets();
                        } else {
@@ -224,7 +224,7 @@ class SqlSchemaMigrationService {
                        }
                }
                // Compile key information:
-               if (count($tempKeys)) {
+               if (!empty($tempKeys)) {
                        foreach ($tempKeys as $table => $keyInf) {
                                foreach ($keyInf as $kName => $index) {
                                        ksort($index);
@@ -413,7 +413,7 @@ class SqlSchemaMigrationService {
                                                                        if ($fN == 'CLEAR') {
                                                                                // Truncate table must happen later, not now
                                                                                // Valid values for CLEAR: 1=only clear if keys are missing, 2=clear anyway (force)
-                                                                               if (count($info['keys']) || $fV == 2) {
+                                                                               if (!empty($info['keys']) || $fV == 2) {
                                                                                        $clear_table = TRUE;
                                                                                }
                                                                                continue;
@@ -428,7 +428,7 @@ class SqlSchemaMigrationService {
                                                        $statement = 'TRUNCATE TABLE ' . $table . ';';
                                                        $statements['clear_table'][md5($statement)] = $statement;
                                                }
-                                               if (count($extras)) {
+                                               if (!empty($extras)) {
                                                        $statement = 'ALTER TABLE ' . $table . ' ' . implode(' ', $extras) . ';';
                                                        $statements['change'][md5($statement)] = $statement;
                                                        $statements['change_currentValue'][md5($statement)] = implode(' ', $extras_currentValue);
@@ -621,7 +621,7 @@ class SqlSchemaMigrationService {
                                }
                        }
                }
-               if (count($result) > 0) {
+               if (!empty($result)) {
                        return $result;
                } else {
                        return TRUE;
index b2e0af9..9f95440 100644 (file)
@@ -400,7 +400,7 @@ class Check {
                }
 
                if ($disabledFunctions !== '') {
-                       if (count($disabledFunctionsArray) > 0) {
+                       if (!empty($disabledFunctionsArray)) {
                                $status = new Status\ErrorStatus();
                                $status->setTitle('Some PHP functions disabled');
                                $status->setMessage(
@@ -876,7 +876,7 @@ class Check {
                // Link to our wiki page, so we can update opcode cache issue information independent of TYPO3 CMS releases.
                $wikiLink = 'For more information take a look in our wiki ' . TYPO3_URL_WIKI_OPCODECACHE . '.';
                $opcodeCaches = GeneralUtility::makeInstance(OpcodeCacheService::class)->getAllActive();
-               if (count($opcodeCaches) === 0) {
+               if (empty($opcodeCaches)) {
                        // Set status to notice. It needs to be notice so email won't be triggered.
                        $status = new Status\NoticeStatus();
                        $status->setTitle('No PHP opcode cache loaded');
index b0292ce..12865d5 100644 (file)
@@ -81,12 +81,12 @@ class ContainerViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBacken
                                $pageRenderer->enableExtJsDebug();
                        }
                }
-               if (is_array($addCssFiles) && count($addCssFiles) > 0) {
+               if (is_array($addCssFiles) && !empty($addCssFiles)) {
                        foreach ($addCssFiles as $addCssFile) {
                                $pageRenderer->addCssFile($addCssFile);
                        }
                }
-               if (is_array($addJsFiles) && count($addJsFiles) > 0) {
+               if (is_array($addJsFiles) && !empty($addJsFiles)) {
                        foreach ($addJsFiles as $addJsFile) {
                                $pageRenderer->addJsFile($addJsFile);
                        }