[CLEANUP] Replace count with empty in EXT:backend 63/40963/4
authorStephan Großberndt <stephan@grossberndt.de>
Tue, 7 Jul 2015 15:11:57 +0000 (17:11 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 8 Jul 2015 04:25:37 +0000 (06:25 +0200)
Replace occurrences of count() with matching empty() pendants.

Resolves: #67960
Releases: master
Change-Id: I0464e5ce1c31d64f0005efcdf5f018239c037ec9
Reviewed-on: http://review.typo3.org/40963
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php
typo3/sysext/backend/Classes/Clipboard/Clipboard.php
typo3/sysext/backend/Classes/Controller/EditDocumentController.php
typo3/sysext/backend/Classes/Controller/PageLayoutController.php
typo3/sysext/backend/Classes/Form/Element/GroupElement.php
typo3/sysext/backend/Classes/Form/FormDataTraverser.php
typo3/sysext/backend/Classes/Tree/Pagetree/DataProvider.php
typo3/sysext/backend/Classes/Tree/View/AbstractTreeView.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/backend/Classes/View/PageTreeView.php

index 3b33129..63c5149 100644 (file)
@@ -172,7 +172,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface {
                }
                $shortcutMenu[] = '</ul>';
 
-               if (count($shortcutMenu) == 2) {
+               if (count($shortcutMenu) === 2) {
                        // No shortcuts added yet, show a small help message how to add shortcuts
                        $title = $languageService->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.bookmarks', TRUE);
                        $icon = IconUtility::getSpriteIcon('actions-system-shortcut-new', array(
index 597a515..bb4a162 100644 (file)
@@ -421,7 +421,7 @@ class Clipboard {
                                }
                        }
                }
-               if (!count($lines)) {
+               if (empty($lines)) {
                        $lines[] = '
                                                                <tr>
                                                                        <td class="col-icon"></td>
@@ -878,7 +878,7 @@ class Clipboard {
         * @return bool TRUE if elements exist.
         */
        public function isElements() {
-               return is_array($this->clipData[$this->current]['el']) && count($this->clipData[$this->current]['el']);
+               return is_array($this->clipData[$this->current]['el']) && !empty($this->clipData[$this->current]['el']);
        }
 
        /*****************************************
index 47a7bd1..e30555b 100644 (file)
@@ -1128,7 +1128,7 @@ class EditDocumentController {
                                $buttons['save_view'] = IconUtility::getSpriteIcon('actions-document-save-view', array('html' => '<input onclick="window.open(\'\', \'newTYPO3frontendWindow\');" type="image" class="c-inputButton" name="_savedokview" src="clear.gif" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveDocShow', TRUE) . '" />'));
                        }
                        // SAVE / NEW button:
-                       if (count($this->elementsData) == 1 && $this->getNewIconMode($this->firstEl['table'])) {
+                       if (count($this->elementsData) === 1 && $this->getNewIconMode($this->firstEl['table'])) {
                                $buttons['save_new'] = IconUtility::getSpriteIcon('actions-document-save-new', array('html' => '<input type="image" class="c-inputButton" name="_savedoknew" src="clear.gif" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.saveNewDoc', TRUE) . '" />'));
                        }
                        // SAVE / CLOSE
@@ -1142,7 +1142,7 @@ class EditDocumentController {
                // CLOSE button:
                $buttons['close'] = '<a href="#" class="t3js-editform-close" title="' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:rm.closeDoc', TRUE) . '">' . IconUtility::getSpriteIcon('actions-document-close') . '</a>';
                // DELETE + UNDO buttons:
-               if (!$this->errorC && !$GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly'] && count($this->elementsData) == 1) {
+               if (!$this->errorC && !$GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly'] && count($this->elementsData) === 1) {
                        if ($this->firstEl['cmd'] != 'new' && MathUtility::canBeInterpretedAsInteger($this->firstEl['uid'])) {
                                // Delete:
                                if ($this->firstEl['deleteAccess'] && !$GLOBALS['TCA'][$this->firstEl['table']]['ctrl']['readOnly'] && !$this->getNewIconMode($this->firstEl['table'], 'disableDelete')) {
@@ -1201,7 +1201,7 @@ class EditDocumentController {
         */
        public function langSelector() {
                $langSelector = '';
-               if (count($this->elementsData) == 1) {
+               if (count($this->elementsData) === 1) {
                        $langSelector = $this->languageSwitch($this->firstEl['table'], $this->firstEl['uid'], $this->firstEl['pid']);
                }
                return $langSelector;
index 5528164..754ea43 100644 (file)
@@ -1065,7 +1065,7 @@ class PageLayoutController {
                        $content .= $this->doc->sectionEnd();
                }
                // Making search form:
-               if (!$this->modTSconfig['properties']['disableSearchBox'] && count($tableOutput)) {
+               if (!$this->modTSconfig['properties']['disableSearchBox'] && !empty($tableOutput)) {
                        $this->markers['BUTTONLIST_ADDITIONAL'] = '<a href="#" onclick="toggleSearchToolbox(); return false;" title="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.title.searchIcon', TRUE) . '">'.IconUtility::getSpriteIcon('apps-toolbar-menu-search').'</a>';
                        $this->markers['SEARCHBOX'] = $dbList->getSearchBox(0);
                }
index 092255b..c3278fd 100644 (file)
@@ -259,7 +259,7 @@ class GroupElement extends AbstractFormElement {
                                                'name' => htmlspecialchars($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.allTables'))
                                        );
                                } elseif ($allowed) {
-                                       $onlySingleTableAllowed = count($allowed) == 1;
+                                       $onlySingleTableAllowed = count($allowed) === 1;
                                        foreach ($allowed as $allowedTable) {
                                                $allowedTables[] = array(
                                                        'name' => htmlspecialchars($languageService->sL($GLOBALS['TCA'][$allowedTable]['ctrl']['title'])),
index 8db2d8d..f3a6fe1 100644 (file)
@@ -170,9 +170,10 @@ class FormDataTraverser {
                }
 
                $relatedRow = FALSE;
-               if (count($possibleUids) === 1) {
+               $possibleUidsCount = count($possibleUids);
+               if ($possibleUidsCount === 1) {
                        $relatedRow = $this->getRecordRow($possibleUids[0]);
-               } elseif (count($possibleUids) > 1) {
+               } elseif ($possibleUidsCount > 1) {
                        $relatedRow = $this->getMatchingRecordRowByTranslation($possibleUids, $fieldConfig);
                }
 
index 16f8294..f18d706 100644 (file)
@@ -196,7 +196,7 @@ class DataProvider extends \TYPO3\CMS\Backend\Tree\AbstractTreeDataProvider {
                /** @var $nodeCollection \TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNodeCollection */
                $nodeCollection = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Tree\Pagetree\PagetreeNodeCollection::class);
                $records = $this->getSubpages(-1, $searchFilter);
-               if (!is_array($records) || !count($records)) {
+               if (!is_array($records) || empty($records)) {
                        return $nodeCollection;
                } elseif (count($records) > 500) {
                        return $nodeCollection;
index fac51e0..5cedd05 100644 (file)
@@ -614,7 +614,7 @@ abstract class AbstractTreeView {
                // must update the stored positions in the tree):
                // 0: mount key, 1: set/clear boolean, 2: item ID (cannot contain "_"), 3: treeName
                $PM = explode('_', GeneralUtility::_GP('PM'));
-               if (count($PM) == 4 && $PM[3] == $this->treeName) {
+               if (count($PM) === 4 && $PM[3] == $this->treeName) {
                        if (isset($this->MOUNTS[$PM[0]])) {
                                // set
                                if ($PM[1]) {
index 48ca1af..aec89b5 100644 (file)
@@ -912,7 +912,7 @@ class BackendUtility {
                if (is_array($pArr)) {
                        foreach ($pArr as $k => $v) {
                                $parts = explode('=', $v, 2);
-                               if (count($parts) == 2) {
+                               if (count($parts) === 2) {
                                        $out[trim($parts[0])] = trim($parts[1]);
                                } else {
                                        $out[$k] = $v;
@@ -963,7 +963,7 @@ class BackendUtility {
                                // Up to two pointer fields can be specified in a comma separated list.
                                $pointerFields = GeneralUtility::trimExplode(',', $ds_pointerField);
                                // If we have two pointer fields, the array keys should contain both field values separated by comma. The asterisk "*" catches all values. For backwards compatibility, it's also possible to specify only the value of the first defined ds_pointerField.
-                               if (count($pointerFields) == 2) {
+                               if (count($pointerFields) === 2) {
                                        if ($ds_array[$row[$pointerFields[0]] . ',' . $row[$pointerFields[1]]]) {
                                                // Check if we have a DS for the combination of both pointer fields values
                                                $srcPointer = $row[$pointerFields[0]] . ',' . $row[$pointerFields[1]];
@@ -2329,7 +2329,7 @@ class BackendUtility {
                                }
                                break;
                        case 'check':
-                               if (!is_array($theColConf['items']) || count($theColConf['items']) == 1) {
+                               if (!is_array($theColConf['items']) || count($theColConf['items']) === 1) {
                                        $l = $value ? $lang->sL('LLL:EXT:lang/locallang_common.xlf:yes') : $lang->sL('LLL:EXT:lang/locallang_common.xlf:no');
                                } else {
                                        $lA = array();
@@ -2812,7 +2812,7 @@ class BackendUtility {
                        // Traverse the view order, match first occurrence:
                        $languageOrder = GeneralUtility::intExplode(',', $viewLanguageOrder);
                        foreach ($languageOrder as $langUid) {
-                               if (is_array($allowedLanguages) && count($allowedLanguages)) {
+                               if (is_array($allowedLanguages) && !empty($allowedLanguages)) {
                                        // Choose if set.
                                        if (isset($allowedLanguages[$langUid])) {
                                                $suffix = '&L=' . $langUid;
@@ -4212,7 +4212,7 @@ class BackendUtility {
                                                . ' AND A.t3ver_wsid=' . (int)$workspace . ' AND ' . $joinStatement
                                                . self::deleteClause($tableName, 'A') . self::deleteClause($tableName, 'B')
                                );
-                               if (!is_array($output[$tableName]) || !count($output[$tableName])) {
+                               if (!is_array($output[$tableName]) || empty($output[$tableName])) {
                                        unset($output[$tableName]);
                                }
                        }
index 5b5b84a..3290f53 100644 (file)
@@ -559,7 +559,7 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                                        }
 
                                        $pasteP = array('colPos' => $key, 'sys_language_uid' => $lP);
-                                       $editParam = $this->doEdit && count($rowArr)
+                                       $editParam = $this->doEdit && !empty($rowArr)
                                                ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc
                                                : '';
                                        $head[$key] .= $this->tt_content_drawColHeader($colTitle, $editParam, $newP, $pasteP);
@@ -826,7 +826,7 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
                                                        <td></td>
                                                        <td valign="top" colspan="3">' . $this->tt_content_drawColHeader(
                                                                BackendUtility::getProcessedValue('tt_content', 'colPos', $key),
-                                                               $this->doEdit && count($rowArr) ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : '',
+                                                               $this->doEdit && !empty($rowArr) ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : '',
                                                                $newP,
                                                                $pasteP
                                                        ) . $theNewButton . '<br /></td>
index 340578c..1cfff98 100644 (file)
@@ -162,7 +162,7 @@ class PageTreeView extends \TYPO3\CMS\Backend\Tree\View\BrowseTreeView {
                        $PM = substr($PM, 0, $PMpos);
                }
                $PM = explode('_', $PM);
-               if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX && is_array($PM) && count($PM) == 4 && $PM[2] != 0) {
+               if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX && is_array($PM) && count($PM) === 4 && $PM[2] != 0) {
                        if ($PM[1]) {
                                $expandedPageUid = $PM[2];
                                $ajaxOutput = '';