Applying suggestions from static analysis tools (#19013)

* Drop array keys from lists

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Import UrlTest

When it doesn't exist in Prod, the code will still work the same.
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Drop redundant return [];

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Fix object access checks

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Use strict comparison

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Int keys should be specified as integers

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Use empty string check instead of strlen

Potential null deprecations are replaced with loose condition.

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Use stripos instead of *substr

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Simplify substr's 3rd param

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove unnecessary defaults

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Replace isZeroBasedArray with array_is_list

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Simplify texEscape()

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Simplify exportZeroBasedArray()

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Replace for loop with array_diff

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Replace for with foreach

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove nullable param in backquoteCompat

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Use null-coalescing operator

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Inline $result variable

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Turn $event into a constant

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Move selectDb outside the loop

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Fix code style order of operation

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove unnecessary isset argument

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Remove line break

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

* Use foreach instead of for

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>

---------

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2024-02-27 16:29:02 +01:00 committed by GitHub
parent e68e814e57
commit 8e4443b17b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
77 changed files with 256 additions and 425 deletions

View File

@ -1335,11 +1335,6 @@ parameters:
count: 2
path: src/ConfigStorage/Relation.php
-
message: "#^Parameter \\#1 \\$string of function strlen expects string, mixed given\\.$#"
count: 1
path: src/ConfigStorage/Relation.php
-
message: "#^Parameter \\#1 \\$type of method PhpMyAdmin\\\\Types\\:\\:getTypeClass\\(\\) expects string, mixed given\\.$#"
count: 1
@ -1375,11 +1370,6 @@ parameters:
count: 1
path: src/ConfigStorage/UserGroups.php
-
message: "#^Only booleans are allowed in &&, PhpMyAdmin\\\\Dbal\\\\ResultInterface\\|false given on the left side\\.$#"
count: 1
path: src/ConfigStorage/UserGroups.php
-
message: "#^Only booleans are allowed in &&, int\\|string given on the right side\\.$#"
count: 1
@ -3030,11 +3020,6 @@ parameters:
count: 1
path: src/Controllers/Operations/TableController.php
-
message: "#^Parameter \\#1 \\$string of function strlen expects string, mixed given\\.$#"
count: 1
path: src/Controllers/Operations/TableController.php
-
message: "#^Parameter \\#1 \\$urlParams of method PhpMyAdmin\\\\Operations\\:\\:getForeignersForReferentialIntegrityCheck\\(\\) expects array, mixed given\\.$#"
count: 1
@ -9610,11 +9595,6 @@ parameters:
count: 1
path: src/Normalization.php
-
message: "#^Only booleans are allowed in &&, int given on the left side\\.$#"
count: 2
path: src/Normalization.php
-
message: "#^Only booleans are allowed in a negated boolean, PhpMyAdmin\\\\Dbal\\\\ResultInterface\\|false given\\.$#"
count: 3
@ -10197,7 +10177,7 @@ parameters:
-
message: "#^Parameter \\#1 \\$string of function strlen expects string, mixed given\\.$#"
count: 2
count: 1
path: src/Plugins/Auth/AuthenticationCookie.php
-
@ -14080,11 +14060,6 @@ parameters:
count: 3
path: src/Table/Search.php
-
message: "#^Parameter \\#1 \\$string of function strlen expects string, mixed given\\.$#"
count: 1
path: src/Table/Search.php
-
message: "#^Parameter \\#1 \\$string of function trim expects string, mixed given\\.$#"
count: 3
@ -14650,11 +14625,6 @@ parameters:
count: 1
path: src/Transformations.php
-
message: "#^Parameter \\#1 \\$string of function strlen expects string, string\\|null given\\.$#"
count: 1
path: src/Transformations.php
-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
count: 1
@ -14990,11 +14960,6 @@ parameters:
count: 1
path: src/Util.php
-
message: "#^Only booleans are allowed in a negated boolean, bool\\|null given\\.$#"
count: 1
path: src/Util.php
-
message: "#^Only booleans are allowed in a negated boolean, int\\<0, 2\\> given\\.$#"
count: 1

View File

@ -721,7 +721,6 @@
<code><![CDATA[$foreignField]]></code>
<code><![CDATA[$foreignTable]]></code>
<code><![CDATA[$foreignTable]]></code>
<code><![CDATA[$foreign[$field]]]></code>
<code><![CDATA[$oneKey['index_list']]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
@ -5162,6 +5161,7 @@
<code><![CDATA[$_SESSION['tmpval']['query']]]></code>
<code><![CDATA[$_SESSION['tmpval']['query']]]></code>
<code><![CDATA[$_SESSION['tmpval']['query'][$sqlMd5]]]></code>
<code><![CDATA[$_SESSION['tmpval']['query'][$sqlMd5]]]></code>
<code><![CDATA[$_SESSION['tmpval']['query'][$sqlMd5]['max_rows']]]></code>
<code><![CDATA[$_SESSION['tmpval']['relational_display']]]></code>
<code><![CDATA[$_SESSION['tmpval']['relational_display']]]></code>
@ -5720,7 +5720,7 @@
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<FalsableReturnStatement>
<code><![CDATA[$this->detectCompression()]]></code>
<code><![CDATA[$this->compression ?? $this->detectCompression()]]></code>
</FalsableReturnStatement>
<InvalidArrayOffset>
<code><![CDATA[$_FILES['fields_upload']['name']['multi_edit']]]></code>
@ -7515,7 +7515,6 @@
<PossiblyInvalidArgument>
<code><![CDATA[$_POST[$config->settings['CaptchaResponseParam']]]]></code>
<code><![CDATA[$_POST['pma_username']]]></code>
<code><![CDATA[$_POST['pma_username']]]></code>
<code><![CDATA[$_REQUEST['pma_servername']]]></code>
<code><![CDATA[$_REQUEST['pma_servername']]]></code>
<code><![CDATA[$password]]></code>
@ -7797,11 +7796,9 @@
<code><![CDATA[$GLOBALS['latex_caption']]]></code>
<code><![CDATA[$GLOBALS['latex_caption']]]></code>
<code><![CDATA[$GLOBALS['latex_columns']]]></code>
<code><![CDATA[$escape[$k]]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$columnsAlias[$i]]]></code>
<code><![CDATA[$escape[$k]]]></code>
<code><![CDATA[$mimeMap[$fieldName]['mimetype']]]></code>
</MixedArgument>
<MixedArrayAccess>
@ -7816,7 +7813,6 @@
<MixedOperand>
<code><![CDATA[$colAs]]></code>
<code><![CDATA[$comments[$fieldName]]]></code>
<code><![CDATA[$escape[$k]]]></code>
<code><![CDATA[$type]]></code>
</MixedOperand>
<PossiblyFalseReference>
@ -10998,7 +10994,6 @@
<code><![CDATA[$criteriaValues]]></code>
<code><![CDATA[$criteriaValues]]></code>
<code><![CDATA[$criteriaValues]]></code>
<code><![CDATA[$criteriaValues]]></code>
<code><![CDATA[$criteriaValues[$e]]]></code>
<code><![CDATA[$criteriaValues[0]]]></code>
<code><![CDATA[$operator]]></code>
@ -11017,6 +11012,7 @@
<code><![CDATA[$criteriaValues]]></code>
<code><![CDATA[$criteriaValues]]></code>
<code><![CDATA[$criteriaValues]]></code>
<code><![CDATA[$criteriaValues]]></code>
<code><![CDATA[$needsQuoting ? $this->dbi->quoteString($criteriaValues) : $criteriaValues]]></code>
<code><![CDATA[$values[0] ?? '']]></code>
<code><![CDATA[$values[1] ?? '']]></code>
@ -11524,9 +11520,6 @@
<MixedReturnStatement>
<code><![CDATA[$stack]]></code>
</MixedReturnStatement>
<PossiblyNullArgument>
<code><![CDATA[$row['comment']]]></code>
</PossiblyNullArgument>
<PossiblyUnusedReturnValue>
<code><![CDATA[bool]]></code>
</PossiblyUnusedReturnValue>
@ -11707,9 +11700,6 @@
</MixedArgument>
</file>
<file src="src/Util.php">
<ArgumentTypeCoercion>
<code><![CDATA[$separator]]></code>
</ArgumentTypeCoercion>
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
<code><![CDATA[Config::getInstance()]]></code>

View File

@ -35,7 +35,7 @@ class Advisor
private array $variables = [];
/** @var mixed[] */
private array $globals = [];
private array $globals;
/**
* @var array<int, array<string, string>>

View File

@ -141,7 +141,7 @@ class Bookmark
$query = str_replace('[VARIABLE' . $i . ']', $var, $query);
// backward compatibility
if ($i != 1) {
if ($i !== 1) {
continue;
}

View File

@ -179,13 +179,9 @@ class Charsets
return self::$charsets['utf8'];
}
if (self::$serverCharset === null) {// Fallback in case nothing is found
return Charset::fromServer(
['Charset' => __('Unknown'), 'Description' => __('Unknown')],
);
}
return self::$serverCharset;
return self::$serverCharset ?? Charset::fromServer(
['Charset' => __('Unknown'), 'Description' => __('Unknown')],
);
}
/**

View File

@ -56,7 +56,6 @@ use function str_contains;
use function str_ends_with;
use function stripos;
use function strtolower;
use function substr;
use function sys_get_temp_dir;
use function time;
use function trim;
@ -770,7 +769,7 @@ class Config
$isHttps = true;
} elseif (strtolower(Core::getEnv('HTTPS')) === 'on') {
$isHttps = true;
} elseif (strtolower(substr(Core::getEnv('REQUEST_URI'), 0, 6)) === 'https:') {
} elseif (stripos(Core::getEnv('REQUEST_URI'), 'https:') === 0) {
$isHttps = true;
} elseif (strtolower(Core::getEnv('HTTP_HTTPS_FROM_LB')) === 'on') {
// A10 Networks load balancer
@ -901,7 +900,7 @@ class Config
if ($validity === null) {
/* Valid for one month */
$validity = time() + 2592000;
} elseif ($validity == 0) {
} elseif ($validity === 0) {
/* Valid for session */
$validity = 0;
} else {

View File

@ -604,13 +604,13 @@ class ConfigFile
],
'InitialSlidersState' => ['open' => __('Open'), 'closed' => __('Closed'), 'disabled' => __('Disabled')],
'FirstDayOfCalendar' => [
'1' => _pgettext('Week day name', 'Monday'),
'2' => _pgettext('Week day name', 'Tuesday'),
'3' => _pgettext('Week day name', 'Wednesday'),
'4' => _pgettext('Week day name', 'Thursday'),
'5' => _pgettext('Week day name', 'Friday'),
'6' => _pgettext('Week day name', 'Saturday'),
'7' => _pgettext('Week day name', 'Sunday'),
1 => _pgettext('Week day name', 'Monday'),
2 => _pgettext('Week day name', 'Tuesday'),
3 => _pgettext('Week day name', 'Wednesday'),
4 => _pgettext('Week day name', 'Thursday'),
5 => _pgettext('Week day name', 'Friday'),
6 => _pgettext('Week day name', 'Saturday'),
7 => _pgettext('Week day name', 'Sunday'),
],
'SendErrorReports' => [
'ask' => __('Ask before sending error reports'),

View File

@ -74,19 +74,19 @@ class SpecialSchemaLinks
'columns_priv' => [
'user' => [
'link_param' => 'username',
'link_dependancy_params' => [0 => ['param_info' => 'hostname', 'column_name' => 'host']],
'link_dependancy_params' => [['param_info' => 'hostname', 'column_name' => 'host']],
'default_page' => './' . Url::getFromRoute('/server/privileges'),
],
'table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [0 => ['param_info' => 'db', 'column_name' => 'Db']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'Db']],
'default_page' => $defaultPageTable,
],
'column_name' => [
'link_param' => 'field',
'link_dependancy_params' => [
0 => ['param_info' => 'db', 'column_name' => 'Db'],
1 => ['param_info' => 'table', 'column_name' => 'Table_name'],
['param_info' => 'db', 'column_name' => 'Db'],
['param_info' => 'table', 'column_name' => 'Table_name'],
],
'default_page' => './' . Url::getFromRoute('/table/structure/change', ['change_column' => 1]),
],
@ -94,14 +94,14 @@ class SpecialSchemaLinks
'db' => [
'user' => [
'link_param' => 'username',
'link_dependancy_params' => [0 => ['param_info' => 'hostname', 'column_name' => 'host']],
'link_dependancy_params' => [['param_info' => 'hostname', 'column_name' => 'host']],
'default_page' => './' . Url::getFromRoute('/server/privileges'),
],
],
'event' => [
'name' => [
'link_param' => 'item_name',
'link_dependancy_params' => [0 => ['param_info' => 'db', 'column_name' => 'db']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'db']],
'default_page' => './' . Url::getFromRoute('/database/events', ['edit_item' => 1]),
],
@ -109,14 +109,14 @@ class SpecialSchemaLinks
'innodb_index_stats' => [
'table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [0 => ['param_info' => 'db', 'column_name' => 'database_name']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'database_name']],
'default_page' => $defaultPageTable,
],
'index_name' => [
'link_param' => 'index',
'link_dependancy_params' => [
0 => ['param_info' => 'db', 'column_name' => 'database_name'],
1 => ['param_info' => 'table', 'column_name' => 'table_name'],
['param_info' => 'db', 'column_name' => 'database_name'],
['param_info' => 'table', 'column_name' => 'table_name'],
],
'default_page' => './' . Url::getFromRoute('/table/structure'),
],
@ -124,7 +124,7 @@ class SpecialSchemaLinks
'innodb_table_stats' => [
'table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [0 => ['param_info' => 'db', 'column_name' => 'database_name']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'database_name']],
'default_page' => $defaultPageTable,
],
],
@ -132,16 +132,16 @@ class SpecialSchemaLinks
'name' => [
'link_param' => 'item_name',
'link_dependancy_params' => [
0 => ['param_info' => 'db', 'column_name' => 'db'],
1 => ['param_info' => 'item_type', 'column_name' => 'type'],
['param_info' => 'db', 'column_name' => 'db'],
['param_info' => 'item_type', 'column_name' => 'type'],
],
'default_page' => './' . Url::getFromRoute('/database/routines', ['edit_item' => 1]),
],
'specific_name' => [
'link_param' => 'item_name',
'link_dependancy_params' => [
0 => ['param_info' => 'db', 'column_name' => 'db'],
1 => ['param_info' => 'item_type', 'column_name' => 'type'],
['param_info' => 'db', 'column_name' => 'db'],
['param_info' => 'item_type', 'column_name' => 'type'],
],
'default_page' => './' . Url::getFromRoute('/database/routines', ['edit_item' => 1]),
],
@ -149,14 +149,14 @@ class SpecialSchemaLinks
'proc_priv' => [
'user' => [
'link_param' => 'username',
'link_dependancy_params' => [0 => ['param_info' => 'hostname', 'column_name' => 'Host']],
'link_dependancy_params' => [['param_info' => 'hostname', 'column_name' => 'Host']],
'default_page' => './' . Url::getFromRoute('/server/privileges'),
],
'routine_name' => [
'link_param' => 'item_name',
'link_dependancy_params' => [
0 => ['param_info' => 'db', 'column_name' => 'Db'],
1 => ['param_info' => 'item_type', 'column_name' => 'Routine_type'],
['param_info' => 'db', 'column_name' => 'Db'],
['param_info' => 'item_type', 'column_name' => 'Routine_type'],
],
'default_page' => './' . Url::getFromRoute('/database/routines', ['edit_item' => 1]),
],
@ -164,26 +164,26 @@ class SpecialSchemaLinks
'proxies_priv' => [
'user' => [
'link_param' => 'username',
'link_dependancy_params' => [0 => ['param_info' => 'hostname', 'column_name' => 'Host']],
'link_dependancy_params' => [['param_info' => 'hostname', 'column_name' => 'Host']],
'default_page' => './' . Url::getFromRoute('/server/privileges'),
],
],
'tables_priv' => [
'user' => [
'link_param' => 'username',
'link_dependancy_params' => [0 => ['param_info' => 'hostname', 'column_name' => 'Host']],
'link_dependancy_params' => [['param_info' => 'hostname', 'column_name' => 'Host']],
'default_page' => './' . Url::getFromRoute('/server/privileges'),
],
'table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [0 => ['param_info' => 'db', 'column_name' => 'Db']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'Db']],
'default_page' => $defaultPageTable,
],
],
'user' => [
'user' => [
'link_param' => 'username',
'link_dependancy_params' => [0 => ['param_info' => 'hostname', 'column_name' => 'host']],
'link_dependancy_params' => [['param_info' => 'hostname', 'column_name' => 'host']],
'default_page' => './' . Url::getFromRoute('/server/privileges'),
],
],
@ -192,14 +192,14 @@ class SpecialSchemaLinks
'columns' => [
'table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [0 => ['param_info' => 'db', 'column_name' => 'table_schema']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'table_schema']],
'default_page' => $defaultPageTable,
],
'column_name' => [
'link_param' => 'field',
'link_dependancy_params' => [
0 => ['param_info' => 'db', 'column_name' => 'table_schema'],
1 => ['param_info' => 'table', 'column_name' => 'table_name'],
['param_info' => 'db', 'column_name' => 'table_schema'],
['param_info' => 'table', 'column_name' => 'table_name'],
],
'default_page' => './' . Url::getFromRoute('/table/structure/change', ['change_column' => 1]),
],
@ -207,29 +207,29 @@ class SpecialSchemaLinks
'key_column_usage' => [
'table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [0 => ['param_info' => 'db','column_name' => 'constraint_schema']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'constraint_schema']],
'default_page' => $defaultPageTable,
],
'column_name' => [
'link_param' => 'field',
'link_dependancy_params' => [
0 => ['param_info' => 'db', 'column_name' => 'table_schema'],
1 => ['param_info' => 'table', 'column_name' => 'table_name'],
['param_info' => 'db', 'column_name' => 'table_schema'],
['param_info' => 'table', 'column_name' => 'table_name'],
],
'default_page' => './' . Url::getFromRoute('/table/structure/change', ['change_column' => 1]),
],
'referenced_table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [
0 => ['param_info' => 'db', 'column_name' => 'referenced_table_schema'],
['param_info' => 'db', 'column_name' => 'referenced_table_schema'],
],
'default_page' => $defaultPageTable,
],
'referenced_column_name' => [
'link_param' => 'field',
'link_dependancy_params' => [
0 => ['param_info' => 'db', 'column_name' => 'referenced_table_schema'],
1 => ['param_info' => 'table', 'column_name' => 'referenced_table_name'],
['param_info' => 'db', 'column_name' => 'referenced_table_schema'],
['param_info' => 'table', 'column_name' => 'referenced_table_name'],
],
'default_page' => './' . Url::getFromRoute('/table/structure/change', ['change_column' => 1]),
],
@ -237,26 +237,26 @@ class SpecialSchemaLinks
'partitions' => [
'table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [0 => ['param_info' => 'db', 'column_name' => 'table_schema']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'table_schema']],
'default_page' => $defaultPageTable,
],
],
'processlist' => [
'user' => [
'link_param' => 'username',
'link_dependancy_params' => [0 => ['param_info' => 'hostname', 'column_name' => 'host']],
'link_dependancy_params' => [['param_info' => 'hostname', 'column_name' => 'host']],
'default_page' => './' . Url::getFromRoute('/server/privileges'),
],
],
'referential_constraints' => [
'table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [0 => ['param_info' => 'db','column_name' => 'constraint_schema']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'constraint_schema']],
'default_page' => $defaultPageTable,
],
'referenced_table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [0 => ['param_info' => 'db','column_name' => 'constraint_schema']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'constraint_schema']],
'default_page' => $defaultPageTable,
],
],
@ -264,8 +264,8 @@ class SpecialSchemaLinks
'routine_name' => [
'link_param' => 'item_name',
'link_dependancy_params' => [
0 => ['param_info' => 'db', 'column_name' => 'routine_schema'],
1 => ['param_info' => 'item_type', 'column_name' => 'routine_type'],
['param_info' => 'db', 'column_name' => 'routine_schema'],
['param_info' => 'item_type', 'column_name' => 'routine_type'],
],
'default_page' => './' . Url::getFromRoute('/database/routines'),
],
@ -274,14 +274,14 @@ class SpecialSchemaLinks
'statistics' => [
'table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [0 => ['param_info' => 'db', 'column_name' => 'table_schema']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'table_schema']],
'default_page' => $defaultPageTable,
],
'column_name' => [
'link_param' => 'field',
'link_dependancy_params' => [
0 => ['param_info' => 'db', 'column_name' => 'table_schema'],
1 => ['param_info' => 'table', 'column_name' => 'table_name'],
['param_info' => 'db', 'column_name' => 'table_schema'],
['param_info' => 'table', 'column_name' => 'table_name'],
],
'default_page' => './' . Url::getFromRoute('/table/structure/change', ['change_column' => 1]),
],
@ -289,21 +289,21 @@ class SpecialSchemaLinks
'tables' => [
'table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [0 => ['param_info' => 'db', 'column_name' => 'table_schema']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'table_schema']],
'default_page' => $defaultPageTable,
],
],
'table_constraints' => [
'table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [0 => ['param_info' => 'db', 'column_name' => 'table_schema']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'table_schema']],
'default_page' => $defaultPageTable,
],
],
'views' => [
'table_name' => [
'link_param' => 'table',
'link_dependancy_params' => [0 => ['param_info' => 'db', 'column_name' => 'table_schema']],
'link_dependancy_params' => [['param_info' => 'db', 'column_name' => 'table_schema']],
'default_page' => $defaultPageTable,
],
],

