Commit 0eeb13a0 authored by Stephan Großberndt's avatar Stephan Großberndt Committed by Christian Kuhn
Browse files

[CLEANUP] Replace count with empty in multiple extensions, part IV

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

Affected extensions:

* compatibility6
* css_styled_content
* dbal
* documentation
* extbase
* frontend
* indexed_search
* lang
* linkvalidator

Resolves: #67965
Releases: master
Change-Id: Ia7ee4bec0e36639ef28b0cd192484f8a22c6f1f1
Reviewed-on: http://review.typo3.org/40968


Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 19cf9671
......@@ -146,7 +146,7 @@ class FormContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractConten
}
$typeParts = explode('=', $fParts[0]);
$confData['type'] = trim(strtolower(end($typeParts)));
if (count($typeParts) == 1) {
if (count($typeParts) === 1) {
$confData['fieldname'] = $this->cleanFormName($parts[0]);
if (strtolower(preg_replace('/[^[:alnum:]]/', '', $confData['fieldname'])) == 'email') {
$confData['fieldname'] = 'email';
......
......@@ -764,7 +764,7 @@ class FormsController extends \TYPO3\CMS\Backend\Controller\Wizard\AbstractWizar
$typeParts = GeneralUtility::trimExplode('=', $fParts[0]);
$confData['type'] = trim(strtolower(end($typeParts)));
if ($confData['type']) {
if (count($typeParts) == 1) {
if (count($typeParts) === 1) {
$confData['fieldname'] = substr(preg_replace('/[^a-zA-Z0-9_]/', '', str_replace(' ', '_', trim($parts[0]))), 0, 30);
// Attachment names...
if ($confData['type'] == 'file') {
......
......@@ -994,7 +994,7 @@ class CssStyledContentController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlug
}
$this->frontendController->register['columnwidth'] = $maxImageSpace + $tmpColspacing;
// Close this row at the end (colCount), or the last row at the final end
if ($separateRows && $i + 1 == count($imgsTag)) {
if ($separateRows && $i + 1 === count($imgsTag)) {
// Close the very last row with either normal configuration or lastRow stdWrap
$allRows .= $this->cObj->stdWrap(
$thisRow,
......
......@@ -3363,9 +3363,10 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
case 'CASE':
if (isset($sqlPartArray[$k]['case_field'])) {
$fieldArray = explode('.', $sqlPartArray[$k]['case_field']);
if (count($fieldArray) == 1 && is_array($this->mapping[$defaultTableKey]['mapFieldNames']) && isset($this->mapping[$defaultTableKey]['mapFieldNames'][$fieldArray[0]])) {
$fieldArrayCount = count($fieldArray);
if ($fieldArrayCount === 1 && is_array($this->mapping[$defaultTableKey]['mapFieldNames']) && isset($this->mapping[$defaultTableKey]['mapFieldNames'][$fieldArray[0]])) {
$sqlPartArray[$k]['case_field'] = $this->mapping[$defaultTableKey]['mapFieldNames'][$fieldArray[0]];
} elseif (count($fieldArray) == 2) {
} elseif ($fieldArrayCount === 2) {
// Map the external table
$table = $fieldArray[0];
$tableKey = $this->getMappingKey($table);
......@@ -3421,10 +3422,11 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
// Mapping field name in SQL-functions like MIN(), MAX() or SUM()
if ($this->mapping[$t]['mapFieldNames']) {
$fieldArray = explode('.', $sqlPartArray[$k]['func_content']);
if (count($fieldArray) == 1 && is_array($this->mapping[$t]['mapFieldNames']) && isset($this->mapping[$t]['mapFieldNames'][$fieldArray[0]])) {
$fieldArrayCount = count($fieldArray);
if ($fieldArrayCount === 1 && is_array($this->mapping[$t]['mapFieldNames']) && isset($this->mapping[$t]['mapFieldNames'][$fieldArray[0]])) {
$sqlPartArray[$k]['func_content.'][0]['func_content'] = $this->mapping[$t]['mapFieldNames'][$fieldArray[0]];
$sqlPartArray[$k]['func_content'] = $this->mapping[$t]['mapFieldNames'][$fieldArray[0]];
} elseif (count($fieldArray) == 2) {
} elseif ($fieldArrayCount === 2) {
// Map the external table
$table = $fieldArray[0];
$tableKey = $this->getMappingKey($table);
......@@ -3469,9 +3471,10 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
// this is a very simplistic check, beware
if (!is_numeric($sqlPartArray[$k]['value'][0]) && !isset($sqlPartArray[$k]['value'][1])) {
$fieldArray = explode('.', $sqlPartArray[$k]['value'][0]);
if (count($fieldArray) == 1 && is_array($this->mapping[$t]['mapFieldNames']) && isset($this->mapping[$t]['mapFieldNames'][$fieldArray[0]])) {
$fieldArrayCount = count($fieldArray);
if ($fieldArrayCount === 1 && is_array($this->mapping[$t]['mapFieldNames']) && isset($this->mapping[$t]['mapFieldNames'][$fieldArray[0]])) {
$sqlPartArray[$k]['value'][0] = $this->mapping[$t]['mapFieldNames'][$fieldArray[0]];
} elseif (count($fieldArray) == 2) {
} elseif ($fieldArrayCount === 2) {
// Map the external table
$table = $fieldArray[0];
$tableKey = $this->getMappingKey($table);
......
......@@ -152,8 +152,9 @@ class DatabaseConnectionOracleTest extends AbstractTestCase {
$components = $this->subject->SQLparser->_callRef('parseINSERT', $parseString);
$this->assertTrue(is_array($components), $components);
$insert = $this->subject->SQLparser->_callRef('compileINSERT', $components);
$this->assertEquals(4, count($insert));
for ($i = 0; $i < count($insert); $i++) {
$insertCount = count($insert);
$this->assertEquals(4, $insertCount);
for ($i = 0; $i < $insertCount; $i++) {
foreach ($tableFields as $field) {
$this->assertTrue(isset($insert[$i][$field]), 'Could not find ' . $field . ' column');
}
......@@ -174,8 +175,9 @@ class DatabaseConnectionOracleTest extends AbstractTestCase {
$expected[0] = 'INSERT INTO "tt_content" ( "uid", "pid", "title", "body" ) VALUES ( \'1\', \'2\', \'Title #1\', \'Content #1\' )';
$expected[1] = 'INSERT INTO "tt_content" ( "uid", "pid", "title", "body" ) VALUES ( \'3\', \'4\', \'Title #2\', \'Content #2\' )';
$expected[2] = 'INSERT INTO "tt_content" ( "uid", "pid", "title", "body" ) VALUES ( \'5\', \'6\', \'Title #3\', \'Content #3\' )';
$this->assertEquals(count($expected), count($result));
for ($i = 0; $i < count($result); $i++) {
$resultCount = count($result);
$this->assertEquals(count($expected), $resultCount);
for ($i = 0; $i < $resultCount; $i++) {
$this->assertTrue(is_array($result[$i]), 'Expected array: ' . $result[$i]);
$this->assertEquals(1, count($result[$i]));
$this->assertEquals($expected[$i], $this->cleanSql($result[$i][0]));
......
......@@ -242,7 +242,7 @@ class DocumentationService {
*/
protected function parsePackagesXML($string) {
$data = json_decode(json_encode((array)simplexml_load_string($string)), TRUE);
if (count($data) != 2) {
if (count($data) !== 2) {
throw new \TYPO3\CMS\Documentation\Exception\XmlParser('Error in XML parser while decoding packages XML file.', 1374222437);
}
......
......@@ -114,7 +114,7 @@ class ClassInfoFactory {
$reflectedProperty = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Reflection\PropertyReflection::class, $reflectedClass->getName(), $reflectionProperty->getName());
if ($reflectedProperty->isTaggedWith('inject') && $reflectedProperty->getName() !== 'settings') {
$varValues = $reflectedProperty->getTagValues('var');
if (count($varValues) == 1) {
if (count($varValues) === 1) {
$result[$reflectedProperty->getName()] = ltrim($varValues[0], '\\');
}
}
......
......@@ -329,7 +329,7 @@ class Backend implements \TYPO3\CMS\Extbase\Persistence\Generic\BackendInterface
// objectstorage needs to be persisted if the object is new, the objectstorge is dirty, meaning it has
// been changed after initial build, or a empty objectstorge is present and the cleanstate objectstorage
// has childelements, meaning all elements should been removed from the objectstorage
if ($object->_isNew() || $propertyValue->_isDirty() || ($propertyValue->count() == 0 && $cleanProperty && $cleanProperty->count() > 0)) {
if ($object->_isNew() || $propertyValue->_isDirty() || ($propertyValue->count() === 0 && $cleanProperty && $cleanProperty->count() > 0)) {
$this->persistObjectStorage($propertyValue, $object, $propertyName, $row);
$propertyValue->_memorizeCleanState();
}
......
......@@ -276,14 +276,15 @@ class DebuggerUtility {
$dump .= '<span class="debug-filtered">max depth</span>';
}
} elseif ($level > 1 && !$object instanceof \DateTime && !$plainText) {
if (($object instanceof \Countable && count($object) === 0) || empty($classReflection->getProperties())) {
if (($object instanceof \Countable && empty($object)) || empty($classReflection->getProperties())) {
$dump = '<span>' . $dump . '</span>';
} else {
$dump = '<input type="checkbox" id="' . spl_object_hash($object) . '" /><span class="debug-header">' . $dump . '</span>';
}
}
if ($object instanceof \Countable) {
$dump .= count($object) > 0 ? ' (' . count($object) . ' items)' : ' (empty)';
$objectCount = count($object);
$dump .= $objectCount > 0 ? ' (' . $objectCount . ' items)' : ' (empty)';
}
if ($object instanceof \DateTime) {
$dump .= ' (' . $object->format(\DateTime::RFC3339) . ', ' . $object->getTimestamp() . ')';
......
......@@ -4204,7 +4204,6 @@ class ContentObjectRenderer {
if ($tagName !== NULL) {
// Seek for the closing (or opening) tag.
$seekingTagName = '';
$countSplittedContent = count($splittedContent);
for ($seekingOffset = $offset + 2; $seekingOffset < $countSplittedContent; $seekingOffset = $seekingOffset + 2) {
preg_match($chars < 0 ? $openingTagRegEx : $closingTagRegEx, $splittedContent[$seekingOffset], $matches);
$seekingTagName = isset($matches[1]) ? $matches[1] : NULL;
......@@ -6720,7 +6719,7 @@ class ContentObjectRenderer {
// If two PIDs matches and this is NOT the site root, start accumulation of MP data (on the next level):
// (The check for site root is done so links to branches outsite the site but sharing the site roots PID
// is NOT detected as within the branch!)
if ($tCR_data['pid'] == $invTmplRLRec['pid'] && count($inverseTmplRootline) != $rlKey + 1) {
if ($tCR_data['pid'] == $invTmplRLRec['pid'] && count($inverseTmplRootline) !== $rlKey + 1) {
$startMPaccu = TRUE;
}
}
......@@ -6914,7 +6913,7 @@ class ContentObjectRenderer {
public function callUserFunction($funcName, $conf, $content) {
// Split parts
$parts = explode('->', $funcName);
if (count($parts) == 2) {
if (count($parts) === 2) {
// Class
// Check whether class is available and try to reload includeLibs if possible:
if ($this->isClassAvailable($parts[0], $conf)) {
......@@ -7057,7 +7056,7 @@ class ContentObjectRenderer {
$labels = str_replace('"', '', $labels);
}
$labelArr = explode('|', $labels);
if (count($labelArr) == 4) {
if (count($labelArr) === 4) {
$labelArr = array_merge($labelArr, $labelArr);
}
$absSeconds = abs($seconds);
......@@ -8041,7 +8040,7 @@ class ContentObjectRenderer {
$listArr[] = -1;
$enableFieldsIgnore['pid'] = TRUE;
}
if (count($listArr)) {
if (!empty($listArr)) {
$query .= ' AND ' . $table . '.pid IN (' . implode(',', array_map('intval', $listArr)) . ')';
$pid_uid_flag++;
} else {
......
......@@ -353,7 +353,7 @@ class Indexer {
public function init() {
// Initializing:
$this->cHashParams = $this->conf['cHash_array'];
if (is_array($this->cHashParams) && count($this->cHashParams)) {
if (is_array($this->cHashParams) && !empty($this->cHashParams)) {
if ($this->conf['cHash']) {
// Add this so that URL's come out right...
$this->cHashParams['cHash'] = $this->conf['cHash'];
......
......@@ -60,7 +60,7 @@ class LanguageCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\Comman
$this->emitPackagesMayHaveChangedSignal();
$packages = $packageManager->getAvailablePackages();
$this->outputLine((sprintf('Updating language packs of all activated extensions for locales "%s"', implode(', ', $locales))));
$this->output->progressStart(count($locales)*count($packages));
$this->output->progressStart(count($locales) * count($packages));
foreach ($locales as $locale) {
/** @var PackageInterface $package */
foreach ($packages as $package) {
......
......@@ -133,7 +133,7 @@ class LinkAnalyzer {
*/
public function getLinkStatistics($checkOptions = array(), $considerHidden = FALSE) {
$results = array();
if (count($checkOptions) > 0) {
if (!empty($checkOptions)) {
$checkKeys = array_keys($checkOptions);
$checkLinkTypeCondition = ' AND link_type IN (\'' . implode('\',\'', $checkKeys) . '\')';
$this->getDatabaseConnection()->exec_DELETEquery(
......
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