Use strict compare for count function

Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
William Desportes 2019-06-22 17:41:34 +02:00
parent 64c1b26bac
commit a2268169ae
No known key found for this signature in database
GPG Key ID: 90A0EF1B8251A889
28 changed files with 44 additions and 44 deletions

View File

@ -101,7 +101,7 @@ if (isset($_POST['delete_tracking']) && isset($_POST['table'])) {
$data = Tracker::getTrackedData($db, '', '1');
// No tables present and no log exist
if ($num_tables == 0 && count($data['ddlog']) == 0) {
if ($num_tables == 0 && count($data['ddlog']) === 0) {
echo '<p>' , __('No tables found in database.') , '</p>' , "\n";
if (empty($db_is_system_schema)) {

View File

@ -411,7 +411,7 @@ if ($save_on_server) {
// HTML
if ($export_type == 'database') {
$num_tables = count($tables);
if ($num_tables == 0) {
if ($num_tables === 0) {
$message = PhpMyAdmin\Message::error(
__('No tables found in database.')
);

View File

@ -1053,7 +1053,7 @@ class CentralColumns
//get current values of $db from central column list
$query = 'SELECT COUNT(db_name) FROM ' . Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . $this->dbi->escapeString($db) . '\'' .
($num == 0 ? '' : 'LIMIT ' . $from . ', ' . $num) . ';';
($num === 0 ? '' : 'LIMIT ' . $from . ', ' . $num) . ';';
$result = (array) $this->dbi->fetchResult(
$query,
null,

View File

@ -1717,7 +1717,7 @@ class Config
public function checkServers(): void
{
// Do we have some server?
if (! isset($this->settings['Servers']) || count($this->settings['Servers']) == 0) {
if (! isset($this->settings['Servers']) || count($this->settings['Servers']) === 0) {
// No server => create one with defaults
$this->settings['Servers'] = [1 => $this->default_server];
} else {

View File

@ -519,7 +519,7 @@ class FormDisplay
public function displayErrors()
{
$this->_validate();
if (count($this->_errors) == 0) {
if (count($this->_errors) === 0) {
return null;
}
@ -545,7 +545,7 @@ class FormDisplay
public function fixErrors()
{
$this->_validate();
if (count($this->_errors) == 0) {
if (count($this->_errors) === 0) {
return;
}

View File

@ -88,7 +88,7 @@ class HomeController extends AbstractController
$hasServerSelection = $cfg['ServerDefault'] == 0
|| (! $cfg['NavigationDisplayServers']
&& (count($cfg['Servers']) > 1
|| ($server == 0 && count($cfg['Servers']) == 1)));
|| ($server == 0 && count($cfg['Servers']) === 1)));
if ($hasServerSelection) {
$serverSelection = Select::render(true, true);
}

View File

@ -321,7 +321,7 @@ class DatabasesController extends AbstractController
);
if (strlen((string) $key) > 0
|| count($replication_info[$type]['Do_DB']) == 0
|| count($replication_info[$type]['Do_DB']) === 0
) {
// if ($key != null) did not work for index "0"
$replication[$type]['is_replicated'] = true;

View File

@ -129,7 +129,7 @@ class HomeController extends AbstractController
if ($this->config->getServerCount() > 0) {
$serverDefaultOptions['values']['0'] = __('let the user choose');
$serverDefaultOptions['values']['-'] = '------------------------------';
if ($this->config->getServerCount() == 1) {
if ($this->config->getServerCount() === 1) {
$serverDefaultOptions['values_disabled'][] = '0';
}
$serverDefaultOptions['values_disabled'][] = '-';

View File

@ -191,7 +191,7 @@ class StructureController extends AbstractController
if (Context::isKeyword(trim($this->table), true)) {
$reserved_keywords_names[] = trim($this->table);
}
if (count($reserved_keywords_names) == 0) {
if (count($reserved_keywords_names) === 0) {
$this->response->setRequestStatus(false);
}
$this->response->addJSON(
@ -541,7 +541,7 @@ class StructureController extends AbstractController
$selected[$i],
true
);
if (count($value) == 0) {
if (count($value) === 0) {
$message = Message::error(
__('Failed to get description of column %s!')
);

View File

@ -735,7 +735,7 @@ class Core
// remove empty nested arrays
for (; $depth >= 0; $depth--) {
if (! isset($path[$depth + 1]) || count($path[$depth + 1]) == 0) {
if (! isset($path[$depth + 1]) || count($path[$depth + 1]) === 0) {
unset($path[$depth][$keys[$depth]]);
} else {
break;

View File

@ -1367,7 +1367,7 @@ class Qbe
array $where_clause_columns,
array $where_clause_tables
) {
if (count($where_clause_tables) == 1) {
if (count($where_clause_tables) === 1) {
// If there is exactly one column that has a decent where-clause
// we will just use this
return key($where_clause_tables);
@ -1614,7 +1614,7 @@ class Qbe
}
// We are done if no unfinalized tables anymore
if (count($tempUnfinalized) == 0) {
if (count($tempUnfinalized) === 0) {
break 3;
}
}

View File

@ -1331,7 +1331,7 @@ class DatabaseInterface
): array {
$sql = $this->getColumnsSql($database, $table, $column, $full);
$fields = $this->fetchResult($sql, 'Field', null, $link);
if (! is_array($fields) || count($fields) == 0) {
if (! is_array($fields) || count($fields) === 0) {
return [];
}
// Check if column is a part of multiple-column index and set its 'Key'.
@ -1379,7 +1379,7 @@ class DatabaseInterface
// We only need the 'Field' column which contains the table's column names
$fields = array_keys($this->fetchResult($sql, 'Field', null, $link));
if (! is_array($fields) || count($fields) == 0) {
if (! is_array($fields) || count($fields) === 0) {
return null;
}
return $fields;
@ -2418,7 +2418,7 @@ class DatabaseInterface
*/
public function getCurrentUserAndHost(): array
{
if (count($this->_current_user) == 0) {
if (count($this->_current_user) === 0) {
$user = $this->getCurrentUser();
$this->_current_user = explode("@", $user);
}

View File

@ -727,7 +727,7 @@ class Results
|| $this->__get('is_analyse'))
&& ! empty($analyzed_sql_results['select_from'])
&& ! empty($analyzed_sql_results['statement']->from)
&& (count($analyzed_sql_results['statement']->from) == 1)
&& (count($analyzed_sql_results['statement']->from) === 1)
&& ! empty($analyzed_sql_results['statement']->from[0]->table);
}
@ -4923,7 +4923,7 @@ class Results
&& ! isset($printview)
&& empty($analyzed_sql_results['procedure'])
) {
if (count($analyzed_sql_results['select_tables']) == 1) {
if (count($analyzed_sql_results['select_tables']) === 1) {
$_url_params['single_table'] = 'true';
}

View File

@ -827,7 +827,7 @@ class Import
if ($cell == (string) (float) $cell
&& mb_strpos($cell, ".") !== false
&& mb_substr_count($cell, ".") == 1
&& mb_substr_count($cell, ".") === 1
) {
return self::DECIMAL;
}
@ -1212,7 +1212,7 @@ class Import
for ($i = 0; $i < $additional_sql_len; ++$i) {
preg_match($view_pattern, $additional_sql[$i], $regs);
if (count($regs) == 0) {
if (count($regs) === 0) {
preg_match($table_pattern, $additional_sql[$i], $regs);
}
@ -1681,7 +1681,7 @@ class Import
public function isTableTransactional(string $table): bool
{
$table = explode('.', $table);
if (count($table) == 2) {
if (count($table) === 2) {
$db = Util::unQuote($table[0]);
$table = Util::unQuote($table[1]);
} else {

View File

@ -383,7 +383,7 @@ class NavigationTree
return $retval;
}
if (count($containers) == 1) {
if (count($containers) === 1) {
$container = array_shift($containers);
} else {
$container = $db->getChild($path[0], true);
@ -759,7 +759,7 @@ class NavigationTree
}
}
// rfe #1634 Don't group if there's only one group and no other items
if (count($prefixes) == 1) {
if (count($prefixes) === 1) {
$keys = array_keys($prefixes);
$key = $keys[0];
if ($prefixes[$key] == count($node->children) - 1) {
@ -1059,7 +1059,7 @@ class NavigationTree
) {
$response = Response::getInstance();
if ($node->type == Node::CONTAINER
&& count($node->children) == 0
&& count($node->children) === 0
&& ! $response->isAjax()
) {
return '';

View File

@ -509,7 +509,7 @@ class Normalization
__('The second step of normalization is complete for table \'%1$s\'.'),
htmlspecialchars($table)
) . '</h3>';
if (count((array) $partialDependencies) == 1) {
if (count((array) $partialDependencies) === 1) {
return [
'legendText' => __('End of step'),
'headText' => $headText,
@ -582,7 +582,7 @@ class Normalization
$i = 1;
$newTables = [];
foreach ($tables as $table => $arrDependson) {
if (count(array_unique($arrDependson)) == 1) {
if (count(array_unique($arrDependson)) === 1) {
continue;
}
$primary = Index::getPrimary($table, $db);
@ -648,7 +648,7 @@ class Normalization
$headText = '<h3>' .
__('The third step of normalization is complete.')
. '</h3>';
if (count((array) $newTables) == 0) {
if (count((array) $newTables) === 0) {
return [
'legendText' => __('End of step'),
'headText' => $headText,

View File

@ -377,7 +377,7 @@ class Plugins
if (method_exists($propertyGroup, "getDoc")) {
$doc = $propertyGroup->getDoc();
if ($doc != null) {
if (count($doc) == 3) {
if (count($doc) === 3) {
$ret .= Util::showMySQLDocu(
$doc[1],
false,
@ -385,7 +385,7 @@ class Plugins
null,
$doc[2]
);
} elseif (count($doc) == 1) {
} elseif (count($doc) === 1) {
$ret .= Util::showDocu('faq', $doc[0]);
} else {
$ret .= Util::showMySQLDocu(

View File

@ -376,7 +376,7 @@ class AuthenticationCookie extends AuthenticationPlugin
) {
if ($GLOBALS['cfg']['ArbitraryServerRegexp']) {
$parts = explode(' ', $_REQUEST['pma_servername']);
if (count($parts) == 2) {
if (count($parts) === 2) {
$tmp_host = $parts[0];
} else {
$tmp_host = $_REQUEST['pma_servername'];
@ -491,7 +491,7 @@ class AuthenticationCookie extends AuthenticationPlugin
) {
/* Allow to specify 'host port' */
$parts = explode(' ', $GLOBALS['pma_auth_server']);
if (count($parts) == 2) {
if (count($parts) === 2) {
$tmp_host = $parts[0];
$tmp_port = $parts[1];
} else {

View File

@ -561,7 +561,7 @@ class ImportMediawiki extends ImportPlugin
return $cell;
}
if (count($cell_data) == 1) {
if (count($cell_data) === 1) {
return $cell_data[0];
}

View File

@ -281,7 +281,7 @@ class ImportOds extends ImportPlugin
}
/* Skip over empty sheets */
if (count($tempRows) == 0 || count($tempRows[0]) == 0) {
if (count($tempRows) == 0 || count($tempRows[0]) === 0) {
$col_names = [];
$tempRow = [];
$tempRows = [];

View File

@ -237,7 +237,7 @@ class ImportShp extends ImportPlugin
}
}
if (count($rows) == 0) {
if (count($rows) === 0) {
$error = true;
$message = Message::error(
__('The imported file does not contain any data!')

View File

@ -4554,7 +4554,7 @@ class Privileges
if (isset($is_valid_pred_dbname) && $is_valid_pred_dbname) {
$dbname = $_POST['pred_dbname'];
// If dbname contains only one database.
if (count($dbname) == 1) {
if (count($dbname) === 1) {
$dbname = $dbname[0];
}
} elseif (isset($is_valid_dbname) && $is_valid_dbname) {

View File

@ -527,9 +527,9 @@ class Sql
&& isset($analyzed_sql_results['select_expr'])
&& isset($analyzed_sql_results['select_tables'])
&& (empty($analyzed_sql_results['select_expr'])
|| ((count($analyzed_sql_results['select_expr']) == 1)
|| ((count($analyzed_sql_results['select_expr']) === 1)
&& ($analyzed_sql_results['select_expr'][0] == '*')))
&& count($analyzed_sql_results['select_tables']) == 1;
&& count($analyzed_sql_results['select_tables']) === 1;
}
/**
@ -574,7 +574,7 @@ class Sql
&& $analyzed_sql_results['select_from']
&& (count($analyzed_sql_results['select_tables']) === 1)
&& (empty($analyzed_sql_results['statement']->where)
|| (count($analyzed_sql_results['statement']->where) == 1
|| (count($analyzed_sql_results['statement']->where) === 1
&& $analyzed_sql_results['statement']->where[0]->expr === '1'))
&& empty($analyzed_sql_results['group'])
&& ! isset($find_real_end)

View File

@ -316,7 +316,7 @@ class Table
// we have to get the table's details
if ($this->_dbi->getCachedTableContent([$db, $table]) == null
|| $force_read
|| count($this->_dbi->getCachedTableContent([$db, $table])) == 1
|| count($this->_dbi->getCachedTableContent([$db, $table])) === 1
) {
$this->_dbi->getTablesFull($db, $table);
}

View File

@ -301,7 +301,7 @@ class Tracking
/*
* First, list tracked data definition statements
*/
if (count($data['ddlog']) == 0 && count($data['dmlog']) == 0) {
if (count($data['ddlog']) == 0 && count($data['dmlog']) === 0) {
$msg = Message::notice(__('No data'));
$msg->display();
}

View File

@ -153,7 +153,7 @@ class VersionInformation
// We evalute MySQL version constraint if there are only
// one server configured.
if (count($GLOBALS['cfg']['Servers']) == 1) {
if (count($GLOBALS['cfg']['Servers']) === 1) {
$mysqlVersions = $release->mysql_versions;
$mysqlConditions = explode(",", $mysqlVersions);
foreach ($mysqlConditions as $mysqlCondition) {

View File

@ -221,7 +221,7 @@ for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
Util::getValueByKey($_POST, "field_key.${columnNumber}", ''),
2
);
if (count($parts) == 2 && $parts[1] == $columnNumber) {
if (count($parts) === 2 && $parts[1] == $columnNumber) {
$columnMeta['Key'] = Util::getValueByKey(
[
'primary' => 'PRI',

View File

@ -76,7 +76,7 @@ class PmaTestCase extends TestCase
if (count($param) > 0) {
if (is_array($param[0])) {
if (is_array($param[0][0]) && count($param) == 1) {
if (is_array($param[0][0]) && count($param) === 1) {
$param = $param[0];
if (is_int(end($param))) {
$http_response_code_param = end($param);