View File

@ -45,7 +45,6 @@ use function preg_match;
use function sprintf;
use function str_contains;
use function str_replace;
use function strlen;
use function strnatcasecmp;
use function trim;
use function uksort;
@ -386,14 +385,14 @@ class Relation
. '.' . Util::backquote($relationFeature->relation)
. ' WHERE `master_db` = ' . $this->dbi->quoteString($db)
. ' AND `master_table` = ' . $this->dbi->quoteString($table);
if (strlen($column) > 0) {
if ($column !== '') {
$relQuery .= ' AND `master_field` = ' . $this->dbi->quoteString($column);
}
$foreign = $this->dbi->fetchResult($relQuery, 'master_field', null, ConnectionType::ControlUser);
}
if (($source === 'both' || $source === 'foreign') && strlen($table) > 0) {
if (($source === 'both' || $source === 'foreign') && $table !== '') {
$tableObj = new Table($table, $db, $this->dbi);
$showCreateTable = $tableObj->showCreate();
if ($showCreateTable !== '') {
@ -421,9 +420,9 @@ class Relation
if (isset($internalRelations[$table])) {
foreach ($internalRelations[$table] as $field => $relations) {
if (
(strlen($column) !== 0 && $column != $field)
($column !== '' && $column != $field)
|| (isset($foreign[$field])
&& strlen($foreign[$field]) !== 0)
&& $foreign[$field] != '')
) {
continue;
}
@ -560,7 +559,7 @@ class Relation
return false;
}
if (strlen($comment) > 0) {
if ($comment !== '') {
$updQuery = 'INSERT INTO '
. Util::backquote($columnCommentsFeature->database) . '.'
. Util::backquote($columnCommentsFeature->columnInfo)

View File

@ -79,7 +79,7 @@ class UserGroups
$userGroupsValues = [];
$action = Url::getFromRoute('/server/privileges');
$hiddenInputs = null;
if ($result && $result->numRows()) {
if ($result !== false && $result->numRows()) {
$hiddenInputs = Url::getHiddenInputs();
foreach ($result as $row) {
$groupName = $row['usergroup'];

View File

@ -32,12 +32,13 @@ final class AddPrefixTableController extends AbstractController
$GLOBALS['sql_query'] = '';
$this->dbi->selectDb(Current::$database);
foreach ($selected as $selectedValue) {
$newTableName = $request->getParsedBodyParam('add_prefix', '') . $selectedValue;
$aQuery = 'ALTER TABLE ' . Util::backquote($selectedValue) . ' RENAME ' . Util::backquote($newTableName);
$GLOBALS['sql_query'] .= $aQuery . ';' . "\n";
$this->dbi->selectDb(Current::$database);
$this->dbi->query($aQuery);
}

View File

@ -58,6 +58,8 @@ final class EmptyTableController extends AbstractController
$GLOBALS['sql_query'] = '';
$this->dbi->selectDb(Current::$database);
foreach ($selected as $selectedValue) {
if (Table::get($selectedValue, Current::$database, $this->dbi)->isView()) {
continue;
@ -67,7 +69,6 @@ final class EmptyTableController extends AbstractController
$aQuery .= Util::backquote($selectedValue);
$GLOBALS['sql_query'] .= $aQuery . ';' . "\n";
$this->dbi->selectDb(Current::$database);
$this->dbi->query($aQuery);
}

View File

@ -37,6 +37,8 @@ final class ReplacePrefixController extends AbstractController
$GLOBALS['sql_query'] = '';
$this->dbi->selectDb(Current::$database);
foreach ($selected as $selectedValue) {
$subFromPrefix = mb_substr($selectedValue, 0, mb_strlen((string) $fromPrefix));
@ -50,7 +52,6 @@ final class ReplacePrefixController extends AbstractController
. ' RENAME ' . Util::backquote($newTableName);
$GLOBALS['sql_query'] .= $aQuery . ';' . "\n";
$this->dbi->selectDb(Current::$database);
$this->dbi->query($aQuery);
}

View File

@ -49,7 +49,6 @@ use function preg_match;
use function preg_quote;
use function sprintf;
use function str_replace;
use function strlen;
use function strtotime;
use function urlencode;
@ -365,7 +364,7 @@ final class StructureController extends AbstractController
);
}
if ($numColumns > 0 && $this->numTables > $numColumns && ($rowCount % $numColumns) == 0) {
if ($numColumns > 0 && $this->numTables > $numColumns && ($rowCount % $numColumns) === 0) {
$rowCount = 1;
$html .= $this->template->render('database/structure/table_header', [
@ -603,15 +602,15 @@ final class StructureController extends AbstractController
$searchDoDBInTruename = array_search($table, $replicaInfo['Do_DB']);
$searchDoDBInDB = array_search(Current::$database, $replicaInfo['Do_DB']);
$do = (is_string($searchDoDBInTruename) && strlen($searchDoDBInTruename) > 0)
|| (is_string($searchDoDBInDB) && strlen($searchDoDBInDB) > 0)
$do = (is_string($searchDoDBInTruename) && $searchDoDBInTruename !== '')
|| (is_string($searchDoDBInDB) && $searchDoDBInDB !== '')
|| ($nbServReplicaDoDb == 0 && $nbServReplicaIgnoreDb == 0)
|| $this->hasTable($replicaInfo['Wild_Do_Table'], $table);
$searchDb = array_search(Current::$database, $replicaInfo['Ignore_DB']);
$searchTable = array_search($table, $replicaInfo['Ignore_Table']);
$ignored = (is_string($searchTable) && strlen($searchTable) > 0)
|| (is_string($searchDb) && strlen($searchDb) > 0)
$ignored = (is_string($searchTable) && $searchTable !== '')
|| (is_string($searchDb) && $searchDb !== '')
|| $this->hasTable($replicaInfo['Wild_Ignore_Table'], $table);
}

View File

@ -37,7 +37,6 @@ use function mb_strtolower;
use function mb_strtoupper;
use function preg_replace;
use function str_contains;
use function strlen;
use function urldecode;
class TableController extends AbstractController
@ -457,7 +456,7 @@ class TableController extends AbstractController
&& $pmaTable->isEngine(['MYISAM', 'ARIA', 'ISAM']);
$hasChecksumAndDelayKeyWrite = $pmaTable->isEngine(['MYISAM', 'ARIA']);
$hasTransactionalAndPageChecksum = $pmaTable->isEngine('ARIA');
$hasAutoIncrement = strlen($GLOBALS['auto_increment']) > 0
$hasAutoIncrement = $GLOBALS['auto_increment'] != ''
&& $pmaTable->isEngine(['MYISAM', 'ARIA', 'INNODB', 'PBXT', 'ROCKSDB']);
$possibleRowFormats = $this->operations->getPossibleRowFormat();

View File

@ -58,6 +58,8 @@ final class DeleteRowsController extends AbstractController
$defaultFkCheckValue = ForeignKey::handleDisableCheckInit();
$GLOBALS['sql_query'] = '';
$this->dbi->selectDb(Current::$database);
foreach ($selected as $row) {
$query = sprintf(
'DELETE FROM %s WHERE %s LIMIT 1;',
@ -65,7 +67,6 @@ final class DeleteRowsController extends AbstractController
$row,
);
$GLOBALS['sql_query'] .= $query . "\n";
$this->dbi->selectDb(Current::$database);
$this->dbi->query($query);
}

View File

@ -16,6 +16,7 @@ use PhpMyAdmin\Util;
use function __;
use function array_column;
use function array_diff;
use function array_splice;
use function count;
use function implode;
@ -121,13 +122,7 @@ final class MoveColumnsController extends AbstractController
$i === 0 ? '-first' : $columnNames[$i - 1],
);
// update current column_names array, first delete old position
for ($j = 0, $ll = count($columnNames); $j < $ll; $j++) {
if ($columnNames[$j] != $column) {
continue;
}
unset($columnNames[$j]);
}
$columnNames = array_diff($columnNames, [$column]);
// insert moved column
array_splice($columnNames, $i, 0, $column);

View File

@ -39,9 +39,9 @@ use function preg_match;
use function preg_replace;
use function sprintf;
use function str_replace;
use function stripos;
use function strlen;
use function strpos;
use function strtolower;
use function substr;
use function unserialize;
use function urldecode;
@ -109,7 +109,7 @@ class Core
$doclink = self::getPHPDocLink('book.' . $extension . '.php');
$message = sprintf($message, '[a@' . $doclink . '@Documentation][em]' . $extension . '[/em][/a]');
if ($extra != '') {
if ($extra !== '') {
$message .= ' ' . $extra;
}
@ -604,7 +604,7 @@ class Core
*/
public static function sanitizeMySQLHost(string $name): string
{
while (strtolower(substr($name, 0, 2)) === 'p:') {
while (stripos($name, 'p:') === 0) {
/** @infection-ignore-all */
$name = substr($name, 2);
}

View File

@ -165,7 +165,7 @@ class Common
$retval[$ti][$cNameI] = [];
if (in_array($dtnI, $tableDbNames, true) && in_array($con['STN'][$i], $tableDbNames, true)) {
$retval[$ti][$cNameI][$dtnI] = [];
$retval[$ti][$cNameI][$dtnI][$con['DCN'][$i]] = [0 => $con['STN'][$i], 1 => $con['SCN'][$i]];
$retval[$ti][$cNameI][$dtnI][$con['DCN'][$i]] = [$con['STN'][$i], $con['SCN'][$i]];
}
$ti++;

View File

@ -539,12 +539,12 @@ class Routines
$index = '%s';
$dropClass = '';
$routine = [
'item_param_dir' => [0 => ''],
'item_param_name' => [0 => ''],
'item_param_type' => [0 => ''],
'item_param_length' => [0 => ''],
'item_param_opts_num' => [0 => ''],
'item_param_opts_text' => [0 => ''],
'item_param_dir' => [''],
'item_param_name' => [''],
'item_param_type' => [''],
'item_param_length' => [''],
'item_param_opts_num' => [''],
'item_param_opts_text' => [''],
];
} elseif ($routine !== []) {
// regular row for routine editor

View File

@ -69,11 +69,11 @@ class Search
public function __construct(private DatabaseInterface $dbi, private string $db, public Template $template)
{
$this->searchTypes = [
'1' => __('at least one of the words'),
'2' => __('all of the words'),
'3' => __('the exact phrase as substring'),
'4' => __('the exact phrase as whole field'),
'5' => __('as regular expression'),
1 => __('at least one of the words'),
2 => __('all of the words'),
3 => __('the exact phrase as substring'),
4 => __('the exact phrase as whole field'),
5 => __('as regular expression'),
];
// Sets criteria parameters
$this->setSearchParams();
@ -160,7 +160,7 @@ class Search
$allColumns = $this->dbi->getColumns(Current::$database, $table);
$likeClauses = [];
// Based on search type, decide like/regex & '%'/''
$likeOrRegex = $this->criteriaSearchType == 5 ? 'REGEXP' : 'LIKE';
$likeOrRegex = $this->criteriaSearchType === 5 ? 'REGEXP' : 'LIKE';
$automaticWildcard = $this->criteriaSearchType < 4 ? '%' : '';
// For "as regular expression" (search option 5), LIKE won't be used
// Usage example: If user is searching for a literal $ in a regexp search,
@ -205,7 +205,7 @@ class Search
}
// Use 'OR' if 'at least one word' is to be searched, else use 'AND'
$implodeStr = $this->criteriaSearchType == 1 ? ' OR ' : ' AND ';
$implodeStr = $this->criteriaSearchType === 1 ? ' OR ' : ' AND ';
return ' WHERE (' . implode(') ' . $implodeStr . ' (', $likeClauses) . ')';
}

View File

@ -908,7 +908,7 @@ class Results
];
// Keep the number of rows (25, 50, 100, ...) when changing sort key value
if (isset($_SESSION['tmpval'], $_SESSION['tmpval']['max_rows'])) {
if (isset($_SESSION['tmpval']['max_rows'])) {
$hiddenFields['session_max_rows'] = $_SESSION['tmpval']['max_rows'];
}
@ -2979,10 +2979,7 @@ class Results
public function setConfigParamsForDisplayTable(StatementInfo $statementInfo): void
{
$sqlMd5 = md5($this->server . $this->db . $this->sqlQuery);
$query = [];
if (isset($_SESSION['tmpval']['query'][$sqlMd5])) {
$query = $_SESSION['tmpval']['query'][$sqlMd5];
}
$query = $_SESSION['tmpval']['query'][$sqlMd5] ?? [];
$query['sql'] = $this->sqlQuery;

View File

@ -218,7 +218,7 @@ class Encoding
*/
public static function kanjiStrConv(string $str, string $enc, string $kana): string
{
if ($enc == '' && $kana == '') {
if ($enc === '' && $kana === '') {
return $str;
}
@ -232,7 +232,7 @@ class Encoding
$str = $dist;
}
if ($stringEncoding !== $enc && $enc != '') {
if ($stringEncoding !== $enc && $enc !== '') {
return mb_convert_encoding($str, $enc, $stringEncoding);
}
@ -250,7 +250,7 @@ class Encoding
*/
public static function kanjiFileConv(string $file, string $enc, string $kana): string
{
if ($enc == '' && $kana == '') {
if ($enc === '' && $kana === '') {
return $file;
}

View File

@ -223,7 +223,7 @@ class Error extends Message
*/
public function getBacktrace(int $count = -1): array
{
if ($count != -1) {
if ($count !== -1) {
return array_slice($this->backtrace, 0, $count);
}

View File

@ -217,11 +217,11 @@ class ErrorHandler
if (
$isSilenced &&
$this->errorReporting != 0 &&
($errno & (E_USER_WARNING | E_USER_ERROR | E_USER_NOTICE | E_USER_DEPRECATED)) == 0
($errno & (E_USER_WARNING | E_USER_ERROR | E_USER_NOTICE | E_USER_DEPRECATED)) === 0
) {
return false;
}
} elseif (($errno & (E_USER_WARNING | E_USER_ERROR | E_USER_NOTICE | E_USER_DEPRECATED)) == 0) {
} elseif (($errno & (E_USER_WARNING | E_USER_ERROR | E_USER_NOTICE | E_USER_DEPRECATED)) === 0) {
return false;
}

View File

@ -135,7 +135,7 @@ class ErrorReport
}
// if there were no 'actual' errors to be submitted.
if ($i == 0) {
if ($i === 0) {
return []; // then return empty array
}

View File

@ -185,7 +185,7 @@ class Export
$line = Encoding::convertString('utf-8', $GLOBALS['charset'], $line);
}
if ($GLOBALS['save_on_server'] && mb_strlen($line) > 0) {
if ($GLOBALS['save_on_server'] && $line !== '') {
if ($GLOBALS['file_handle'] !== null) {
$writeResult = @fwrite($GLOBALS['file_handle'], $line);
} else {
@ -669,7 +669,7 @@ class Export
// to resolve view dependencies (only when it's a single-file export)
if ($isView) {
if (
$separateFiles == ''
$separateFiles === ''
&& isset($GLOBALS['sql_create_view'])
&& ! $exportPlugin->exportStructure(
$db->getName(),
@ -920,7 +920,7 @@ class Export
return;
}
if (isset($allrows) && $allrows == '0' && $limitTo > 0 && $limitFrom >= 0) {
if ($allrows === '0' && $limitTo > 0 && $limitFrom >= 0) {
$addQuery = ' LIMIT '
. ($limitFrom > 0 ? $limitFrom . ', ' : '')
. $limitTo;

View File

@ -70,7 +70,7 @@ class File
protected int $chunkSize = 32768;
/** @var resource|null file handle */
protected $handle = null;
protected $handle;
/** @var bool whether to decompress content before returning */
protected bool $decompress = false;
@ -722,11 +722,7 @@ class File
*/
public function getCompression(): string
{
if ($this->compression === null) {
return $this->detectCompression();
}
return $this->compression;
return $this->compression ?? $this->detectCompression();
}
/**

View File

@ -56,7 +56,7 @@ class FileListing
if (
! @is_file($dir . $file)
|| @is_link($dir . $file)
|| ($expression != '' && ! preg_match($expression, $file))
|| ($expression !== '' && ! preg_match($expression, $file))
) {
continue;
}

View File

@ -20,7 +20,6 @@ use function is_object;
use function is_scalar;
use function json_encode;
use function json_last_error;
use function strlen;
/**
* Class used to output the footer
@ -172,7 +171,7 @@ class Footer
(
isset($_REQUEST['no_history'])
&& is_scalar($_REQUEST['no_history'])
&& strlen((string) $_REQUEST['no_history']) > 0
&& (string) $_REQUEST['no_history'] !== ''
)
|| ! empty($GLOBALS['error_message'])
|| empty($GLOBALS['sql_query'])

View File

@ -339,7 +339,7 @@ abstract class GisGeometry
protected function toOpenLayersObject(string $constructor, array $coordinates, int $srid): string
{
$ol = 'new ' . $constructor . '(' . json_encode($coordinates) . ')';
if ($srid != 3857) {
if ($srid !== 3857) {
$ol .= '.transform(\'EPSG:' . ($srid !== 0 ? $srid : 4326) . '\', \'EPSG:3857\')';
}

View File

@ -215,7 +215,7 @@ class GisGeometryCollection extends GisGeometry
$brCount++;
} elseif ($char === ')') {
$brCount--;
if ($brCount == 0) {
if ($brCount === 0) {
$subParts[] = mb_substr($geomCol, $start, $count + 1 - $start);
$start = $count + 2;
}

View File

@ -37,7 +37,6 @@ use function str_contains;
use function str_ends_with;
use function str_replace;
use function str_starts_with;
use function strlen;
use function strtolower;
use function substr;
use function trim;
@ -172,7 +171,7 @@ class Git
}
// we care only about commit objects
if ($type != 1) {
if ($type !== 1) {
return null;
}
@ -293,7 +292,7 @@ class Git
// packs. (to look for them in .git/object/pack directory later)
foreach (explode("\n", $packs) as $line) {
// skip blank lines
if (strlen(trim($line)) == 0) {
if (trim($line) === '') {
continue;
}

View File

@ -26,7 +26,6 @@ use function htmlspecialchars;
use function ini_get;
use function json_encode;
use function sprintf;
use function strlen;
use function strtolower;
use function urlencode;
@ -494,7 +493,7 @@ class Header
*/
public function getPageTitle(): string
{
if (strlen($this->title) == 0) {
if ($this->title === '') {
if (Current::$server > 0) {
if (Current::$table !== '') {
$tempTitle = $this->config->settings['TitleTable'];

View File

@ -52,9 +52,8 @@ use function sprintf;
use function str_contains;
use function str_replace;
use function str_starts_with;
use function stripos;
use function strlen;
use function strtoupper;
use function substr;
use function trim;
use const ENT_COMPAT;
@ -264,7 +263,7 @@ class Generator
if (
$currentClass === 'SPATIAL' &&
$dbi->getVersion() >= 50600 &&
strtoupper(substr($defaultFunction, 0, 3)) !== 'ST_'
stripos($defaultFunction, 'ST_') !== 0
) {
$defaultFunction = 'ST_' . $defaultFunction;
}

View File

@ -14,7 +14,6 @@ use function __;
use function hash_equals;
use function is_scalar;
use function session_id;
use function strlen;
use function trigger_error;
use const E_USER_ERROR;
@ -45,7 +44,7 @@ final class TokenRequestParamChecking implements MiddlewareInterface
return;
}
if (isset($_POST['token']) && is_scalar($_POST['token']) && strlen((string) $_POST['token']) > 0) {
if (isset($_POST['token']) && is_scalar($_POST['token']) && (string) $_POST['token'] !== '') {
$GLOBALS['token_provided'] = true;
$GLOBALS['token_mismatch'] = ! @hash_equals($_SESSION[' PMA_token '], (string) $_POST['token']);
}

View File

@ -48,7 +48,7 @@ final class ImageWrapper
return null;
}
if (! isset($background, $background['red'], $background['green'], $background['blue'])) {
if (! isset($background['red'], $background['green'], $background['blue'])) {
return new self($image);
}

View File

@ -423,7 +423,7 @@ class Import
// subtract 1 of divided value in case the modulus is 0,
// this is necessary because A-Z has no 'zero'
if ($remain == 0) {
if ($remain === 0) {
$div--;
}
@ -433,7 +433,7 @@ class Import
$num = $remain;
}
if ($num == 0) {
if ($num === 0) {
// use 'Z' if column number is 0,
// this is necessary because A-Z has no 'zero'
$colName .= mb_chr($capitalA + 26 - 1);
@ -566,14 +566,14 @@ class Import
return $lastCumulativeSize;
}
if ($currentCellType == self::VARCHAR) {
if ($currentCellType === self::VARCHAR) {
/**
* What to do if the current cell is of type VARCHAR
*/
/**
* The last cumulative type was VARCHAR
*/
if ($lastCumulativeType == self::VARCHAR) {
if ($lastCumulativeType === self::VARCHAR) {
if ($currSize >= $lastCumulativeSize) {
return $currSize;
}
@ -581,7 +581,7 @@ class Import
return $lastCumulativeSize;
}
if ($lastCumulativeType == self::DECIMAL) {
if ($lastCumulativeType === self::DECIMAL) {
/**
* The last cumulative type was DECIMAL
*/
@ -594,7 +594,7 @@ class Import
return $oldM;
}
if ($lastCumulativeType == self::BIGINT || $lastCumulativeType == self::INT) {
if ($lastCumulativeType === self::BIGINT || $lastCumulativeType === self::INT) {
/**
* The last cumulative type was BIGINT or INT
*/
@ -605,7 +605,7 @@ class Import
return $lastCumulativeSize;
}
if (! isset($lastCumulativeType) || $lastCumulativeType == self::NONE) {
if ($lastCumulativeType === null || $lastCumulativeType === self::NONE) {
/**
* This is the first row to be analyzed
*/
@ -622,14 +622,14 @@ class Import
return -1;
}
if ($currentCellType == self::DECIMAL) {
if ($currentCellType === self::DECIMAL) {
/**
* What to do if the current cell is of type DECIMAL
*/
/**
* The last cumulative type was VARCHAR
*/
if ($lastCumulativeType == self::VARCHAR) {
if ($lastCumulativeType === self::VARCHAR) {
/* Convert $last_cumulative_size from varchar to decimal format */
$size = $this->getDecimalSize($cell);
@ -640,7 +640,7 @@ class Import
return $lastCumulativeSize;
}
if ($lastCumulativeType == self::DECIMAL) {
if ($lastCumulativeType === self::DECIMAL) {
/**
* The last cumulative type was DECIMAL
*/
@ -659,7 +659,7 @@ class Import
return $lastCumulativeSize;
}
if ($lastCumulativeType == self::BIGINT || $lastCumulativeType == self::INT) {
if ($lastCumulativeType === self::BIGINT || $lastCumulativeType === self::INT) {
/**
* The last cumulative type was BIGINT or INT
*/
@ -673,7 +673,7 @@ class Import
return $lastCumulativeSize . ',' . $size[self::D];
}
if (! isset($lastCumulativeType) || $lastCumulativeType == self::NONE) {
if ($lastCumulativeType === null || $lastCumulativeType === self::NONE) {
/**
* This is the first row to be analyzed
*/
@ -693,14 +693,14 @@ class Import
return -1;
}
if ($currentCellType == self::BIGINT || $currentCellType == self::INT) {
if ($currentCellType === self::BIGINT || $currentCellType === self::INT) {
/**
* What to do if the current cell is of type BIGINT or INT
*/
/**
* The last cumulative type was VARCHAR
*/
if ($lastCumulativeType == self::VARCHAR) {
if ($lastCumulativeType === self::VARCHAR) {
if ($currSize >= $lastCumulativeSize) {
return $currSize;
}
@ -708,7 +708,7 @@ class Import
return $lastCumulativeSize;
}
if ($lastCumulativeType == self::DECIMAL) {
if ($lastCumulativeType === self::DECIMAL) {
/**
* The last cumulative type was DECIMAL
*/
@ -727,7 +727,7 @@ class Import
return ($newInt + $oldD) . ',' . $oldD;
}
if ($lastCumulativeType == self::BIGINT || $lastCumulativeType == self::INT) {
if ($lastCumulativeType === self::BIGINT || $lastCumulativeType === self::INT) {
/**
* The last cumulative type was BIGINT or INT
*/
@ -738,7 +738,7 @@ class Import
return $lastCumulativeSize;
}
if (! isset($lastCumulativeType) || $lastCumulativeType == self::NONE) {
if ($lastCumulativeType === null || $lastCumulativeType === self::NONE) {
/**
* This is the first row to be analyzed
*/
@ -784,7 +784,7 @@ class Import
*/
if ($cell === 'NULL') {
if ($lastCumulativeType === null || $lastCumulativeType == self::NONE) {
if ($lastCumulativeType === null || $lastCumulativeType === self::NONE) {
return self::NONE;
}
@ -975,7 +975,7 @@ class Import
. '.' . Util::backquote($table->tableName) . ' (';
foreach ($table->columns as $j => $column) {
$size = $analyses[$i][self::SIZES][$j];
if ((int) $size == 0) {
if ((int) $size === 0) {
$size = 10;
}

View File

@ -8,7 +8,6 @@ use function __;
use function array_pop;
use function count;
use function htmlspecialchars;
use function strlen;
/**
* Index manipulation class
@ -380,7 +379,7 @@ class Index
public function getComments(): string
{
$comments = $this->getRemarks();
if (strlen($comments) > 0) {
if ($comments !== '') {
$comments .= "\n";
}

View File

@ -1645,10 +1645,7 @@ class InsertEdit
} else {
// (we are inserting)
// display default values
$defaultValue = $column->default ?? null;
if (isset($repopulate[$fieldHashMd5])) {
$defaultValue = $repopulate[$fieldHashMd5];
}
$defaultValue = $repopulate[$fieldHashMd5] ?? $column->default ?? null;
$realNullValue = $defaultValue === null;
$data = (string) $defaultValue;
@ -1716,10 +1713,7 @@ class InsertEdit
];
$transformationOptions['wrapper_link'] = Url::getCommon($urlParams);
$transformationOptions['wrapper_params'] = $urlParams;
$currentValue = '';
if (isset($currentRow[$column->field])) {
$currentValue = $currentRow[$column->field];
}
$currentValue = $currentRow[$column->field] ?? '';
if ($transformationPlugin instanceof IOTransformationsPlugin) {
$transformedHtml = $transformationPlugin->getInputHtml(
@ -1933,18 +1927,12 @@ class InsertEdit
//store the default value for CharEditing
$defaultCharEditing = $this->config->settings['CharEditing'];
$mimeMap = $this->transformations->getMime($db, $table);
$whereClause = '';
if (isset($whereClauseArray[$rowId])) {
$whereClause = $whereClauseArray[$rowId];
}
$whereClause = $whereClauseArray[$rowId] ?? '';
$columnCount = count($tableColumns);
for ($columnNumber = 0; $columnNumber < $columnCount; $columnNumber++) {
$tableColumn = $tableColumns[$columnNumber];
$columnMime = [];
if (isset($mimeMap[$tableColumn->field])) {
$columnMime = $mimeMap[$tableColumn->field];
}
$columnMime = $mimeMap[$tableColumn->field] ?? [];
$virtual = ['VIRTUAL', 'PERSISTENT', 'VIRTUAL GENERATED', 'STORED GENERATED'];
if (in_array($tableColumn->extra, $virtual, true)) {

View File

@ -13,7 +13,6 @@ use function is_array;
use function is_string;
use function preg_match;
use function sort;
use function strlen;
use function strnatcasecmp;
use function strtr;
use function usort;
@ -134,7 +133,7 @@ class ListDatabase extends ArrayObject
protected function checkOnlyDatabase(UserPrivileges $userPrivileges): bool
{
if (
is_string($this->config->selectedServer['only_db']) && strlen($this->config->selectedServer['only_db']) > 0
is_string($this->config->selectedServer['only_db']) && $this->config->selectedServer['only_db'] !== ''
) {
$this->config->selectedServer['only_db'] = [$this->config->selectedServer['only_db']];
}

View File

@ -45,6 +45,7 @@ use function __;
use function _ngettext;
use function array_intersect_key;
use function array_key_exists;
use function array_key_last;
use function array_keys;
use function array_map;
use function array_merge;
@ -1006,13 +1007,14 @@ class NavigationTree
private function renderNodes(UserPrivileges $userPrivileges, array $children, bool $hasFirstClass = true): string
{
$nodes = '';
for ($i = 0, $nbChildren = count($children); $i < $nbChildren; $i++) {
$lastKey = array_key_last($children);
foreach ($children as $i => $child) {
if ($i === 0) {
$nodes .= $this->renderNode($userPrivileges, $children[0], $hasFirstClass ? 'first' : '');
} elseif ($i + 1 !== $nbChildren) {
$nodes .= $this->renderNode($userPrivileges, $children[$i]);
$nodes .= $this->renderNode($userPrivileges, $child, $hasFirstClass ? 'first' : '');
} elseif ($i !== $lastKey) {
$nodes .= $this->renderNode($userPrivileges, $child);
} else {
$nodes .= $this->renderNode($userPrivileges, $children[$i], 'last');
$nodes .= $this->renderNode($userPrivileges, $child, 'last');
}
}
@ -1127,12 +1129,13 @@ class NavigationTree
usort($children, $this->sortNode(...));
$buffer = '';
$extraClass = '';
for ($i = 0, $nbChildren = count($children); $i < $nbChildren; $i++) {
if ($i + 1 === $nbChildren) {
$lastKey = array_key_last($children);
foreach ($children as $i => $child) {
if ($i === $lastKey) {
$extraClass = ' last';
}
$buffer .= $this->renderNode($userPrivileges, $children[$i], $children[$i]->classes . $extraClass);
$buffer .= $this->renderNode($userPrivileges, $child, $child->classes . $extraClass);
}
if ($buffer !== '') {
@ -1348,7 +1351,7 @@ class NavigationTree
'server' => Current::$server,
'pos2_name' => $paths['aPath_clean'][2],
];
if ($level == 3) {
if ($level === 3) {
$pos = $node->pos3;
$urlParams['pos2_value'] = $node->pos2;
$urlParams['pos3_name'] = $paths['aPath_clean'][4];

View File

@ -827,6 +827,7 @@ class Normalization
. 'in that case you don\'t have to select any.',
);
$cnt = 0;
$this->dbi->selectDb($db);
foreach ($tables as $table) {
$primary = Index::getPrimary($this->dbi, $table, $db);
$primarycols = $primary === null ? [] : $primary->getColumns();
@ -836,7 +837,6 @@ class Normalization
$pk[] = $col->getName();
}
$this->dbi->selectDb($db);
$columns = $this->dbi->getColumnNames($db, $table);
if (count($columns) - count($pk) <= 1) {
continue;
@ -871,7 +871,7 @@ class Normalization
}
}
if ($extra == '') {
if ($extra === '') {
$headText = __(
'No Transitive dependencies possible as the table doesn\'t have any non primary key columns',
);
@ -991,11 +991,11 @@ class Normalization
. ' LIMIT 500) as dt;';
$res = $this->dbi->fetchResult($query);
$pkColCnt = $res[0];
if ($pkCnt && $pkCnt == $colCnt && $colCnt == $pkColCnt) {
if ($pkCnt !== 0 && $pkCnt === $colCnt && $colCnt == $pkColCnt) {
return true;
}
return $totalRows && $totalRows == $pkCnt;
return $totalRows !== 0 && $totalRows === $pkCnt;
}
/**

View File

@ -165,8 +165,6 @@ class Partition extends SubPartition
return array_values($partitionMap);
}
return [];
}
return [];

View File

@ -223,7 +223,7 @@ class AuthenticationCookie extends AuthenticationPlugin
$GLOBALS['from_cookie'] = false;
$config = Config::getInstance();
if (isset($_POST['pma_username']) && strlen($_POST['pma_username']) > 0) {
if (isset($_POST['pma_username']) && $_POST['pma_username'] != '') {
// Verify Captcha if it is required.
if (
! empty($config->settings['CaptchaApi'])

View File

@ -177,10 +177,7 @@ class AuthenticationSignon extends AuthenticationPlugin
$pmaToken = $_SESSION['PMA_single_signon_token'];
}
$hmacSecret = Util::generateRandom(16);
if (isset($_SESSION['PMA_single_signon_HMAC_secret'])) {
$hmacSecret = $_SESSION['PMA_single_signon_HMAC_secret'];
}
$hmacSecret = $_SESSION['PMA_single_signon_HMAC_secret'] ?? Util::generateRandom(16);
/* End single signon session */
if (! defined('TESTSUITE')) {

View File

@ -226,11 +226,7 @@ class ExportHtmlword extends ExportPlugin
while ($row = $result->fetchRow()) {
$schemaInsert = '<tr class="print-category">';
foreach ($row as $field) {
if ($field === null) {
$value = $GLOBALS[$GLOBALS['what'] . '_null'];
} else {
$value = $field;
}
$value = $field ?? $GLOBALS[$GLOBALS['what'] . '_null'];
$schemaInsert .= '<td class="print">'
. htmlspecialchars((string) $value)

View File

@ -21,7 +21,7 @@ use PhpMyAdmin\Util;
use PhpMyAdmin\Version;
use function __;
use function count;
use function addcslashes;
use function in_array;
use function mb_strpos;
use function mb_substr;
@ -625,12 +625,6 @@ class ExportLatex extends ExportPlugin
*/
public static function texEscape(string $string): string
{
$escape = ['$', '%', '{', '}', '&', '#', '_', '^'];
$cntEscape = count($escape);
for ($k = 0; $k < $cntEscape; $k++) {
$string = str_replace($escape[$k], '\\' . $escape[$k], $string);
}
return $string;
return addcslashes($string, '$%{}&#_^');
}
}

View File

@ -20,7 +20,6 @@ use PhpMyAdmin\Util;
use function __;
use function array_values;
use function count;
use function htmlspecialchars;
use function str_repeat;
@ -176,7 +175,6 @@ class ExportMediawiki extends ExportPlugin
if ($exportMode === 'create_table') {
$columns = DatabaseInterface::getInstance()->getColumns($db, $table);
$columns = array_values($columns);
$rowCnt = count($columns);
// Print structure comment
$output = $this->exportComment(
@ -198,8 +196,8 @@ class ExportMediawiki extends ExportPlugin
$output .= '|- style="background:#ffdead;"' . $this->exportCRLF();
$output .= '! style="background:#ffffff" | '
. $this->exportCRLF();
for ($i = 0; $i < $rowCnt; ++$i) {
$colAs = $columns[$i]->field;
foreach ($columns as $column) {
$colAs = $column->field;
if (! empty($aliases[$db]['tables'][$table]['columns'][$colAs])) {
$colAs = $aliases[$db]['tables'][$table]['columns'][$colAs];
}
@ -211,26 +209,26 @@ class ExportMediawiki extends ExportPlugin
// Add the table structure
$output .= '|-' . $this->exportCRLF();
$output .= '! Type' . $this->exportCRLF();
for ($i = 0; $i < $rowCnt; ++$i) {
$output .= ' | ' . $columns[$i]->type . $this->exportCRLF();
foreach ($columns as $column) {
$output .= ' | ' . $column->type . $this->exportCRLF();
}
$output .= '|-' . $this->exportCRLF();
$output .= '! Null' . $this->exportCRLF();
for ($i = 0; $i < $rowCnt; ++$i) {
$output .= ' | ' . ($columns[$i]->isNull ? 'YES' : 'NO') . $this->exportCRLF();
foreach ($columns as $column) {
$output .= ' | ' . ($column->isNull ? 'YES' : 'NO') . $this->exportCRLF();
}
$output .= '|-' . $this->exportCRLF();
$output .= '! Default' . $this->exportCRLF();
for ($i = 0; $i < $rowCnt; ++$i) {
$output .= ' | ' . ($columns[$i]->default ?? '') . $this->exportCRLF();
foreach ($columns as $column) {
$output .= ' | ' . ($column->default ?? '') . $this->exportCRLF();
}
$output .= '|-' . $this->exportCRLF();
$output .= '! Extra' . $this->exportCRLF();
for ($i = 0; $i < $rowCnt; ++$i) {
$output .= ' | ' . $columns[$i]->extra . $this->exportCRLF();
foreach ($columns as $column) {
$output .= ' | ' . $column->extra . $this->exportCRLF();
}
$output .= '|}' . str_repeat($this->exportCRLF(), 2);

View File

@ -202,7 +202,7 @@ class ExportPhparray extends ExportPlugin
while ($record = $result->fetchRow()) {
$recordCnt++;
if ($recordCnt == 1) {
if ($recordCnt === 1) {
$buffer .= "\n" . ' array(';
} else {
$buffer .= ',' . "\n" . ' array(';

View File

@ -2248,7 +2248,7 @@ class ExportSql extends ExportPlugin
$insertLine = $schemaInsert;
/** @infection-ignore-all */
for ($i = 0; $i < $fieldsCnt; $i++) {
if ($i == 0) {
if ($i === 0) {
$insertLine .= ' ';
}

View File

@ -153,7 +153,7 @@ class ExportYaml extends ExportPlugin
$recordCnt++;
// Output table name as comment if this is the first record of the table
if ($recordCnt == 1) {
if ($recordCnt === 1) {
$buffer = '# ' . $dbAlias . '.' . $tableAlias . "\n";
$buffer .= '-' . "\n";
} else {

View File

@ -11,7 +11,6 @@ use function mb_strpos;
use function mb_substr;
use function str_replace;
use function str_starts_with;
use function strlen;
use function trim;
use const ENT_COMPAT;
@ -188,7 +187,7 @@ class TableProperty
*/
public function getIndexName(): string
{
if (strlen($this->key) > 0) {
if ($this->key !== '') {
return 'index="'
. htmlspecialchars($this->name, ENT_COMPAT, 'UTF-8')
. '"';

View File

@ -19,7 +19,6 @@ use PhpMyAdmin\Util;
use function __;
use function is_array;
use function preg_split;
use function strlen;
use function trim;
use const PHP_EOL;
@ -132,19 +131,19 @@ class ImportLdi extends AbstractImportCsv
$sql .= ' INTO TABLE ' . Util::backquote(Current::$table);
if (strlen((string) $GLOBALS['ldi_terminated']) > 0) {
if ((string) $GLOBALS['ldi_terminated'] !== '') {
$sql .= ' FIELDS TERMINATED BY \'' . $GLOBALS['ldi_terminated'] . '\'';
}
if (strlen((string) $GLOBALS['ldi_enclosed']) > 0) {
if ((string) $GLOBALS['ldi_enclosed'] !== '') {
$sql .= ' ENCLOSED BY ' . $dbi->quoteString($GLOBALS['ldi_enclosed']);
}
if (strlen((string) $GLOBALS['ldi_escaped']) > 0) {
if ((string) $GLOBALS['ldi_escaped'] !== '') {
$sql .= ' ESCAPED BY ' . $dbi->quoteString($GLOBALS['ldi_escaped']);
}
if (strlen((string) $GLOBALS['ldi_new_line']) > 0) {
if ((string) $GLOBALS['ldi_new_line'] !== '') {
if ($GLOBALS['ldi_new_line'] === 'auto') {
$GLOBALS['ldi_new_line'] = PHP_EOL;
}
@ -157,7 +156,7 @@ class ImportLdi extends AbstractImportCsv
ImportSettings::$skipQueries = 0;
}
if (strlen((string) $GLOBALS['ldi_columns']) > 0) {
if ((string) $GLOBALS['ldi_columns'] !== '') {
$sql .= ' (';
$tmp = preg_split('/,( ?)/', $GLOBALS['ldi_columns']);

View File

@ -402,7 +402,7 @@ class ImportMediawiki extends ImportPlugin
} elseif ($curChar === '>' && ! $insideAttribute) {
// end of a tag
$insideTag = false;
} elseif (($curChar === '"' || $curChar == "'") && $insideTag) {
} elseif (($curChar === '"' || $curChar === "'") && $insideTag) {
// start or end of an attribute
if (! $insideAttribute) {
$insideAttribute = true;

View File

@ -227,7 +227,7 @@ class ExportRelationSchema
$filename = $this->db . $extension;
// Get the name of this page to use as filename
if ($this->pageNumber != -1 && ! $this->offline && $pdfFeature !== null) {
if ($this->pageNumber !== -1 && ! $this->offline && $pdfFeature !== null) {
$nameSql = 'SELECT page_descr FROM '
. Util::backquote($pdfFeature->database) . '.'
. Util::backquote($pdfFeature->pdfPages)

View File

@ -247,7 +247,7 @@ class Pdf extends PdfLib
}
$pdfFeature = $this->relation->getRelationParameters()->pdfFeature;
if ($this->offline || $this->pageNumber == -1 || $pdfFeature === null) {
if ($this->offline || $this->pageNumber === -1 || $pdfFeature === null) {
$pgName = __('PDF export page');
} else {
$dbi = DatabaseInterface::getInstance();
@ -347,7 +347,7 @@ class Pdf extends PdfLib
{
// phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
$cw = &$this->CurrentFont['cw'];
if ($w == 0) {
if ($w === 0) {
$w = $this->w - $this->rMargin - $this->x;
}

View File

@ -173,10 +173,8 @@ class PdfRelationSchema extends ExportRelationSchema
}
// Defines the scale factor
$innerWidth = $this->pdf->getPageWidth() - $this->rightMargin
- $this->leftMargin;
$innerHeight = $this->pdf->getPageHeight() - $this->topMargin
- $this->bottomMargin;
$innerWidth = $this->pdf->getPageWidth() - $this->rightMargin - $this->leftMargin;
$innerHeight = $this->pdf->getPageHeight() - $this->topMargin - $this->bottomMargin;
$this->scale = ceil(
max(
($this->xMax - $this->xMin) / $innerWidth,

View File

@ -41,7 +41,7 @@ abstract class Bool2TextTransformationsPlugin extends TransformationsPlugin
$cfg = Config::getInstance()->settings;
$options = $this->getOptions($options, $cfg['DefaultTransformations']['Bool2Text']);
if ($buffer == '0') {
if ($buffer === '0') {
return $options[1]; // return false label
}

View File

@ -20,7 +20,6 @@ use function htmlspecialchars;
use function proc_close;
use function proc_open;
use function sprintf;
use function strlen;
use function trigger_error;
use const E_USER_DEPRECATED;
@ -112,7 +111,7 @@ abstract class ExternalTransformationsPlugin extends TransformationsPlugin
$program = $allowedPrograms[$options[0]] ?? $allowedPrograms[0];
if (isset($options[1]) && strlen((string) $options[1]) > 0) {
if (isset($options[1]) && (string) $options[1] !== '') {
trigger_error(sprintf(
__(
'You are using the external transformation command line'
@ -125,7 +124,7 @@ abstract class ExternalTransformationsPlugin extends TransformationsPlugin
// needs PHP >= 4.3.0
$newstring = '';
$descriptorspec = [0 => ['pipe', 'r'], 1 => ['pipe', 'w']];
$descriptorspec = [['pipe', 'r'], ['pipe', 'w']];
$process = proc_open($program . ' ' . $options[1], $descriptorspec, $pipes);
if ($process !== false) {
fwrite($pipes[0], $buffer);

View File

@ -88,18 +88,18 @@ class Utilities
$error = '#' . $errorNumber;
$separator = ' &mdash; ';
if ($errorNumber == 2002) {
if ($errorNumber === 2002) {
$error .= ' - ' . $errorMessage;
$error .= $separator;
$error .= __('The server is not responding (or the local server\'s socket is not correctly configured).');
} elseif ($errorNumber == 2003) {
} elseif ($errorNumber === 2003) {
$error .= ' - ' . $errorMessage;
$error .= $separator . __('The server is not responding.');
} elseif ($errorNumber == 1698) {
} elseif ($errorNumber === 1698) {
$error .= ' - ' . $errorMessage;
$error .= $separator . '<a href="' . Url::getFromRoute('/logout') . '" class="disableAjax">';
$error .= __('Logout and try as another user.') . '</a>';
} elseif ($errorNumber == 1005) {
} elseif ($errorNumber === 1005) {
if (str_contains($errorMessage, 'errno: 13')) {
$error .= ' - ' . $errorMessage;
$error .= $separator

View File

@ -20,7 +20,6 @@ use function json_encode;
use function json_last_error_msg;
use function mb_strlen;
use function str_starts_with;
use function strlen;
use function substr;
/**
@ -308,12 +307,12 @@ class ResponseRenderer
$this->addJSON('displayMessage', $this->getHeader()->getMessage());
$debug = $this->footer->getDebugMessage();
if (empty($_REQUEST['no_debug']) && strlen($debug) > 0) {
if (empty($_REQUEST['no_debug']) && $debug !== '') {
$this->addJSON('debug', $debug);
}
$errors = $this->footer->getErrorMessages();
if (strlen($errors) > 0) {
if ($errors !== '') {
$this->addJSON('errors', $errors);
}

View File

@ -1180,9 +1180,8 @@ class Privileges
)
ORDER BY `User` ASC, `Host` ASC, `Db` ASC;
';
$result = $this->dbi->query($query);
return $result->fetchAllAssoc();
return $this->dbi->query($query)->fetchAllAssoc();
}
/** @return array<int, array<string|null>> */
@ -1202,9 +1201,7 @@ class Privileges
return [];
}
$result = $statement->getResult();
return $result->fetchAllAssoc();
return $statement->getResult()->fetchAllAssoc();
}
/** @return array<int, array<string|null>> */
@ -1214,9 +1211,8 @@ class Privileges
SELECT *, \'r\' AS `Type`
FROM `mysql`.`procs_priv`
WHERE Db = ' . $this->dbi->quoteString($db->getName()) . ';';
$result = $this->dbi->query($query);
return $result->fetchAllAssoc();
return $this->dbi->query($query)->fetchAllAssoc();
}
/**
@ -1253,9 +1249,9 @@ class Privileges
string $initial = '',
): string {
$linkClass = '';
if ($linktype == 'edit') {
if ($linktype === 'edit') {
$linkClass = 'edit_user_anchor';
} elseif ($linktype == 'export') {
} elseif ($linktype === 'export') {
$linkClass = 'export_user_anchor ajax';
}

View File

@ -489,7 +489,7 @@ class Monitor
$return = [];
if (strlen($database) > 0) {
if ($database !== '') {
$this->dbi->selectDb($database);
}

View File

@ -10,6 +10,7 @@ namespace PhpMyAdmin\Setup;
use PhpMyAdmin\Config\ConfigFile;
use PhpMyAdmin\Version;
use function array_is_list;
use function array_keys;
use function count;
use function gmdate;
@ -105,7 +106,7 @@ class ConfigGenerator
. var_export($varValue, true) . ';' . $eol;
}
if (self::isZeroBasedArray($varValue)) {
if (array_is_list($varValue)) {
return "\$cfg['" . $varName . "'] = "
. self::exportZeroBasedArray($varValue, $eol)
. ';' . $eol;
@ -122,22 +123,6 @@ class ConfigGenerator
return $ret;
}
/**
* Check whether $array is a continuous 0-based array
*
* @param mixed[] $array Array to check
*/
private static function isZeroBasedArray(array $array): bool
{
for ($i = 0, $nb = count($array); $i < $nb; $i++) {
if (! isset($array[$i])) {
return false;
}
}
return true;
}
/**
* Exports continuous 0-based array
*
@ -151,20 +136,13 @@ class ConfigGenerator
$retv[] = var_export($v, true);
}
$ret = '[';
if (count($retv) <= 4) {
// up to 4 values - one line
return $ret . implode(', ', $retv) . ']';
return '[' . implode(', ', $retv) . ']';
}
// more than 4 values - value per line
$imax = count($retv);
/** @infection-ignore-all */
for ($i = 0; $i < $imax; $i++) {
$ret .= ($i > 0 ? ',' : '') . $eol . ' ' . $retv[$i];
}
return $ret . ']';
return '[' . $eol . ' ' . implode(',' . $eol . ' ', $retv) . ']';
}
/**
@ -189,7 +167,7 @@ class ConfigGenerator
foreach ($server as $k => $v) {
$k = preg_replace('/[^A-Za-z0-9_]/', '_', (string) $k);
$ret .= "\$cfg['Servers'][\$i]['" . $k . "'] = "
. (is_array($v) && self::isZeroBasedArray($v)
. (is_array($v) && array_is_list($v)
? self::exportZeroBasedArray($v, $eol)
: var_export($v, true))
. ';' . $eol;

View File

@ -153,7 +153,7 @@ class Index
sprintf(__('A newer version of phpMyAdmin is available and you should consider upgrading.'
. ' The newest version is %s, released on %s.'), $version, $date),
);
} elseif ($versionLocal % 100 == 0) {
} elseif ($versionLocal % 100 === 0) {
self::messagesSet(
'notice',
$messageId,

View File

@ -16,7 +16,6 @@ use function is_array;
use function preg_match;
use function str_contains;
use function str_replace;
use function strlen;
use function strncasecmp;
use function trim;
@ -290,7 +289,7 @@ final class Search
// create gis data from the criteria input
$gisData = Gis::createData($criteriaValues, $this->dbi->getVersion());
$where = $geomFunctionApplied . ' ' . $funcType . ' ' . $gisData;
} elseif (strlen($criteriaValues) > 0) {
} elseif ($criteriaValues != '') {
$where = $geomFunctionApplied . ' '
. $funcType . " '" . $criteriaValues . "'";
}

View File

@ -468,7 +468,7 @@ class Table implements Stringable
$query .= '(' . $length . ')';
}
if ($attribute != '') {
if ($attribute !== '') {
$query .= ' ' . $attribute;
if ($isTimestamp && stripos($attribute, 'TIMESTAMP') !== false && $length !== '') {
@ -584,7 +584,7 @@ class Table implements Stringable
// move column
if ($moveTo === '-first') { // dash can't appear as part of column name
$query .= ' FIRST';
} elseif ($moveTo != '') {
} elseif ($moveTo !== '') {
$query .= ' AFTER ' . Util::backquote($moveTo);
}
@ -1691,7 +1691,7 @@ class Table implements Stringable
}
// do checking based on property
if ($property == self::PROP_SORTED_COLUMN) {
if ($property === self::PROP_SORTED_COLUMN) {
if (! isset($this->uiprefs[$property])) {
return false;
}
@ -1719,7 +1719,7 @@ class Table implements Stringable
return false;
}
if ($property == self::PROP_COLUMN_ORDER || $property == self::PROP_COLUMN_VISIB) {
if ($property === self::PROP_COLUMN_ORDER || $property === self::PROP_COLUMN_VISIB) {
if ($this->isView() || ! isset($this->uiprefs[$property])) {
return false;
}
@ -1759,7 +1759,7 @@ class Table implements Stringable
}
// we want to save the create time if the property is PROP_COLUMN_ORDER
if (! $this->isView() && ($property == self::PROP_COLUMN_ORDER || $property == self::PROP_COLUMN_VISIB)) {
if (! $this->isView() && ($property === self::PROP_COLUMN_ORDER || $property === self::PROP_COLUMN_VISIB)) {
$currCreateTime = $this->getStatusInfo('CREATE_TIME');
if ($tableCreateTime === null || $tableCreateTime != $currCreateTime) {
// there is no $table_create_time, or
@ -1883,7 +1883,7 @@ class Table implements Stringable
*/
public function updateDisplayField(string $displayField, DisplayFeature $displayFeature): void
{
if ($displayField == '') {
if ($displayField === '') {
$updQuery = 'DELETE FROM '
. Util::backquote($displayFeature->database)
. '.' . Util::backquote($displayFeature->tableInfo)

View File

@ -157,7 +157,7 @@ class Tracker
$relation = new Relation($dbi);
$config = Config::getInstance();
if ($trackingSet == '') {
if ($trackingSet === '') {
$trackingSet = $config->selectedServer['tracking_default_statements'];
}
@ -259,7 +259,7 @@ class Tracker
$date = Util::date('Y-m-d H:i:s');
$config = Config::getInstance();
if ($trackingSet == '') {
if ($trackingSet === '') {
$trackingSet = $config->selectedServer['tracking_default_statements'];
}

View File

@ -376,11 +376,11 @@ class Transformations
// Do we have any parameter to set?
$hasValue =
strlen($mimetype) > 0 ||
strlen($transformation) > 0 ||
strlen($transformationOpts) > 0 ||
strlen($inputTransform) > 0 ||
strlen($inputTransformOpts) > 0;
$mimetype != '' ||
$transformation != '' ||
$transformationOpts !== '' ||
$inputTransform !== '' ||
$inputTransformOpts !== '';
$testQry = '
SELECT `mimetype`,
@ -396,7 +396,7 @@ class Transformations
if ($testRs->numRows() > 0) {
$row = $testRs->fetchAssoc();
if (! $forcedelete && ($hasValue || strlen($row['comment']) > 0)) {
if (! $forcedelete && ($hasValue || $row['comment'] != '')) {
$updQuery = 'UPDATE '
. Util::backquote($browserTransformationFeature->database) . '.'
. Util::backquote($browserTransformationFeature->columnInfo)
@ -472,11 +472,11 @@ class Transformations
. Util::backquote($browserTransformationFeature->columnInfo)
. ' WHERE ';
if ($column != '' && $table != '') {
if ($column !== '' && $table !== '') {
$deleteSql .= '`db_name` = \'' . $db . '\' AND '
. '`table_name` = \'' . $table . '\' AND '
. '`column_name` = \'' . $column . '\' ';
} elseif ($table != '') {
} elseif ($table !== '') {
$deleteSql .= '`db_name` = \'' . $db . '\' AND '
. '`table_name` = \'' . $table . '\' ';
} else {

View File

@ -32,8 +32,7 @@ class Triggers
/** @var array<int, string> */
private array $time = ['BEFORE', 'AFTER'];
/** @var array<int, string> */
private array $event = ['INSERT', 'UPDATE', 'DELETE'];
private const EVENTS = ['INSERT', 'UPDATE', 'DELETE'];
public function __construct(private DatabaseInterface $dbi)
{
@ -206,7 +205,7 @@ class Triggers
$GLOBALS['errors'][] = __('You must provide a valid timing for the trigger!');
}
if (! empty($_POST['item_event']) && in_array($_POST['item_event'], $this->event, true)) {
if (! empty($_POST['item_event']) && in_array($_POST['item_event'], self::EVENTS, true)) {
$query .= $_POST['item_event'] . ' ';
} else {
$GLOBALS['errors'][] = __('You must provide a valid event for the trigger!');

View File

@ -8,6 +8,7 @@ declare(strict_types=1);
namespace PhpMyAdmin;
use PhpMyAdmin\Crypto\Crypto;
use PhpMyAdmin\Tests\UrlTest;
use function base64_decode;
use function base64_encode;
@ -326,13 +327,9 @@ class Url
/** @return string|false */
private static function getArgSeparatorValueFromIni(): string|bool
{
/**
* @psalm-suppress ArgumentTypeCoercion
* @phpstan-ignore-next-line
*/
if (method_exists('PhpMyAdmin\Tests\UrlTest', 'getInputArgSeparator')) {
// phpcs:ignore SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly.ReferenceViaFullyQualifiedName
return \PhpMyAdmin\Tests\UrlTest::getInputArgSeparator();
/** @phpstan-ignore-next-line */
if (method_exists(UrlTest::class, 'getInputArgSeparator')) {
return UrlTest::getInputArgSeparator();
}
return ini_get('arg_separator.input');

View File

@ -77,7 +77,7 @@ class UserPassword
}
$sqlQuery = 'SET password = '
. ($password == '' ? '\'\'' : $hashingFunction . '(\'***\')');
. ($password === '' ? '\'\'' : $hashingFunction . '(\'***\')');
$isPerconaOrMySql = Compatibility::isMySqlOrPerconaDb();
if ($isPerconaOrMySql && $serverVersion >= 50706) {
@ -220,7 +220,7 @@ class UserPassword
. ' WHERE `User` = ' . $this->dbi->quoteString($username)
. ' AND Host = ' . $this->dbi->quoteString($hostname) . ';';
} else {
$localQuery = 'SET password = ' . ($password == ''
$localQuery = 'SET password = ' . ($password === ''
? '\'\''
: $hashingFunction . '(' . $this->dbi->quoteString($password) . ')');
}

View File

@ -248,12 +248,12 @@ class Util
*
* @param Stringable|string|null $identifier the database, table or field name to "backquote"
* @param string $compatibility string compatibility mode (used by dump functions)
* @param bool|null $doIt a flag to bypass this function (used by dump functions)
* @param bool $doIt a flag to bypass this function (used by dump functions)
*/
public static function backquoteCompat(
Stringable|string|null $identifier,
string $compatibility = 'MSSQL',
bool|null $doIt = true,
bool $doIt = true,
): string {
$identifier = (string) $identifier;
if ($identifier === '' || $identifier === '*') {
@ -518,12 +518,12 @@ class Util
_pgettext('Short week day name for Saturday', 'Sat'),
];
if ($format == '') {
if ($format === '') {
/* l10n: See https://www.php.net/manual/en/function.strftime.php */
$format = __('%B %d, %Y at %I:%M %p');
}
if ($timestamp == -1) {
if ($timestamp === -1) {
$timestamp = time();
}
@ -585,7 +585,7 @@ class Util
$urlParts = parse_url($url);
if (is_array($urlParts) && isset($urlParts['query']) && strlen($separator) > 0) {
if (is_array($urlParts) && isset($urlParts['query']) && $separator !== '') {
return explode($separator, $urlParts['query']);
}
@ -865,7 +865,7 @@ class Util
++$i;
}
if ($i != 0) {
if ($i !== 0) {
--$i;
}
@ -1795,7 +1795,7 @@ class Util
if (
isset($_REQUEST['tbl_group'])
&& is_scalar($_REQUEST['tbl_group'])
&& strlen((string) $_REQUEST['tbl_group']) > 0
&& (string) $_REQUEST['tbl_group'] !== ''
) {
$group = $dbi->escapeMysqlWildcards((string) $_REQUEST['tbl_group']);
$groupWithSeparator = $dbi->escapeMysqlWildcards(
@ -2078,7 +2078,7 @@ class Util
}
[$keyName, $value] = $keyValueArray;
$value = trim(strtolower($value));
$value = strtolower(trim($value));
if (strtolower(trim($keyName)) === 'proto' && in_array($value, ['http', 'https'], true)) {
return $value;
}

View File

@ -22,7 +22,6 @@ use function is_dir;
use function parse_url;
use function preg_match;
use function stream_context_create;
use function strlen;
use const CURL_IPRESOLVE_V4;
use const CURLINFO_HTTP_CODE;
@ -87,9 +86,9 @@ class HttpRequest
*/
private function handleContext(array $context): array
{
if (strlen($this->proxyUrl) > 0) {
if ($this->proxyUrl !== '') {
$context['http'] = ['proxy' => $this->proxyUrl, 'request_fulluri' => true];
if (strlen($this->proxyUser) > 0) {
if ($this->proxyUser !== '') {
$auth = base64_encode($this->proxyUser . ':' . $this->proxyPass);
$context['http']['header'] = 'Proxy-Authorization: Basic '
. $auth . "\r\n";
@ -111,11 +110,11 @@ class HttpRequest
int $httpStatus,
bool $returnOnlyStatus,
): string|bool|null {
if ($httpStatus == 404) {
if ($httpStatus === 404) {
return false;
}
if ($httpStatus != 200) {
if ($httpStatus !== 200) {
return null;
}
@ -148,9 +147,9 @@ class HttpRequest
}
$curlStatus = 1;
if (strlen($this->proxyUrl) > 0) {
if ($this->proxyUrl !== '') {
$curlStatus &= (int) curl_setopt($curlHandle, CURLOPT_PROXY, $this->proxyUrl);
if (strlen($this->proxyUser) > 0) {
if ($this->proxyUser !== '') {
$curlStatus &= (int) curl_setopt(
$curlHandle,
CURLOPT_PROXYUSERPWD,

View File

@ -251,7 +251,7 @@ class ZipExtension
$uncLen = strlen($dump);
$crc = crc32($dump);
$zdata = (string) gzcompress($dump);
$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
$zdata = substr(substr($zdata, 0, -4), 2); // fix crc bug
$cLen = strlen($zdata);
$fr = "\x50\x4b\x03\x04"
. "\x14\x00" // ver needed to extract

View File

@ -126,43 +126,6 @@ class ConfigGeneratorTest extends AbstractTestCase
self::assertSame(SODIUM_CRYPTO_SECRETBOX_KEYBYTES, mb_strlen($binaryString, '8bit'));
}
/**
* Test for ConfigGenerator::isZeroBasedArray
*/
public function testIsZeroBasedArray(): void
{
$reflection = new ReflectionClass(ConfigGenerator::class);
$method = $reflection->getMethod('isZeroBasedArray');
self::assertFalse(
$method->invoke(
null,
['a' => 1, 'b' => 2],
),
);
self::assertFalse(
$method->invoke(
null,
[0 => 1, 1 => 2, 3 => 3],
),
);
self::assertTrue(
$method->invoke(
null,
[],
),
);
self::assertTrue(
$method->invoke(
null,
[1, 2, 3],
),
);
}
/**
* Test for ConfigGenerator::exportZeroBasedArray
*/