From a3d237f0b4d1262039a5a2bf070a164cf447ab9b Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 5 Dec 2023 00:04:18 +0100 Subject: [PATCH 01/11] Remove useless in_array It's always going to be either true or false. There are no other options. Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 5 ----- src/Footer.php | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d0fb5bf6fc..165304dd79 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -10580,11 +10580,6 @@ parameters: count: 1 path: src/Font.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Footer.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 4 diff --git a/src/Footer.php b/src/Footer.php index 45e4f9ea03..67bf689cd5 100644 --- a/src/Footer.php +++ b/src/Footer.php @@ -141,7 +141,7 @@ class Footer $params['server'] = $GLOBALS['server']; - if (isset($_REQUEST['single_table']) && in_array($_REQUEST['single_table'], [true, false])) { + if (isset($_REQUEST['single_table'])) { $params['single_table'] = $_REQUEST['single_table']; } From b4b617d9da12f7322fe8cc0c4d3c2187a070135a Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 5 Dec 2023 00:27:28 +0100 Subject: [PATCH 02/11] Duplicate Gis::getDataTypes() Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 2 +- src/InsertEdit.php | 10 ++-------- tests/classes/InsertEditTest.php | 14 +++++++------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 165304dd79..35a24979d5 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -11727,7 +11727,7 @@ parameters: - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 8 + count: 7 path: src/InsertEdit.php - diff --git a/src/InsertEdit.php b/src/InsertEdit.php index c45a35b0d2..7c749af7c5 100644 --- a/src/InsertEdit.php +++ b/src/InsertEdit.php @@ -730,7 +730,6 @@ class InsertEdit * @param mixed[] $extractedColumnspec associative array containing type, * spec_in_brackets and possibly * enum_set_values (another array) - * @param mixed[] $gisDataTypes list of GIS data types * @param string $columnNameAppendix string to append to column name in input * @param bool $asIs use the data as is, used in repopulating * @@ -742,7 +741,6 @@ class InsertEdit array $currentRow, InsertEditColumn $column, array $extractedColumnspec, - array $gisDataTypes, string $columnNameAppendix, bool $asIs, ): array { @@ -772,7 +770,7 @@ class InsertEdit ? $currentRow[$column->field] : Util::addMicroseconds($currentRow[$column->field]); $specialChars = htmlspecialchars($currentRow[$column->field], ENT_COMPAT); - } elseif (in_array($column->trueType, $gisDataTypes)) { + } elseif (in_array($column->trueType, Gis::getDataTypes(), true)) { // Convert gis data to Well Know Text format $currentRow[$column->field] = $asIs ? $currentRow[$column->field] @@ -1635,9 +1633,6 @@ class InsertEdit // in the name attribute (see bug #1746964 ) $columnNameAppendix = $vkey . '[' . $fieldHashMd5 . ']'; - // Get a list of GIS data types. - $gisDataTypes = Gis::getDataTypes(); - // Prepares the field value if ($currentRow !== []) { // (we are editing) @@ -1651,7 +1646,6 @@ class InsertEdit $currentRow, $column, $extractedColumnspec, - $gisDataTypes, $columnNameAppendix, $asIs, ); @@ -1872,7 +1866,7 @@ class InsertEdit 'is_value_foreign_link' => $foreignData['foreign_link'] === true, 'backup_field' => $backupField, 'data' => $data, - 'gis_data_types' => $gisDataTypes, + 'gis_data_types' => Gis::getDataTypes(), 'foreign_dropdown' => $foreignDropdown, 'data_type' => $dataType, 'textarea_cols' => $textareaCols, diff --git a/tests/classes/InsertEditTest.php b/tests/classes/InsertEditTest.php index 802428c034..cda8531c24 100644 --- a/tests/classes/InsertEditTest.php +++ b/tests/classes/InsertEditTest.php @@ -1063,7 +1063,7 @@ class InsertEditTest extends AbstractTestCase $this->insertEdit, InsertEdit::class, 'getSpecialCharsAndBackupFieldForExistingRow', - [$currentRow, $column, [], [], 'a', false], + [$currentRow, $column, [], 'a', false], ); $this->assertEquals( @@ -1094,7 +1094,7 @@ class InsertEditTest extends AbstractTestCase $this->insertEdit, InsertEdit::class, 'getSpecialCharsAndBackupFieldForExistingRow', - [$currentRow, $column, $extractedColumnSpec, [], 'a', false], + [$currentRow, $column, $extractedColumnSpec, 'a', false], ); $this->assertEquals( @@ -1107,7 +1107,7 @@ class InsertEditTest extends AbstractTestCase $this->insertEdit, InsertEdit::class, 'getSpecialCharsAndBackupFieldForExistingRow', - [$currentRow, $column, $extractedColumnSpec, [], 'a', true], + [$currentRow, $column, $extractedColumnSpec, 'a', true], ); $this->assertEquals( @@ -1133,7 +1133,7 @@ class InsertEditTest extends AbstractTestCase $extractedColumnSpec['spec_in_brackets'] = '20'; $column = new InsertEditColumn( 'f', - 'int', + 'geometry', false, 'PRI', null, @@ -1149,7 +1149,7 @@ class InsertEditTest extends AbstractTestCase $this->insertEdit, InsertEdit::class, 'getSpecialCharsAndBackupFieldForExistingRow', - [$currentRow, $column, $extractedColumnSpec, ['int'], 'a', false], + [$currentRow, $column, $extractedColumnSpec, 'a', false], ); $this->assertEquals( @@ -1181,7 +1181,7 @@ class InsertEditTest extends AbstractTestCase $this->insertEdit, InsertEdit::class, 'getSpecialCharsAndBackupFieldForExistingRow', - [$currentRow, $column, $extractedColumnSpec, ['int'], 'a', false], + [$currentRow, $column, $extractedColumnSpec, 'a', false], ); $this->assertEquals( @@ -1202,7 +1202,7 @@ class InsertEditTest extends AbstractTestCase $this->insertEdit, InsertEdit::class, 'getSpecialCharsAndBackupFieldForExistingRow', - [$currentRow, $column, $extractedColumnSpec, ['int'], 'a', false], + [$currentRow, $column, $extractedColumnSpec, 'a', false], ); $this->assertEquals( From 1995c4f3120d98861ba04df3fa6e46dab0303da8 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 5 Dec 2023 01:19:18 +0100 Subject: [PATCH 03/11] Revert commit 0e344b6 Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 2 +- src/Config.php | 2 +- src/ErrorHandler.php | 5 +++-- src/Util.php | 21 --------------------- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 35a24979d5..e124ccdd12 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -19002,7 +19002,7 @@ parameters: - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 6 + count: 5 path: src/Util.php - diff --git a/src/Config.php b/src/Config.php index 2d2cd8073d..c532330cd6 100644 --- a/src/Config.php +++ b/src/Config.php @@ -351,7 +351,7 @@ class Config * Parses the configuration file, we throw away any errors or * output. */ - $canUseErrorReporting = Util::isErrorReportingAvailable(); + $canUseErrorReporting = function_exists('error_reporting'); $oldErrorReporting = null; if ($canUseErrorReporting) { $oldErrorReporting = error_reporting(0); diff --git a/src/ErrorHandler.php b/src/ErrorHandler.php index 6c0d4c4368..579480dddc 100644 --- a/src/ErrorHandler.php +++ b/src/ErrorHandler.php @@ -16,6 +16,7 @@ use function array_splice; use function count; use function defined; use function error_reporting; +use function function_exists; use function htmlspecialchars; use function sprintf; @@ -61,7 +62,7 @@ class ErrorHandler public function __construct() { - if (! Util::isErrorReportingAvailable()) { + if (! function_exists('error_reporting')) { return; } @@ -192,7 +193,7 @@ class ErrorHandler string $errfile, int $errline, ): bool { - if (Util::isErrorReportingAvailable()) { + if (function_exists('error_reporting')) { /** * Check if Error Control Operator (@) was used, but still show * user errors even in this case. diff --git a/src/Util.php b/src/Util.php index bf5dfc42f9..3464a0dfe1 100644 --- a/src/Util.php +++ b/src/Util.php @@ -38,7 +38,6 @@ use function htmlspecialchars; use function htmlspecialchars_decode; use function implode; use function in_array; -use function ini_get; use function is_array; use function is_numeric; use function is_object; @@ -82,7 +81,6 @@ use function uksort; use const ENT_COMPAT; use const ENT_QUOTES; use const PHP_INT_SIZE; -use const PHP_MAJOR_VERSION; use const STR_PAD_LEFT; /** @@ -2109,25 +2107,6 @@ class Util return ''; } - /** - * Check if error reporting is available - */ - public static function isErrorReportingAvailable(): bool - { - // issue #16256 - PHP 7.x does not return false for a core function - if (PHP_MAJOR_VERSION < 8) { - $disabled = ini_get('disable_functions'); - if (is_string($disabled)) { - $disabled = explode(',', $disabled); - $disabled = array_map(trim(...), $disabled); - - return ! in_array('error_reporting', $disabled); - } - } - - return function_exists('error_reporting'); - } - public static function getTableListPosition(ServerRequest $request, string $db): int { if (! isset($_SESSION['tmpval']['table_limit_offset']) || $_SESSION['tmpval']['table_limit_offset_db'] != $db) { From 58a3de6ad641f25011e24d236ae734dabfbe78b5 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 5 Dec 2023 14:35:59 +0100 Subject: [PATCH 04/11] Fix type hint Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 5 ----- src/Controllers/Server/VariablesController.php | 2 +- src/Providers/ServerVariables/MariaDbMySqlKbsProvider.php | 2 +- .../ServerVariables/ServerVariablesProviderInterface.php | 2 +- src/Providers/ServerVariables/VoidProvider.php | 2 +- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index e124ccdd12..d783d75c11 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -5145,11 +5145,6 @@ parameters: count: 1 path: src/Controllers/Server/Variables/SetVariableController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Controllers/Server/VariablesController.php - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" count: 1 diff --git a/src/Controllers/Server/VariablesController.php b/src/Controllers/Server/VariablesController.php index b8f14fb988..94b2fa06bc 100644 --- a/src/Controllers/Server/VariablesController.php +++ b/src/Controllers/Server/VariablesController.php @@ -73,7 +73,7 @@ class VariablesController extends AbstractController $variables[] = [ 'name' => $name, - 'is_editable' => ! in_array(strtolower($name), $staticVariables), + 'is_editable' => ! in_array(strtolower($name), $staticVariables, true), 'doc_link' => $docLink, 'value' => $formattedValue, 'is_escaped' => $isEscaped, diff --git a/src/Providers/ServerVariables/MariaDbMySqlKbsProvider.php b/src/Providers/ServerVariables/MariaDbMySqlKbsProvider.php index 09222a037c..688b128c67 100644 --- a/src/Providers/ServerVariables/MariaDbMySqlKbsProvider.php +++ b/src/Providers/ServerVariables/MariaDbMySqlKbsProvider.php @@ -18,7 +18,7 @@ class MariaDbMySqlKbsProvider implements ServerVariablesProviderInterface } } - /** @return mixed[] */ + /** @return string[] */ public function getStaticVariables(): array { return []; diff --git a/src/Providers/ServerVariables/ServerVariablesProviderInterface.php b/src/Providers/ServerVariables/ServerVariablesProviderInterface.php index 0cc6e003f3..8a8031fd54 100644 --- a/src/Providers/ServerVariables/ServerVariablesProviderInterface.php +++ b/src/Providers/ServerVariables/ServerVariablesProviderInterface.php @@ -8,7 +8,7 @@ interface ServerVariablesProviderInterface { public function getVariableType(string $name): string|null; - /** @return mixed[] */ + /** @return string[] */ public function getStaticVariables(): array; public function getDocLinkByNameMariaDb(string $name): string|null; diff --git a/src/Providers/ServerVariables/VoidProvider.php b/src/Providers/ServerVariables/VoidProvider.php index 453d62f7ab..af07a66b71 100644 --- a/src/Providers/ServerVariables/VoidProvider.php +++ b/src/Providers/ServerVariables/VoidProvider.php @@ -11,7 +11,7 @@ class VoidProvider implements ServerVariablesProviderInterface return null; } - /** @return mixed[] */ + /** @return string[] */ public function getStaticVariables(): array { return []; From 063a49479333c1c5d1c2c55b80eb46e96c414cee Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 5 Dec 2023 14:52:04 +0100 Subject: [PATCH 05/11] Improve type hint of getColumnsWithIndex() Signed-off-by: Kamil Tekiela --- src/Controllers/Table/StructureController.php | 6 +- src/Index.php | 2 +- src/Table/Table.php | 70 +++++++++---------- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/Controllers/Table/StructureController.php b/src/Controllers/Table/StructureController.php index 67dab950f2..9770a9da90 100644 --- a/src/Controllers/Table/StructureController.php +++ b/src/Controllers/Table/StructureController.php @@ -147,9 +147,9 @@ class StructureController extends AbstractController /** * Displays the table structure ('show table' works correct since 3.23.03) * - * @param mixed[] $columnsWithUniqueIndex Columns with unique index - * @param ColumnFull[] $fields Fields - * @param mixed[] $columnsWithIndex Columns with index + * @param (string|int)[] $columnsWithUniqueIndex Columns with unique index + * @param ColumnFull[] $fields Fields + * @param (string|int)[] $columnsWithIndex Columns with index * @psalm-param non-empty-string $route */ protected function displayStructure( diff --git a/src/Index.php b/src/Index.php index 5b6984344b..6f31c17d8f 100644 --- a/src/Index.php +++ b/src/Index.php @@ -40,7 +40,7 @@ class Index /** * Columns in index * - * @var array + * @var array */ private array $columns = []; diff --git a/src/Table/Table.php b/src/Table/Table.php index e19577bcef..6bd75a5063 100644 --- a/src/Table/Table.php +++ b/src/Table/Table.php @@ -443,23 +443,23 @@ class Table implements Stringable /** * generates column specification for ALTER or CREATE TABLE syntax * - * @param string $name name - * @param string $type type ('INT', 'VARCHAR', 'BIT', ...) - * @param string $length length ('2', '5,2', '', ...) - * @param string $attribute attribute - * @param string $collation collation - * @param bool|string $null with 'NULL' or 'NOT NULL' - * @param string $defaultType whether default is CURRENT_TIMESTAMP, - * NULL, NONE, USER_DEFINED, UUID - * @param string $defaultValue default value for USER_DEFINED - * default type - * @param string $extra 'AUTO_INCREMENT' - * @param string $comment field comment - * @param string $virtuality virtuality of the column - * @param string $expression expression for the virtual column - * @param string $moveTo new position for column - * @param mixed[]|null $columnsWithIndex Fields having PRIMARY or UNIQUE KEY indexes - * @param string|null $oldColumnName Old column name + * @param string $name name + * @param string $type type ('INT', 'VARCHAR', 'BIT', ...) + * @param string $length length ('2', '5,2', '', ...) + * @param string $attribute attribute + * @param string $collation collation + * @param bool|string $null with 'NULL' or 'NOT NULL' + * @param string $defaultType whether default is CURRENT_TIMESTAMP, + * NULL, NONE, USER_DEFINED, UUID + * @param string $defaultValue default value for USER_DEFINED + * default type + * @param string $extra 'AUTO_INCREMENT' + * @param string $comment field comment + * @param string $virtuality virtuality of the column + * @param string $expression expression for the virtual column + * @param string $moveTo new position for column + * @param (string|int)[]|null $columnsWithIndex Fields having PRIMARY or UNIQUE KEY indexes + * @param string|null $oldColumnName Old column name * * @return string field specification * @@ -751,23 +751,23 @@ class Table implements Stringable * * @see Table::generateFieldSpec() * - * @param string $oldcol old column name - * @param string $newcol new column name - * @param string $type type ('INT', 'VARCHAR', 'BIT', ...) - * @param string $length length ('2', '5,2', '', ...) - * @param string $attribute attribute - * @param string $collation collation - * @param bool|string $null with 'NULL' or 'NOT NULL' - * @param string $defaultType whether default is CURRENT_TIMESTAMP, - * NULL, NONE, USER_DEFINED - * @param string $defaultValue default value for USER_DEFINED default - * type - * @param string $extra 'AUTO_INCREMENT' - * @param string $comment field comment - * @param string $virtuality virtuality of the column - * @param string $expression expression for the virtual column - * @param string $moveTo new position for column - * @param mixed[]|null $columnsWithIndex Fields having PRIMARY or UNIQUE KEY indexes + * @param string $oldcol old column name + * @param string $newcol new column name + * @param string $type type ('INT', 'VARCHAR', 'BIT', ...) + * @param string $length length ('2', '5,2', '', ...) + * @param string $attribute attribute + * @param string $collation collation + * @param bool|string $null with 'NULL' or 'NOT NULL' + * @param string $defaultType whether default is CURRENT_TIMESTAMP, + * NULL, NONE, USER_DEFINED + * @param string $defaultValue default value for USER_DEFINED default + * type + * @param string $extra 'AUTO_INCREMENT' + * @param string $comment field comment + * @param string $virtuality virtuality of the column + * @param string $expression expression for the virtual column + * @param string $moveTo new position for column + * @param (string|int)[]|null $columnsWithIndex Fields having PRIMARY or UNIQUE KEY indexes * * @return string field specification */ @@ -2477,7 +2477,7 @@ class Table implements Stringable * * @param int $types types bitmask * - * @return mixed[] an array of columns + * @return (string|int)[] an array of columns */ public function getColumnsWithIndex(int $types): array { From 9d18c3d5e6e26c35732d7a400f1e0b952353c78e Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 5 Dec 2023 15:17:51 +0100 Subject: [PATCH 06/11] Fix type hint for getSupportedDatatypes() Signed-off-by: Kamil Tekiela uyi --- phpstan-baseline.neon | 11 ++++++++--- psalm-baseline.xml | 2 -- src/Database/Routines.php | 10 +++++++--- src/Util.php | 4 ++-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d783d75c11..62d2ac0857 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -9092,12 +9092,12 @@ parameters: - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 9 + count: 5 path: src/Database/Routines.php - message: "#^Cannot access an offset on mixed\\.$#" - count: 10 + count: 9 path: src/Database/Routines.php - @@ -9190,6 +9190,11 @@ parameters: count: 1 path: src/Database/Routines.php + - + message: "#^Cannot assign new offset to array\\\\|string\\|null\\.$#" + count: 1 + path: src/Database/Routines.php + - message: "#^Cannot call method has\\(\\) on PhpMyAdmin\\\\SqlParser\\\\Components\\\\OptionsArray\\|null\\.$#" count: 1 @@ -9202,7 +9207,7 @@ parameters: - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" - count: 24 + count: 23 path: src/Database/Routines.php - diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 499d63dbd4..e1b9fa4439 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -5152,7 +5152,6 @@ - @@ -5248,7 +5247,6 @@ $itemDefinition - $itemReturnType $itemSqlDataAccess diff --git a/src/Database/Routines.php b/src/Database/Routines.php index 23bdcc9775..3b73129379 100644 --- a/src/Database/Routines.php +++ b/src/Database/Routines.php @@ -361,7 +361,10 @@ class Routines } $retval['item_returntype'] = ''; - if (isset($_POST['item_returntype']) && in_array($_POST['item_returntype'], Util::getSupportedDatatypes())) { + if ( + isset($_POST['item_returntype']) + && in_array($_POST['item_returntype'], Util::getSupportedDatatypes(), true) + ) { $retval['item_returntype'] = $_POST['item_returntype']; } @@ -677,7 +680,7 @@ class Routines $itemReturnType = $_POST['item_returntype'] ?? null; - if (! empty($itemReturnType) && in_array($itemReturnType, Util::getSupportedDatatypes())) { + if ($itemReturnType !== '' && in_array($itemReturnType, Util::getSupportedDatatypes(), true)) { $query .= 'RETURNS ' . $itemReturnType; } else { $GLOBALS['errors'][] = __('You must provide a valid return type for the routine.'); @@ -1050,6 +1053,7 @@ class Routines || in_array( mb_strtolower($routine['item_param_type'][$i]), $noSupportTypes, + true, ) ) { $params[$i]['generator'] = null; @@ -1085,7 +1089,7 @@ class Routines $value = htmlentities(Util::unQuote($value), ENT_QUOTES); $params[$i]['htmlentities'][] = $value; } - } elseif (in_array(mb_strtolower($routine['item_param_type'][$i]), $noSupportTypes)) { + } elseif (in_array(mb_strtolower($routine['item_param_type'][$i]), $noSupportTypes, true)) { $params[$i]['input_type'] = null; } else { $params[$i]['input_type'] = 'text'; diff --git a/src/Util.php b/src/Util.php index 3464a0dfe1..60d9121e55 100644 --- a/src/Util.php +++ b/src/Util.php @@ -1259,7 +1259,7 @@ class Util * as specified in Types->getColumns() and returns an array * (useful for quickly checking if a datatype is supported). * - * @return mixed[] An array of datatypes. + * @return string[] An array of datatypes. */ public static function getSupportedDatatypes(): array { @@ -1285,7 +1285,7 @@ class Util * Returns a list of datatypes that are not (yet) handled by PMA. * Used by: /table/change and libraries/Routines.php * - * @return mixed[] list of datatypes + * @return string[] list of datatypes */ public static function unsupportedDatatypes(): array { From 48cd962475b931f181cdfb2f7e24327e3964b59d Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 5 Dec 2023 15:56:51 +0100 Subject: [PATCH 07/11] Fix type hint in exportDatabase() Signed-off-by: Kamil Tekiela t --- phpstan-baseline.neon | 35 +++++------------------------------ psalm-baseline.xml | 3 --- src/Export/Export.php | 12 ++++++------ 3 files changed, 11 insertions(+), 39 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 62d2ac0857..014ab3d1d9 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -3226,7 +3226,7 @@ parameters: path: src/Controllers/Export/ExportController.php - - message: "#^Parameter \\#2 \\$tables of method PhpMyAdmin\\\\Export\\\\Export\\:\\:exportDatabase\\(\\) expects array, mixed given\\.$#" + message: "#^Parameter \\#2 \\$tables of method PhpMyAdmin\\\\Export\\\\Export\\:\\:exportDatabase\\(\\) expects array\\, mixed given\\.$#" count: 2 path: src/Controllers/Export/ExportController.php @@ -3301,7 +3301,7 @@ parameters: path: src/Controllers/Export/ExportController.php - - message: "#^Parameter \\#4 \\$tableStructure of method PhpMyAdmin\\\\Export\\\\Export\\:\\:exportDatabase\\(\\) expects array, mixed given\\.$#" + message: "#^Parameter \\#4 \\$tableStructure of method PhpMyAdmin\\\\Export\\\\Export\\:\\:exportDatabase\\(\\) expects array\\, mixed given\\.$#" count: 2 path: src/Controllers/Export/ExportController.php @@ -3321,7 +3321,7 @@ parameters: path: src/Controllers/Export/ExportController.php - - message: "#^Parameter \\#5 \\$tableData of method PhpMyAdmin\\\\Export\\\\Export\\:\\:exportDatabase\\(\\) expects array, mixed given\\.$#" + message: "#^Parameter \\#5 \\$tableData of method PhpMyAdmin\\\\Export\\\\Export\\:\\:exportDatabase\\(\\) expects array\\, mixed given\\.$#" count: 2 path: src/Controllers/Export/ExportController.php @@ -10267,7 +10267,7 @@ parameters: - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 5 + count: 2 path: src/Export/Export.php - @@ -10332,12 +10332,7 @@ parameters: - message: "#^Parameter \\#1 \\$identifier of static method PhpMyAdmin\\\\Util\\:\\:backquote\\(\\) expects string\\|Stringable\\|null, mixed given\\.$#" - count: 2 - path: src/Export/Export.php - - - - message: "#^Parameter \\#1 \\$name of class PhpMyAdmin\\\\Table\\\\Table constructor expects string, mixed given\\.$#" - count: 2 + count: 1 path: src/Export/Export.php - @@ -10345,11 +10340,6 @@ parameters: count: 2 path: src/Export/Export.php - - - message: "#^Parameter \\#1 \\$str of method PhpMyAdmin\\\\DatabaseInterface\\:\\:quoteString\\(\\) expects string, mixed given\\.$#" - count: 1 - path: src/Export/Export.php - - message: "#^Parameter \\#1 \\$stream of function fwrite expects resource, mixed given\\.$#" count: 2 @@ -10370,21 +10360,6 @@ parameters: count: 1 path: src/Export/Export.php - - - message: "#^Parameter \\#2 \\$table of method PhpMyAdmin\\\\Plugins\\\\ExportPlugin\\:\\:exportData\\(\\) expects string, mixed given\\.$#" - count: 1 - path: src/Export/Export.php - - - - message: "#^Parameter \\#2 \\$table of method PhpMyAdmin\\\\Plugins\\\\ExportPlugin\\:\\:exportStructure\\(\\) expects string, mixed given\\.$#" - count: 4 - path: src/Export/Export.php - - - - message: "#^Parameter \\#2 \\$tables of method PhpMyAdmin\\\\Plugins\\\\ExportPlugin\\:\\:exportMetadata\\(\\) expects array\\\\|string, array given\\.$#" - count: 1 - path: src/Export/Export.php - - message: "#^Parameter \\#3 \\$dbAlias of method PhpMyAdmin\\\\Plugins\\\\ExportPlugin\\:\\:exportDBCreate\\(\\) expects string, mixed given\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e1b9fa4439..31fd975898 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -5952,11 +5952,9 @@ $dbAlias $dbAlias $table - $table $dbSelect - $tables getName()]['alias']]]> @@ -5987,7 +5985,6 @@ $dbAlias $dbAlias $table - $table $tableName $tbl $val diff --git a/src/Export/Export.php b/src/Export/Export.php index ba98d1f35e..6e45fb6956 100644 --- a/src/Export/Export.php +++ b/src/Export/Export.php @@ -599,10 +599,10 @@ class Export * Export at the database level * * @param DatabaseName $db the database to export - * @param mixed[] $tables the tables to export + * @param string[] $tables the tables to export * @param string $whatStrucOrData structure or data or both - * @param mixed[] $tableStructure whether to export structure for each table - * @param mixed[] $tableData whether to export data for each table + * @param string[] $tableStructure whether to export structure for each table + * @param string[] $tableData whether to export data for each table * @param ExportPlugin $exportPlugin the selected export plugin * @param string $errorUrl the URL in case of error * @param string $exportType the export type @@ -677,7 +677,7 @@ class Export if ( ($whatStrucOrData === 'structure' || $whatStrucOrData === 'structure_and_data') - && in_array($table, $tableStructure) + && in_array($table, $tableStructure, true) ) { // for a view, export a stand-in definition of the table // to resolve view dependencies (only when it's a single-file export) @@ -739,7 +739,7 @@ class Export // if this is a view or a merge table, don't export data if ( ($whatStrucOrData === 'data' || $whatStrucOrData === 'structure_and_data') - && in_array($table, $tableData) + && in_array($table, $tableData, true) && ! $isView ) { $tableObj = new Table($table, $db->getName(), $this->dbi); @@ -764,7 +764,7 @@ class Export if ( ! isset($GLOBALS['sql_create_trigger']) || ($whatStrucOrData !== 'structure' && $whatStrucOrData !== 'structure_and_data') - || ! in_array($table, $tableStructure) + || ! in_array($table, $tableStructure, true) ) { continue; } From 0d5dd21bf68076f4525af368250f23bd835e8896 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 5 Dec 2023 23:18:42 +0100 Subject: [PATCH 08/11] Refactor getOs() Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 5 ----- src/Server/SysInfo/SysInfo.php | 5 ++--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 014ab3d1d9..90796e988f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -17355,11 +17355,6 @@ parameters: count: 1 path: src/Server/SysInfo/SunOs.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Server/SysInfo/SysInfo.php - - message: "#^Class COM referenced with incorrect case\\: com\\.$#" count: 1 diff --git a/src/Server/SysInfo/SysInfo.php b/src/Server/SysInfo/SysInfo.php index ee30929a4c..ae0e277424 100644 --- a/src/Server/SysInfo/SysInfo.php +++ b/src/Server/SysInfo/SysInfo.php @@ -28,9 +28,8 @@ class SysInfo public static function getOs(string $phpOs = PHP_OS): string { // look for common UNIX-like systems - $unixLike = ['FreeBSD', 'DragonFly']; - if (in_array($phpOs, $unixLike)) { - $phpOs = 'Linux'; + if (in_array($phpOs, ['FreeBSD', 'DragonFly'], true)) { + return 'Linux'; } return ucfirst($phpOs); From b658499250238aa66f5359292e0290eb54f6d45d Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 5 Dec 2023 23:43:50 +0100 Subject: [PATCH 09/11] Fix type hint in Tracking Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 5 ----- src/Tracking/Tracking.php | 21 ++++++++++----------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 90796e988f..8db91dc54b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -18620,11 +18620,6 @@ parameters: count: 1 path: src/Tracking/Tracker.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 4 - path: src/Tracking/Tracking.php - - message: "#^Cannot access offset 'COLUMNS' on mixed\\.$#" count: 1 diff --git a/src/Tracking/Tracking.php b/src/Tracking/Tracking.php index 20b87e4f43..f679b680a3 100644 --- a/src/Tracking/Tracking.php +++ b/src/Tracking/Tracking.php @@ -88,7 +88,7 @@ class Tracking * Filters tracking entries * * @param list $data the entries to filter - * @param mixed[] $filterUsers users + * @param string[] $filterUsers users * * @return mixed[] filtered entries */ @@ -101,10 +101,9 @@ class Tracking $tmpEntries = []; $id = 0; foreach ($data as $entry) { - $filteredUser = in_array($entry['username'], $filterUsers); if ( $this->isDateBetweenInclusive(new DateTimeImmutable($entry['date']), $dateFrom, $dateTo) - && (in_array('*', $filterUsers) || $filteredUser) + && (in_array('*', $filterUsers, true) || in_array($entry['username'], $filterUsers, true)) ) { $tmpEntries[] = [ 'id' => $id, @@ -190,7 +189,7 @@ class Tracking * * @param TrackedData $trackedData data * @param mixed[] $urlParams url params - * @param mixed[] $filterUsers filter users + * @param string[] $filterUsers filter users * @psalm-param 'schema'|'data'|'schema_and_data' $logType */ public function getHtmlForTrackingReport( @@ -313,7 +312,7 @@ class Tracking * * @param TrackedData $trackedData data * @param mixed[] $urlParams url params - * @param mixed[] $filterUsers filter users + * @param string[] $filterUsers filter users * @param string $str1 HTML for log_type select * @param string $str2 HTML for "from date" * @param string $str3 HTML for "to date" @@ -458,7 +457,7 @@ class Tracking * Function to get html for data manipulation statements * * @param TrackedData $trackedData data - * @param mixed[] $filterUsers filter users + * @param string[] $filterUsers filter users * @param mixed[] $urlParams url parameters * @param int $ddlogCount data definition log count * @param string $dropImageOrText drop image or text @@ -493,7 +492,7 @@ class Tracking * Function to get html for data definition statements in schema snapshot * * @param TrackedData $trackedData data - * @param mixed[] $filterUsers filter users + * @param string[] $filterUsers filter users * @param mixed[] $urlParams url parameters * @param string $dropImageOrText drop image or text * @@ -527,7 +526,7 @@ class Tracking * Function to get html for data statements in schema snapshot * * @param list $logData tracked data - * @param mixed[] $filterUsers filter users + * @param string[] $filterUsers filter users * @param mixed[] $urlParams url parameters * @param string $dropImageOrText drop image or text * @param LogTypeEnum $logType DDL|DML @@ -551,8 +550,8 @@ class Tracking foreach ($logData as $entry) { if ( $this->isDateBetweenInclusive(new DateTimeImmutable($entry['date']), $dateFrom, $dateTo) - && (in_array('*', $filterUsers) - || in_array($entry['username'], $filterUsers)) + && (in_array('*', $filterUsers, true) + || in_array($entry['username'], $filterUsers, true)) ) { $entry['formated_statement'] = Generator::formatSql($entry['statement'], true); $deleteParam = 'delete_' . $logType->getLogName(); @@ -1071,7 +1070,7 @@ class Tracking /** * Function to get the entries * - * @param mixed[] $filterUsers filter users + * @param string[] $filterUsers filter users * @phpstan-param 'schema'|'data'|'schema_and_data' $logType * * @return mixed[] From 4fb335e96051fba6aef643a23f942f5fcdb6bf0a Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 5 Dec 2023 00:01:54 +0100 Subject: [PATCH 10/11] Make in_array strict Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 301 ++---------------- psalm-baseline.xml | 22 -- src/ConfigStorage/Relation.php | 2 +- .../Database/DesignerController.php | 2 +- .../Database/RoutinesController.php | 7 +- .../Database/StructureController.php | 4 +- src/Controllers/ErrorReportController.php | 2 +- src/Controllers/Export/ExportController.php | 2 +- src/Controllers/Import/ImportController.php | 2 +- .../Server/DatabasesController.php | 2 +- .../Server/Status/VariablesController.php | 4 +- src/Controllers/Setup/AbstractController.php | 2 +- src/Controllers/Table/ReplaceController.php | 3 +- src/Controllers/Table/SearchController.php | 6 +- .../Table/ZoomSearchController.php | 6 +- src/Controllers/Triggers/IndexController.php | 5 +- src/Controllers/View/CreateController.php | 6 +- src/Core.php | 2 +- src/CreateAddField.php | 2 +- src/Database/CentralColumns.php | 10 +- src/Database/Designer/Common.php | 2 +- src/Database/Events.php | 4 +- src/Database/Routines.php | 10 +- src/Display/Results.php | 3 + src/Error.php | 4 +- src/Export/Export.php | 2 +- src/Git.php | 4 +- src/Html/Generator.php | 2 +- src/InsertEdit.php | 14 +- src/Language.php | 2 +- src/Menu.php | 14 +- src/Navigation/NavigationTree.php | 24 +- src/Navigation/Nodes/Node.php | 4 +- src/Navigation/Nodes/NodeDatabase.php | 2 +- src/Normalization.php | 16 +- src/Plugins/Auth/AuthenticationSignon.php | 2 +- src/Plugins/Export/ExportHtmlword.php | 2 +- src/Plugins/Export/ExportLatex.php | 2 +- src/Plugins/Export/ExportTexytext.php | 2 +- src/Plugins/Schema/Dia/DiaRelationSchema.php | 4 +- src/Plugins/Schema/Eps/EpsRelationSchema.php | 4 +- src/Plugins/Schema/Pdf/PdfRelationSchema.php | 4 +- src/Plugins/Schema/Svg/SvgRelationSchema.php | 4 +- src/Query/Compatibility.php | 2 +- src/Replication/ReplicationGui.php | 2 +- src/Server/Privileges.php | 32 +- src/Table/ColumnsDefinition.php | 2 +- src/Table/Search.php | 2 +- src/Table/Table.php | 4 +- src/Triggers/Triggers.php | 9 +- src/TwoFactor.php | 8 +- src/Types.php | 2 +- src/Util.php | 10 +- tests/classes/AbstractTestCase.php | 4 +- tests/classes/TwoFactorTest.php | 6 +- 55 files changed, 169 insertions(+), 437 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 8db91dc54b..f94fe5992b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1115,11 +1115,6 @@ parameters: count: 1 path: src/ConfigStorage/Relation.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/ConfigStorage/Relation.php - - message: "#^Cannot access an offset on mixed\\.$#" count: 1 @@ -1680,11 +1675,6 @@ parameters: count: 1 path: src/Controllers/Database/DataDictionaryController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Controllers/Database/DesignerController.php - - message: "#^Cannot access offset 'dbName' on mixed\\.$#" count: 2 @@ -2060,11 +2050,6 @@ parameters: count: 1 path: src/Controllers/Database/MultiTableQueryController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 - path: src/Controllers/Database/RoutinesController.php - - message: "#^Cannot access an offset on mixed\\.$#" count: 6 @@ -2187,7 +2172,7 @@ parameters: - message: "#^Parameter \\#3 \\$which of static method PhpMyAdmin\\\\Database\\\\Routines\\:\\:getDetails\\(\\) expects string\\|null, mixed given\\.$#" - count: 2 + count: 1 path: src/Controllers/Database/RoutinesController.php - @@ -2705,11 +2690,6 @@ parameters: count: 4 path: src/Controllers/Database/StructureController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 - path: src/Controllers/Database/StructureController.php - - message: "#^Cannot access offset 'Check_time' on mixed\\.$#" count: 1 @@ -3035,11 +3015,6 @@ parameters: count: 1 path: src/Controllers/Database/TrackingController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Controllers/ErrorReportController.php - - message: "#^Cannot access offset 'success' on mixed\\.$#" count: 1 @@ -3065,11 +3040,6 @@ parameters: count: 1 path: src/Controllers/Export/ExportController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Controllers/Export/ExportController.php - - message: "#^Cannot access offset 'aliases' on mixed\\.$#" count: 1 @@ -3440,11 +3410,6 @@ parameters: count: 1 path: src/Controllers/Import/ImportController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Controllers/Import/ImportController.php - - message: "#^Cannot access offset 'error' on mixed\\.$#" count: 1 @@ -3552,7 +3517,7 @@ parameters: - message: "#^Parameter \\#1 \\$path of static method PhpMyAdmin\\\\Core\\:\\:securePath\\(\\) expects string, mixed given\\.$#" - count: 2 + count: 1 path: src/Controllers/Import/ImportController.php - @@ -4580,11 +4545,6 @@ parameters: count: 4 path: src/Controllers/Server/DatabasesController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Controllers/Server/DatabasesController.php - - message: "#^Cannot access offset 'DEFAULT_COLLATION…' on mixed\\.$#" count: 1 @@ -5055,11 +5015,6 @@ parameters: count: 1 path: src/Controllers/Server/Status/VariablesController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Controllers/Server/Status/VariablesController.php - - message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#" count: 1 @@ -5145,11 +5100,6 @@ parameters: count: 1 path: src/Controllers/Server/Variables/SetVariableController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Controllers/Setup/AbstractController.php - - message: "#^Only booleans are allowed in a ternary operator condition, mixed given\\.$#" count: 1 @@ -6585,11 +6535,6 @@ parameters: count: 2 path: src/Controllers/Table/ReplaceController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Controllers/Table/ReplaceController.php - - message: "#^Call to function method_exists\\(\\) with PhpMyAdmin\\\\Plugins\\\\IOTransformationsPlugin and 'isSuccess' will always evaluate to true\\.$#" count: 1 @@ -6865,11 +6810,6 @@ parameters: count: 1 path: src/Controllers/Table/ReplaceController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 3 - path: src/Controllers/Table/SearchController.php - - message: "#^Cannot access offset int on mixed\\.$#" count: 1 @@ -7855,11 +7795,6 @@ parameters: count: 2 path: src/Controllers/Table/ZoomSearchController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 3 - path: src/Controllers/Table/ZoomSearchController.php - - message: "#^Cannot access offset 0 on mixed\\.$#" count: 3 @@ -8040,11 +7975,6 @@ parameters: count: 1 path: src/Controllers/Transformation/WrapperController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Controllers/Triggers/IndexController.php - - message: "#^Cannot call method isSuccess\\(\\) on mixed\\.$#" count: 1 @@ -8215,11 +8145,6 @@ parameters: count: 1 path: src/Controllers/VersionCheckController.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 3 - path: src/Controllers/View/CreateController.php - - message: "#^Cannot access offset 'back' on mixed\\.$#" count: 1 @@ -8322,7 +8247,7 @@ parameters: - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 4 + count: 3 path: src/Core.php - @@ -8395,11 +8320,6 @@ parameters: count: 3 path: src/CreateAddField.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/CreateAddField.php - - message: "#^Cannot access offset 'col_index' on mixed\\.$#" count: 1 @@ -8552,7 +8472,7 @@ parameters: - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 9 + count: 4 path: src/Database/CentralColumns.php - @@ -8835,11 +8755,6 @@ parameters: count: 3 path: src/Database/Designer/Common.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 - path: src/Database/Designer/Common.php - - message: "#^Cannot access offset 'ENGINE' on mixed\\.$#" count: 5 @@ -9000,11 +8915,6 @@ parameters: count: 1 path: src/Database/Events.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 - path: src/Database/Events.php - - message: "#^Cannot access an offset on mixed\\.$#" count: 6 @@ -9090,11 +9000,6 @@ parameters: count: 3 path: src/Database/Routines.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 5 - path: src/Database/Routines.php - - message: "#^Cannot access an offset on mixed\\.$#" count: 9 @@ -9207,7 +9112,7 @@ parameters: - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" - count: 23 + count: 22 path: src/Database/Routines.php - @@ -9355,11 +9260,6 @@ parameters: count: 3 path: src/Database/Routines.php - - - message: "#^Parameter \\#3 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" - count: 1 - path: src/Database/Routines.php - - message: "#^Parameter \\#7 \\$itemType of method PhpMyAdmin\\\\Database\\\\Routines\\:\\:processParamsAndBuild\\(\\) expects string, mixed given\\.$#" count: 1 @@ -9645,11 +9545,6 @@ parameters: count: 6 path: src/Display/Results.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 3 - path: src/Display/Results.php - - message: "#^Cannot access offset 'display_binary' on mixed\\.$#" count: 8 @@ -10095,11 +9990,6 @@ parameters: count: 3 path: src/Error.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 - path: src/Error.php - - message: "#^Cannot access offset 'args' on mixed\\.$#" count: 1 @@ -10267,7 +10157,7 @@ parameters: - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 + count: 1 path: src/Export/Export.php - @@ -10915,11 +10805,6 @@ parameters: count: 1 path: src/Gis/GisVisualization.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Git.php - - message: "#^Cannot access offset 1 on array\\|false\\.$#" count: 2 @@ -11087,7 +10972,7 @@ parameters: - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 + count: 1 path: src/Html/Generator.php - @@ -11700,11 +11585,6 @@ parameters: count: 2 path: src/InsertEdit.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 7 - path: src/InsertEdit.php - - message: "#^Cannot access offset 'relational_display' on mixed\\.$#" count: 1 @@ -12015,11 +11895,6 @@ parameters: count: 1 path: src/IpAllowDeny.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Language.php - - message: "#^Cannot access offset 'a_meta_dir' on mixed\\.$#" count: 1 @@ -12150,11 +12025,6 @@ parameters: count: 1 path: src/Menu.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 5 - path: src/Menu.php - - message: "#^Cannot access offset 'icon' on mixed\\.$#" count: 22 @@ -12250,11 +12120,6 @@ parameters: count: 1 path: src/Navigation/NavigationTree.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 12 - path: src/Navigation/NavigationTree.php - - message: "#^Cannot access offset 'image' on mixed\\.$#" count: 1 @@ -12435,11 +12300,6 @@ parameters: count: 1 path: src/Navigation/Nodes/Node.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 - path: src/Navigation/Nodes/Node.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 5 @@ -12505,11 +12365,6 @@ parameters: count: 1 path: src/Navigation/Nodes/NodeColumn.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Navigation/Nodes/NodeDatabase.php - - message: "#^Method PhpMyAdmin\\\\Navigation\\\\Nodes\\\\NodeDatabase\\:\\:getEventCount\\(\\) should return int but returns int\\|string\\.$#" count: 1 @@ -12557,7 +12412,7 @@ parameters: - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 7 + count: 1 path: src/Normalization.php - @@ -13345,11 +13200,6 @@ parameters: count: 1 path: src/Plugins/Auth/AuthenticationHttp.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Plugins/Auth/AuthenticationSignon.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 2 @@ -13490,11 +13340,6 @@ parameters: count: 3 path: src/Plugins/Export/ExportCsv.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Plugins/Export/ExportHtmlword.php - - message: "#^Cannot access offset 'columns' on mixed\\.$#" count: 3 @@ -13545,11 +13390,6 @@ parameters: count: 1 path: src/Plugins/Export/ExportJson.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Plugins/Export/ExportLatex.php - - message: "#^Cannot access offset 'columns' on mixed\\.$#" count: 2 @@ -14140,11 +13980,6 @@ parameters: count: 1 path: src/Plugins/Export/ExportSql.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Plugins/Export/ExportTexytext.php - - message: "#^Cannot access offset 'columns' on mixed\\.$#" count: 3 @@ -15165,11 +15000,6 @@ parameters: count: 2 path: src/Plugins/Schema/Dia/DiaRelationSchema.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 - path: src/Plugins/Schema/Dia/DiaRelationSchema.php - - message: "#^Cannot access offset 'foreign_field' on mixed\\.$#" count: 1 @@ -15177,7 +15007,7 @@ parameters: - message: "#^Cannot access offset 'foreign_table' on mixed\\.$#" - count: 2 + count: 1 path: src/Plugins/Schema/Dia/DiaRelationSchema.php - @@ -15192,7 +15022,7 @@ parameters: - message: "#^Cannot access offset 'ref_table_name' on mixed\\.$#" - count: 2 + count: 1 path: src/Plugins/Schema/Dia/DiaRelationSchema.php - @@ -15215,11 +15045,6 @@ parameters: count: 1 path: src/Plugins/Schema/Dia/DiaRelationSchema.php - - - message: "#^Parameter \\#3 \\$foreignTable of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Dia\\\\DiaRelationSchema\\:\\:addRelation\\(\\) expects string, mixed given\\.$#" - count: 2 - path: src/Plugins/Schema/Dia/DiaRelationSchema.php - - message: "#^Parameter \\#4 \\$foreignField of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Dia\\\\DiaRelationSchema\\:\\:addRelation\\(\\) expects string, mixed given\\.$#" count: 2 @@ -15250,11 +15075,6 @@ parameters: count: 2 path: src/Plugins/Schema/Eps/EpsRelationSchema.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 - path: src/Plugins/Schema/Eps/EpsRelationSchema.php - - message: "#^Cannot access offset 'foreign_field' on mixed\\.$#" count: 1 @@ -15262,7 +15082,7 @@ parameters: - message: "#^Cannot access offset 'foreign_table' on mixed\\.$#" - count: 2 + count: 1 path: src/Plugins/Schema/Eps/EpsRelationSchema.php - @@ -15277,7 +15097,7 @@ parameters: - message: "#^Cannot access offset 'ref_table_name' on mixed\\.$#" - count: 2 + count: 1 path: src/Plugins/Schema/Eps/EpsRelationSchema.php - @@ -15300,11 +15120,6 @@ parameters: count: 1 path: src/Plugins/Schema/Eps/EpsRelationSchema.php - - - message: "#^Parameter \\#5 \\$foreignTable of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Eps\\\\EpsRelationSchema\\:\\:addRelation\\(\\) expects string, mixed given\\.$#" - count: 2 - path: src/Plugins/Schema/Eps/EpsRelationSchema.php - - message: "#^Parameter \\#6 \\$foreignField of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Eps\\\\EpsRelationSchema\\:\\:addRelation\\(\\) expects string, mixed given\\.$#" count: 2 @@ -15385,11 +15200,6 @@ parameters: count: 2 path: src/Plugins/Schema/Pdf/PdfRelationSchema.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 - path: src/Plugins/Schema/Pdf/PdfRelationSchema.php - - message: "#^Call to method TCPDF\\:\\:Line\\(\\) with incorrect case\\: line$#" count: 2 @@ -15427,7 +15237,7 @@ parameters: - message: "#^Cannot access offset 'foreign_table' on mixed\\.$#" - count: 2 + count: 1 path: src/Plugins/Schema/Pdf/PdfRelationSchema.php - @@ -15442,7 +15252,7 @@ parameters: - message: "#^Cannot access offset 'ref_table_name' on mixed\\.$#" - count: 2 + count: 1 path: src/Plugins/Schema/Pdf/PdfRelationSchema.php - @@ -15535,11 +15345,6 @@ parameters: count: 1 path: src/Plugins/Schema/Pdf/PdfRelationSchema.php - - - message: "#^Parameter \\#3 \\$foreignTable of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Pdf\\\\PdfRelationSchema\\:\\:addRelation\\(\\) expects string, mixed given\\.$#" - count: 2 - path: src/Plugins/Schema/Pdf/PdfRelationSchema.php - - message: "#^Parameter \\#4 \\$foreignField of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Pdf\\\\PdfRelationSchema\\:\\:addRelation\\(\\) expects string, mixed given\\.$#" count: 2 @@ -15615,11 +15420,6 @@ parameters: count: 2 path: src/Plugins/Schema/Svg/SvgRelationSchema.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 - path: src/Plugins/Schema/Svg/SvgRelationSchema.php - - message: "#^Cannot access offset 'foreign_field' on mixed\\.$#" count: 1 @@ -15627,7 +15427,7 @@ parameters: - message: "#^Cannot access offset 'foreign_table' on mixed\\.$#" - count: 2 + count: 1 path: src/Plugins/Schema/Svg/SvgRelationSchema.php - @@ -15642,7 +15442,7 @@ parameters: - message: "#^Cannot access offset 'ref_table_name' on mixed\\.$#" - count: 2 + count: 1 path: src/Plugins/Schema/Svg/SvgRelationSchema.php - @@ -15660,11 +15460,6 @@ parameters: count: 1 path: src/Plugins/Schema/Svg/SvgRelationSchema.php - - - message: "#^Parameter \\#5 \\$foreignTable of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Svg\\\\SvgRelationSchema\\:\\:addRelation\\(\\) expects string, mixed given\\.$#" - count: 2 - path: src/Plugins/Schema/Svg/SvgRelationSchema.php - - message: "#^Parameter \\#6 \\$foreignField of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Svg\\\\SvgRelationSchema\\:\\:addRelation\\(\\) expects string, mixed given\\.$#" count: 2 @@ -15985,11 +15780,6 @@ parameters: count: 1 path: src/Profiling.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Query/Compatibility.php - - message: "#^Cannot access offset 'AUTO_INCREMENT' on mixed\\.$#" count: 1 @@ -16425,11 +16215,6 @@ parameters: count: 1 path: src/Replication/Replication.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Replication/ReplicationGui.php - - message: "#^Cannot access offset 'Slave_IO_Running' on mixed\\.$#" count: 1 @@ -16720,11 +16505,6 @@ parameters: count: 1 path: src/Server/Privileges.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 17 - path: src/Server/Privileges.php - - message: "#^Cannot access offset 'CHARACTER_MAXIMUM…' on mixed\\.$#" count: 2 @@ -17895,11 +17675,6 @@ parameters: count: 4 path: src/SystemDatabase.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Table/ColumnsDefinition.php - - message: "#^Cannot access offset 'isEditable' on mixed\\.$#" count: 2 @@ -18050,11 +17825,6 @@ parameters: count: 2 path: src/Table/Search.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Table/Search.php - - message: "#^Cannot access offset mixed on mixed\\.$#" count: 4 @@ -18142,7 +17912,7 @@ parameters: - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 5 + count: 3 path: src/Table/Table.php - @@ -18740,11 +18510,6 @@ parameters: count: 1 path: src/Triggers/Triggers.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 3 - path: src/Triggers/Triggers.php - - message: "#^Cannot access an offset on mixed\\.$#" count: 6 @@ -18787,7 +18552,7 @@ parameters: - message: "#^Parameter \\#1 \\$identifier of static method PhpMyAdmin\\\\Util\\:\\:backquote\\(\\) expects string\\|Stringable\\|null, mixed given\\.$#" - count: 4 + count: 3 path: src/Triggers/Triggers.php - @@ -18815,21 +18580,6 @@ parameters: count: 1 path: src/Triggers/Triggers.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 - path: src/TwoFactor.php - - - - message: "#^Parameter \\#1 \\$name of method PhpMyAdmin\\\\TwoFactor\\:\\:getBackendClass\\(\\) expects string, mixed given\\.$#" - count: 1 - path: src/TwoFactor.php - - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 1 - path: src/Types.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 4 @@ -18965,11 +18715,6 @@ parameters: count: 1 path: src/Util.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 5 - path: src/Util.php - - message: "#^Cannot access offset 'Cardinality' on mixed\\.$#" count: 1 @@ -19330,11 +19075,6 @@ parameters: count: 1 path: src/ZipExtension.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 2 - path: tests/classes/AbstractTestCase.php - - message: "#^Call to method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 'formula' and array\\{id\\: non\\-empty\\-string, name\\: string, precondition\\?\\: non\\-empty\\-string, formula\\: non\\-empty\\-string, test\\: non\\-empty\\-string, issue\\: string, recommendation\\: string, justification\\: string, \\.\\.\\.\\} will always evaluate to true\\.$#" count: 1 @@ -21070,11 +20810,6 @@ parameters: count: 1 path: tests/classes/Triggers/TriggersTest.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 3 - path: tests/classes/TwoFactorTest.php - - message: "#^Method PhpMyAdmin\\\\Tests\\\\TwoFactorTest\\:\\:loadResultForConfig\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 31fd975898..33fdcd7eae 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1243,7 +1243,6 @@ - $type @@ -2079,7 +2078,6 @@ - @@ -2154,7 +2152,6 @@ - @@ -3828,7 +3825,6 @@ - $afterInsert $clauseIsUnique @@ -4418,11 +4414,8 @@ - - - __construct @@ -4540,7 +4533,6 @@ - @@ -5034,7 +5026,6 @@ - $createItem @@ -5247,7 +5238,6 @@ $itemDefinition - $itemSqlDataAccess $createRoutine @@ -7478,9 +7468,6 @@ int int - - $item - @@ -12346,15 +12333,12 @@ - - - getCreateSql @@ -12368,12 +12352,6 @@ Config::getInstance() DatabaseInterface::getInstance() - - $name - - - $name - new $cls($this) new $cls($this) diff --git a/src/ConfigStorage/Relation.php b/src/ConfigStorage/Relation.php index 43946f141b..74caa40f9b 100644 --- a/src/ConfigStorage/Relation.php +++ b/src/ConfigStorage/Relation.php @@ -1519,7 +1519,7 @@ class Relation // Check if the table already exists // use the possible replaced name first and fallback on the table name // if no replacement exists - if (! in_array($tableNameReplacements[$table] ?? $table, $existingTables)) { + if (! in_array($tableNameReplacements[$table] ?? $table, $existingTables, true)) { if (! $create) { continue; } diff --git a/src/Controllers/Database/DesignerController.php b/src/Controllers/Database/DesignerController.php index fb9b86a473..da1a2cfe87 100644 --- a/src/Controllers/Database/DesignerController.php +++ b/src/Controllers/Database/DesignerController.php @@ -197,7 +197,7 @@ class DesignerController extends AbstractController } foreach ($tablePositions as $position) { - if (in_array($position['dbName'] . '.' . $position['tableName'], $fullTableNames)) { + if (in_array($position['dbName'] . '.' . $position['tableName'], $fullTableNames, true)) { continue; } diff --git a/src/Controllers/Database/RoutinesController.php b/src/Controllers/Database/RoutinesController.php index 53bf6b3d59..80048b1fcb 100644 --- a/src/Controllers/Database/RoutinesController.php +++ b/src/Controllers/Database/RoutinesController.php @@ -64,7 +64,10 @@ class RoutinesController extends AbstractController /** * Displays the header and tabs */ - if (! empty($GLOBALS['table']) && in_array($GLOBALS['table'], $this->dbi->getTables($GLOBALS['db']))) { + if ( + ! empty($GLOBALS['table']) + && in_array($GLOBALS['table'], $this->dbi->getTables($GLOBALS['db']), true) + ) { if (! $this->checkParameters(['db', 'table'])) { return; } @@ -452,7 +455,7 @@ class RoutinesController extends AbstractController } } - if (! isset($type) || ! in_array($type, ['FUNCTION', 'PROCEDURE'])) { + if (! isset($type) || ! in_array($type, ['FUNCTION', 'PROCEDURE'], true)) { $type = null; } diff --git a/src/Controllers/Database/StructureController.php b/src/Controllers/Database/StructureController.php index 760b7c8b23..ba86d39716 100644 --- a/src/Controllers/Database/StructureController.php +++ b/src/Controllers/Database/StructureController.php @@ -557,7 +557,7 @@ class StructureController extends AbstractController if (isset($currentTable['TABLE_ROWS']) && ($currentTable['ENGINE'] != null || $tableIsView)) { // InnoDB/TokuDB table: we did not get an accurate row count $approxRows = ! $tableIsView - && in_array($currentTable['ENGINE'], ['InnoDB', 'TokuDB']) + && in_array($currentTable['ENGINE'], ['InnoDB', 'TokuDB'], true) && ! $currentTable['COUNTED']; if ($tableIsView && $currentTable['TABLE_ROWS'] >= Config::getInstance()->settings['MaxExactCountViews']) { @@ -828,7 +828,7 @@ class StructureController extends AbstractController $formattedSize = $unit = ''; if ( - (in_array($currentTable['ENGINE'], ['InnoDB', 'TokuDB']) + (in_array($currentTable['ENGINE'], ['InnoDB', 'TokuDB'], true) && $currentTable['TABLE_ROWS'] < Config::getInstance()->settings['MaxExactCount']) || ! isset($currentTable['TABLE_ROWS']) ) { diff --git a/src/Controllers/ErrorReportController.php b/src/Controllers/ErrorReportController.php index ed8a890aa5..a145279419 100644 --- a/src/Controllers/ErrorReportController.php +++ b/src/Controllers/ErrorReportController.php @@ -48,7 +48,7 @@ class ErrorReportController extends AbstractController /** @var string|null $alwaysSend */ $alwaysSend = $request->getParsedBodyParam('always_send'); - if (! in_array($exceptionType, ['js', 'php'])) { + if (! in_array($exceptionType, ['js', 'php'], true)) { return; } diff --git a/src/Controllers/Export/ExportController.php b/src/Controllers/Export/ExportController.php index 2fed20d29f..2d6f9562e9 100644 --- a/src/Controllers/Export/ExportController.php +++ b/src/Controllers/Export/ExportController.php @@ -153,7 +153,7 @@ final class ExportController extends AbstractController $separateFiles = $asSeparateFiles; } - if (in_array($compressionParam, $compressionMethods)) { + if (in_array($compressionParam, $compressionMethods, true)) { $GLOBALS['compression'] = $compressionParam; $GLOBALS['buffer_needed'] = true; } diff --git a/src/Controllers/Import/ImportController.php b/src/Controllers/Import/ImportController.php index 80cc1b5879..bedff96729 100644 --- a/src/Controllers/Import/ImportController.php +++ b/src/Controllers/Import/ImportController.php @@ -229,7 +229,7 @@ final class ImportController extends AbstractController * We only need to load the selected plugin */ - if (! in_array($GLOBALS['format'], ['csv', 'ldi', 'mediawiki', 'ods', 'shp', 'sql', 'xml'])) { + if (! in_array($GLOBALS['format'], ['csv', 'ldi', 'mediawiki', 'ods', 'shp', 'sql', 'xml'], true)) { // this should not happen for a normal user // but only during an attack $this->response->setRequestStatus(false); diff --git a/src/Controllers/Server/DatabasesController.php b/src/Controllers/Server/DatabasesController.php index b27dfb0ce7..2401c35dba 100644 --- a/src/Controllers/Server/DatabasesController.php +++ b/src/Controllers/Server/DatabasesController.php @@ -182,7 +182,7 @@ class DatabasesController extends AbstractController 'SCHEMA_DATA_FREE', ]; $this->sortBy = 'SCHEMA_NAME'; - if (in_array($sortBy, $sortByAllowList)) { + if (in_array($sortBy, $sortByAllowList, true)) { $this->sortBy = $sortBy; } } diff --git a/src/Controllers/Server/Status/VariablesController.php b/src/Controllers/Server/Status/VariablesController.php index 28b177f36d..9b6530ebe3 100644 --- a/src/Controllers/Server/Status/VariablesController.php +++ b/src/Controllers/Server/Status/VariablesController.php @@ -136,9 +136,7 @@ class VariablesController extends AbstractController */ private function flush(string $flush): void { - $flushCommands = ['STATUS', 'TABLES', 'QUERY CACHE']; - - if (! in_array($flush, $flushCommands)) { + if (! in_array($flush, ['STATUS', 'TABLES', 'QUERY CACHE'], true)) { return; } diff --git a/src/Controllers/Setup/AbstractController.php b/src/Controllers/Setup/AbstractController.php index a2042405bb..26b4ede37b 100644 --- a/src/Controllers/Setup/AbstractController.php +++ b/src/Controllers/Setup/AbstractController.php @@ -23,7 +23,7 @@ abstract class AbstractController $ignored = ['Config', 'Servers']; $pages = []; foreach (SetupFormList::getAllFormNames() as $formset) { - if (in_array($formset, $ignored)) { + if (in_array($formset, $ignored, true)) { continue; } diff --git a/src/Controllers/Table/ReplaceController.php b/src/Controllers/Table/ReplaceController.php index 88c5562a29..ad31fcac0b 100644 --- a/src/Controllers/Table/ReplaceController.php +++ b/src/Controllers/Table/ReplaceController.php @@ -76,9 +76,8 @@ final class ReplaceController extends AbstractController $this->addScriptFiles(['makegrid.js', 'sql.js', 'gis_data_editor.js']); - $afterInsertActions = ['new_insert', 'same_insert', 'edit_next']; $afterInsert = $request->getParsedBodyParam('after_insert'); - if ($afterInsert !== null && in_array($afterInsert, $afterInsertActions)) { + if (in_array($afterInsert, ['new_insert', 'same_insert', 'edit_next'], true)) { $GLOBALS['urlParams']['after_insert'] = $afterInsert; $whereClause = $request->getParsedBodyParam('where_clause'); if ($whereClause !== null) { diff --git a/src/Controllers/Table/SearchController.php b/src/Controllers/Table/SearchController.php index 54e881e1e7..82b0a72955 100644 --- a/src/Controllers/Table/SearchController.php +++ b/src/Controllers/Table/SearchController.php @@ -120,7 +120,7 @@ class SearchController extends AbstractController // before any replacement $this->originalColumnTypes[] = mb_strtolower($type); // check whether table contains geometric columns - if (in_array($type, $geomTypes)) { + if (in_array($type, $geomTypes, true)) { $this->geomColumnFlag = true; } @@ -378,8 +378,8 @@ class SearchController extends AbstractController '', ); $htmlAttributes = ''; - $isInteger = in_array($cleanType, $this->dbi->types->getIntegerTypes()); - $isFloat = in_array($cleanType, $this->dbi->types->getFloatTypes()); + $isInteger = in_array($cleanType, $this->dbi->types->getIntegerTypes(), true); + $isFloat = in_array($cleanType, $this->dbi->types->getFloatTypes(), true); if ($isInteger) { $extractedColumnspec = Util::extractColumnSpec($this->originalColumnTypes[$columnIndex]); $isUnsigned = $extractedColumnspec['unsigned']; diff --git a/src/Controllers/Table/ZoomSearchController.php b/src/Controllers/Table/ZoomSearchController.php index fa03f9638d..02d6d08348 100644 --- a/src/Controllers/Table/ZoomSearchController.php +++ b/src/Controllers/Table/ZoomSearchController.php @@ -206,7 +206,7 @@ class ZoomSearchController extends AbstractController // before any replacement $this->originalColumnTypes[] = mb_strtolower($type); // check whether table contains geometric columns - if (in_array($type, $geomTypes)) { + if (in_array($type, $geomTypes, true)) { $this->geomColumnFlag = true; } @@ -465,8 +465,8 @@ class ZoomSearchController extends AbstractController '', ); $htmlAttributes = ''; - $isInteger = in_array($cleanType, $this->dbi->types->getIntegerTypes()); - $isFloat = in_array($cleanType, $this->dbi->types->getFloatTypes()); + $isInteger = in_array($cleanType, $this->dbi->types->getIntegerTypes(), true); + $isFloat = in_array($cleanType, $this->dbi->types->getFloatTypes(), true); if ($isInteger) { $extractedColumnspec = Util::extractColumnSpec($this->originalColumnTypes[$columnIndex]); $isUnsigned = $extractedColumnspec['unsigned']; diff --git a/src/Controllers/Triggers/IndexController.php b/src/Controllers/Triggers/IndexController.php index 80385bb7e4..004467e4a0 100644 --- a/src/Controllers/Triggers/IndexController.php +++ b/src/Controllers/Triggers/IndexController.php @@ -57,7 +57,10 @@ final class IndexController extends AbstractController /** * Displays the header and tabs */ - if (! empty($GLOBALS['table']) && in_array($GLOBALS['table'], $this->dbi->getTables($GLOBALS['db']))) { + if ( + ! empty($GLOBALS['table']) + && in_array($GLOBALS['table'], $this->dbi->getTables($GLOBALS['db']), true) + ) { if (! $this->checkParameters(['db', 'table'])) { return; } diff --git a/src/Controllers/View/CreateController.php b/src/Controllers/View/CreateController.php index a7e419b9dc..b424e0a30a 100644 --- a/src/Controllers/View/CreateController.php +++ b/src/Controllers/View/CreateController.php @@ -265,7 +265,7 @@ class CreateController extends AbstractController if ( isset($view['algorithm']) - && in_array($view['algorithm'], self::VIEW_ALGORITHM_OPTIONS) + && in_array($view['algorithm'], self::VIEW_ALGORITHM_OPTIONS, true) ) { $sqlQuery .= $separator . ' ALGORITHM = ' . $view['algorithm']; } @@ -283,7 +283,7 @@ class CreateController extends AbstractController if ( isset($view['sql_security']) - && in_array($view['sql_security'], self::VIEW_SECURITY_OPTIONS) + && in_array($view['sql_security'], self::VIEW_SECURITY_OPTIONS, true) ) { $sqlQuery .= $separator . ' SQL SECURITY ' . $view['sql_security']; @@ -298,7 +298,7 @@ class CreateController extends AbstractController $sqlQuery .= $separator . ' AS ' . $view['as']; - if (isset($view['with']) && in_array($view['with'], self::VIEW_WITH_OPTIONS)) { + if (isset($view['with']) && in_array($view['with'], self::VIEW_WITH_OPTIONS, true)) { $sqlQuery .= $separator . ' WITH ' . $view['with'] . ' CHECK OPTION'; } diff --git a/src/Core.php b/src/Core.php index 00320fd9fe..4f08043ae0 100644 --- a/src/Core.php +++ b/src/Core.php @@ -85,7 +85,7 @@ class Core $phpDocLanguages = ['pt_BR', 'zh_CN', 'fr', 'de', 'ja', 'ru', 'es', 'tr']; $lang = 'en'; - if (isset($GLOBALS['lang']) && in_array($GLOBALS['lang'], $phpDocLanguages)) { + if (isset($GLOBALS['lang']) && in_array($GLOBALS['lang'], $phpDocLanguages, true)) { $lang = $GLOBALS['lang'] === 'zh_CN' ? 'zh' : $GLOBALS['lang']; } diff --git a/src/CreateAddField.php b/src/CreateAddField.php index ba355c658a..c3bef39fa5 100644 --- a/src/CreateAddField.php +++ b/src/CreateAddField.php @@ -173,7 +173,7 @@ class CreateAddField if ( $index['Index_choice'] !== 'SPATIAL' && $index['Index_choice'] !== 'FULLTEXT' - && in_array($index['Index_type'], Index::getIndexTypes()) + && in_array($index['Index_type'], Index::getIndexTypes(), true) ) { $sqlQuery .= ' USING ' . $index['Index_type']; } diff --git a/src/Database/CentralColumns.php b/src/Database/CentralColumns.php index 03c039a453..6b0a7b9b33 100644 --- a/src/Database/CentralColumns.php +++ b/src/Database/CentralColumns.php @@ -752,19 +752,19 @@ class CentralColumns foreach ($columnsList as &$row) { $vals = explode(',', $row['col_extra']); - if (in_array('BINARY', $vals)) { + if (in_array('BINARY', $vals, true)) { $row['col_attribute'] = 'BINARY'; - } elseif (in_array('UNSIGNED', $vals)) { + } elseif (in_array('UNSIGNED', $vals, true)) { $row['col_attribute'] = 'UNSIGNED'; - } elseif (in_array('UNSIGNED ZEROFILL', $vals)) { + } elseif (in_array('UNSIGNED ZEROFILL', $vals, true)) { $row['col_attribute'] = 'UNSIGNED ZEROFILL'; - } elseif (in_array('on update CURRENT_TIMESTAMP', $vals)) { + } elseif (in_array('on update CURRENT_TIMESTAMP', $vals, true)) { $row['col_attribute'] = 'on update CURRENT_TIMESTAMP'; } else { $row['col_attribute'] = ''; } - $row['col_extra'] = in_array('auto_increment', $vals) ? 'auto_increment' : ''; + $row['col_extra'] = in_array('auto_increment', $vals, true) ? 'auto_increment' : ''; } } diff --git a/src/Database/Designer/Common.php b/src/Database/Designer/Common.php index e22eb6b619..0e30d4857c 100644 --- a/src/Database/Designer/Common.php +++ b/src/Database/Designer/Common.php @@ -169,7 +169,7 @@ class Common $dtnI = $con['DTN'][$i]; $retval[$ti] = []; $retval[$ti][$cNameI] = []; - if (in_array($dtnI, $tableDbNames) && in_array($con['STN'][$i], $tableDbNames)) { + 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]]; } diff --git a/src/Database/Events.php b/src/Database/Events.php index 616ab54b65..300aa6426f 100644 --- a/src/Database/Events.php +++ b/src/Database/Events.php @@ -269,12 +269,12 @@ class Events } $query .= 'ON SCHEDULE '; - if (! empty($_POST['item_type']) && in_array($_POST['item_type'], $this->type)) { + if (! empty($_POST['item_type']) && in_array($_POST['item_type'], $this->type, true)) { if ($_POST['item_type'] === 'RECURRING') { if ( ! empty($_POST['item_interval_value']) && ! empty($_POST['item_interval_field']) - && in_array($_POST['item_interval_field'], $this->interval) + && in_array($_POST['item_interval_field'], $this->interval, true) ) { $query .= 'EVERY ' . intval($_POST['item_interval_value']) . ' '; $query .= $_POST['item_interval_field'] . ' '; diff --git a/src/Database/Routines.php b/src/Database/Routines.php index 3b73129379..5f9b9371ec 100644 --- a/src/Database/Routines.php +++ b/src/Database/Routines.php @@ -603,7 +603,7 @@ class Routines if ( $itemType === 'PROCEDURE' && ! empty($itemParamDir[$i]) - && in_array($itemParamDir[$i], $this->directions) + && in_array($itemParamDir[$i], $this->directions, true) ) { $params .= $itemParamDir[$i] . ' ' . Util::backquote($itemParamName[$i]) @@ -642,7 +642,7 @@ class Routines if (! empty($itemParamOpsText[$i])) { if ($this->dbi->types->getTypeClass($itemParamType[$i]) === 'CHAR') { - if (! in_array($itemParamType[$i], ['VARBINARY', 'BINARY'])) { + if (! in_array($itemParamType[$i], ['VARBINARY', 'BINARY'], true)) { $params .= ' CHARSET ' . mb_strtolower($itemParamOpsText[$i]); } @@ -820,7 +820,7 @@ class Routines } $itemSqlDataAccess = $_POST['item_sqldataaccess'] ?? ''; - if (! empty($itemSqlDataAccess) && in_array($itemSqlDataAccess, $this->sqlDataAccess)) { + if (in_array($itemSqlDataAccess, $this->sqlDataAccess, true)) { $query .= $itemSqlDataAccess . ' '; } @@ -861,7 +861,7 @@ class Routines if ( ! empty($_POST['funcs'][$routine['item_param_name'][$i]]) - && in_array($_POST['funcs'][$routine['item_param_name'][$i]], $allFunctions) + && in_array($_POST['funcs'][$routine['item_param_name'][$i]], $allFunctions, true) ) { $queries[] = sprintf( 'SET @p%d=%s(%s);', @@ -1078,7 +1078,7 @@ class Routines $params[$i]['class'] = 'datefield'; } - if (in_array($routine['item_param_type'][$i], ['ENUM', 'SET'])) { + if (in_array($routine['item_param_type'][$i], ['ENUM', 'SET'], true)) { if ($routine['item_param_type'][$i] === 'ENUM') { $params[$i]['input_type'] = 'radio'; } else { diff --git a/src/Display/Results.php b/src/Display/Results.php index 9f917cfa80..6dc440dd84 100644 --- a/src/Display/Results.php +++ b/src/Display/Results.php @@ -3058,6 +3058,7 @@ class Results isset($_REQUEST['pftext']) && in_array( $_REQUEST['pftext'], [self::DISPLAY_PARTIAL_TEXT, self::DISPLAY_FULL_TEXT], + true, ) ) { $query['pftext'] = $_REQUEST['pftext']; @@ -3072,6 +3073,7 @@ class Results isset($_REQUEST['relational_display']) && in_array( $_REQUEST['relational_display'], [self::RELATIONAL_KEY, self::RELATIONAL_DISPLAY_COLUMN], + true, ) ) { $query['relational_display'] = $_REQUEST['relational_display']; @@ -3087,6 +3089,7 @@ class Results isset($_REQUEST['geoOption']) && in_array( $_REQUEST['geoOption'], [self::GEOMETRY_DISP_WKT, self::GEOMETRY_DISP_WKB, self::GEOMETRY_DISP_GEOM], + true, ) ) { $query['geoOption'] = $_REQUEST['geoOption']; diff --git a/src/Error.php b/src/Error.php index 9ae4fe52f1..4ccf5e7957 100644 --- a/src/Error.php +++ b/src/Error.php @@ -408,9 +408,9 @@ class Error extends Message '_realConnect', ]; - if (in_array($function, $includeFunctions)) { + if (in_array($function, $includeFunctions, true)) { $retval .= self::relPath($arg); - } elseif (in_array($function, $connectFunctions) && is_string($arg)) { + } elseif (in_array($function, $connectFunctions, true) && is_string($arg)) { $retval .= gettype($arg) . ' ********'; } elseif (is_scalar($arg)) { $retval .= gettype($arg) . ' ' diff --git a/src/Export/Export.php b/src/Export/Export.php index 6e45fb6956..e53d01bf7f 100644 --- a/src/Export/Export.php +++ b/src/Export/Export.php @@ -98,7 +98,7 @@ class Export /** @var string[] $handlers */ $handlers = ob_list_handlers(); - return in_array('ob_gzhandler', $handlers); + return in_array('ob_gzhandler', $handlers, true); } /** diff --git a/src/Git.php b/src/Git.php index 092bdc1421..25416874cb 100644 --- a/src/Git.php +++ b/src/Git.php @@ -367,7 +367,7 @@ class Git $dataline = array_shift($commit); $datalinearr = explode(' ', $dataline, 2); $linetype = $datalinearr[0]; - if (! in_array($linetype, ['author', 'committer'])) { + if (! in_array($linetype, ['author', 'committer'], true)) { continue; } @@ -380,7 +380,7 @@ class Git if ($linetype === 'author') { $author = $user2; - } elseif ($linetype === 'committer') { + } else { $committer = $user2; } } while ($dataline != ''); diff --git a/src/Html/Generator.php b/src/Html/Generator.php index fe163fc92c..20306c40be 100644 --- a/src/Html/Generator.php +++ b/src/Html/Generator.php @@ -908,7 +908,7 @@ class Generator // set all other attributes $attributeString = ''; foreach ($attributes as $key => $value) { - if (in_array($key, ['alt', 'title'])) { + if (in_array($key, ['alt', 'title'], true)) { continue; } diff --git a/src/InsertEdit.php b/src/InsertEdit.php index 7c749af7c5..c84703ba67 100644 --- a/src/InsertEdit.php +++ b/src/InsertEdit.php @@ -451,7 +451,7 @@ class InsertEdit } $inputMinMax = ''; - $isInteger = in_array($column->trueType, $this->dbi->types->getIntegerTypes()); + $isInteger = in_array($column->trueType, $this->dbi->types->getIntegerTypes(), true); if ($isInteger) { $extractedColumnspec = Util::extractColumnSpec($column->type); $isUnsigned = $extractedColumnspec['unsigned']; @@ -877,7 +877,7 @@ class InsertEdit public function getGotoInclude(string|false $gotoInclude): string { $validOptions = ['new_insert', 'same_insert', 'edit_next']; - if (isset($_POST['after_insert']) && in_array($_POST['after_insert'], $validOptions)) { + if (isset($_POST['after_insert']) && in_array($_POST['after_insert'], $validOptions, true)) { return '/table/change'; } @@ -1168,8 +1168,8 @@ class InsertEdit } if ( - in_array($editField->function, $this->getGisFromTextFunctions()) - || in_array($editField->function, $this->getGisFromWKBFunctions()) + in_array($editField->function, $this->getGisFromTextFunctions(), true) + || in_array($editField->function, $this->getGisFromWKBFunctions(), true) ) { preg_match('/^(\'?)(.*?)\1(?:,(\d+))?$/', $editField->value, $matches); $escapedParams = $this->dbi->quoteString($matches[2]) . (isset($matches[3]) ? ',' . $matches[3] : ''); @@ -1178,8 +1178,8 @@ class InsertEdit } if ( - ! in_array($editField->function, self::FUNC_NO_PARAM) - || ($editField->value !== '' && in_array($editField->function, self::FUNC_OPTIONAL_PARAM)) + ! in_array($editField->function, self::FUNC_NO_PARAM, true) + || ($editField->value !== '' && in_array($editField->function, self::FUNC_OPTIONAL_PARAM, true)) ) { if ( ($editField->salt !== null @@ -1956,7 +1956,7 @@ class InsertEdit } $virtual = ['VIRTUAL', 'PERSISTENT', 'VIRTUAL GENERATED', 'STORED GENERATED']; - if (in_array($tableColumn->extra, $virtual)) { + if (in_array($tableColumn->extra, $virtual, true)) { continue; } diff --git a/src/Language.php b/src/Language.php index e82cb774ab..2906146dd1 100644 --- a/src/Language.php +++ b/src/Language.php @@ -144,7 +144,7 @@ class Language */ public function isRTL(): bool { - return in_array($this->code, ['ar', 'fa', 'he', 'ur']); + return in_array($this->code, ['ar', 'fa', 'he', 'ur'], true); } /** diff --git a/src/Menu.php b/src/Menu.php index fc8e20e534..056f31379a 100644 --- a/src/Menu.php +++ b/src/Menu.php @@ -224,7 +224,7 @@ class Menu $tabs['structure']['icon'] = 'b_props'; $tabs['structure']['route'] = '/table/structure'; $tabs['structure']['text'] = __('Structure'); - $tabs['structure']['active'] = in_array($route, ['/table/relation', '/table/structure']); + $tabs['structure']['active'] = in_array($route, ['/table/relation', '/table/structure'], true); $tabs['sql']['icon'] = 'b_sql'; $tabs['sql']['route'] = '/table/sql'; @@ -234,7 +234,11 @@ class Menu $tabs['search']['icon'] = 'b_search'; $tabs['search']['text'] = __('Search'); $tabs['search']['route'] = '/table/search'; - $tabs['search']['active'] = in_array($route, ['/table/find-replace', '/table/search', '/table/zoom-search']); + $tabs['search']['active'] = in_array($route, [ + '/table/find-replace', + '/table/search', + '/table/zoom-search', + ], true); if (! $isSystemSchema && (! $tableIsView || $updatableView)) { $tabs['insert']['icon'] = 'b_insrow'; @@ -459,13 +463,13 @@ class Menu '/server/status/processes', '/server/status/queries', '/server/status/variables', - ]); + ], true); if ($isSuperUser || $isCreateOrGrantUser) { $tabs['rights']['icon'] = 's_rights'; $tabs['rights']['route'] = '/server/privileges'; $tabs['rights']['text'] = __('User accounts'); - $tabs['rights']['active'] = in_array($route, ['/server/privileges', '/server/user-groups']); + $tabs['rights']['active'] = in_array($route, ['/server/privileges', '/server/user-groups'], true); } $tabs['export']['icon'] = 'b_export'; @@ -490,7 +494,7 @@ class Menu '/preferences/navigation', '/preferences/sql', '/preferences/two-factor', - ]); + ], true); if (! empty($binaryLogs)) { $tabs['binlog']['icon'] = 's_tbl'; diff --git a/src/Navigation/NavigationTree.php b/src/Navigation/NavigationTree.php index 49db35b76c..b98c382af7 100644 --- a/src/Navigation/NavigationTree.php +++ b/src/Navigation/NavigationTree.php @@ -552,45 +552,45 @@ class NavigationTree // Get items to hide $hidden = $db->getHiddenItems($this->relationParameters, 'group'); $config = Config::getInstance(); - if (! $config->settings['NavigationTreeShowTables'] && ! in_array('tables', $hidden)) { + if (! $config->settings['NavigationTreeShowTables'] && ! in_array('tables', $hidden, true)) { $hidden[] = 'tables'; } - if (! $config->settings['NavigationTreeShowViews'] && ! in_array('views', $hidden)) { + if (! $config->settings['NavigationTreeShowViews'] && ! in_array('views', $hidden, true)) { $hidden[] = 'views'; } - if (! $config->settings['NavigationTreeShowFunctions'] && ! in_array('functions', $hidden)) { + if (! $config->settings['NavigationTreeShowFunctions'] && ! in_array('functions', $hidden, true)) { $hidden[] = 'functions'; } - if (! $config->settings['NavigationTreeShowProcedures'] && ! in_array('procedures', $hidden)) { + if (! $config->settings['NavigationTreeShowProcedures'] && ! in_array('procedures', $hidden, true)) { $hidden[] = 'procedures'; } - if (! $config->settings['NavigationTreeShowEvents'] && ! in_array('events', $hidden)) { + if (! $config->settings['NavigationTreeShowEvents'] && ! in_array('events', $hidden, true)) { $hidden[] = 'events'; } $retval = []; if (! $db->hasChildren()) { - if (! in_array('tables', $hidden) && $db->getPresence('tables')) { + if (! in_array('tables', $hidden, true) && $db->getPresence('tables')) { $retval['tables'] = new NodeTableContainer(); } - if (! in_array('views', $hidden) && $db->getPresence('views')) { + if (! in_array('views', $hidden, true) && $db->getPresence('views')) { $retval['views'] = new NodeViewContainer(); } - if (! in_array('functions', $hidden) && $db->getPresence('functions')) { + if (! in_array('functions', $hidden, true) && $db->getPresence('functions')) { $retval['functions'] = new NodeFunctionContainer(); } - if (! in_array('procedures', $hidden) && $db->getPresence('procedures')) { + if (! in_array('procedures', $hidden, true) && $db->getPresence('procedures')) { $retval['procedures'] = new NodeProcedureContainer(); } - if (! in_array('events', $hidden) && $db->getPresence('events')) { + if (! in_array('events', $hidden, true) && $db->getPresence('events')) { $retval['events'] = new NodeEventContainer(); } @@ -1031,8 +1031,8 @@ class NavigationTree // if node name itself is in sterile, then allow $nodeIsGroup = $node->isGroup - || (! in_array($parentName, $sterile) && ! $node->isNew) - || (in_array($node->realName, $sterile) && $node->children !== []); + || (! in_array($parentName, $sterile, true) && ! $node->isNew) + || (in_array($node->realName, $sterile, true) && $node->children !== []); if ($nodeIsGroup) { $match = $this->findTreeMatch($this->vPath, $paths['vPath_clean']); $linkClasses = $node->getCssClasses($match); diff --git a/src/Navigation/Nodes/Node.php b/src/Navigation/Nodes/Node.php index 87e3cff3e4..b42bed8760 100644 --- a/src/Navigation/Nodes/Node.php +++ b/src/Navigation/Nodes/Node.php @@ -786,7 +786,7 @@ class Node continue; } - if (in_array($arr[0], $retval)) { + if (in_array($arr[0], $retval, true)) { continue; } @@ -844,7 +844,7 @@ class Node continue; } - if (in_array($arr[0], $retval)) { + if (in_array($arr[0], $retval, true)) { continue; } diff --git a/src/Navigation/Nodes/NodeDatabase.php b/src/Navigation/Nodes/NodeDatabase.php index aff0415a29..e967f0e7ff 100644 --- a/src/Navigation/Nodes/NodeDatabase.php +++ b/src/Navigation/Nodes/NodeDatabase.php @@ -276,7 +276,7 @@ class NodeDatabase extends Node if ($relationParameters->navigationItemsHidingFeature !== null) { $hiddenItems = $this->getHiddenItems($relationParameters, substr($type, 0, -1)); foreach ($retval as $key => $item) { - if (! in_array($item, $hiddenItems)) { + if (! in_array($item, $hiddenItems, true)) { continue; } diff --git a/src/Normalization.php b/src/Normalization.php index cf43893358..80e62494ef 100644 --- a/src/Normalization.php +++ b/src/Normalization.php @@ -74,7 +74,11 @@ class Normalization $column = $def->field; $extractedColumnSpec = Util::extractColumnSpec($def->type); - if ($columnTypeList !== [] && ! in_array(mb_strtoupper($extractedColumnSpec['type']), $columnTypeList)) { + if ( + $columnTypeList !== [] && ! in_array(mb_strtoupper( + $extractedColumnSpec['type'], + ), $columnTypeList, true) + ) { continue; } @@ -411,7 +415,7 @@ class Normalization ); $cnt = 0; foreach ($columns as $column) { - if (in_array($column, $pk)) { + if (in_array($column, $pk, true)) { continue; } @@ -691,7 +695,7 @@ class Normalization ); $query = 'ALTER TABLE ' . Util::backquote($originalTable); foreach ($columns as $col) { - if (in_array($col, $colPresent)) { + if (in_array($col, $colPresent, true)) { continue; } @@ -836,7 +840,7 @@ class Normalization } foreach ($columns as $column) { - if (in_array($column, $pk)) { + if (in_array($column, $pk, true)) { continue; } @@ -846,7 +850,7 @@ class Normalization } foreach ($columns as $column) { - if (in_array($column, $pk)) { + if (in_array($column, $pk, true)) { continue; } @@ -913,7 +917,7 @@ class Normalization $table, ); foreach ($columns as $column) { - if (in_array($column, $pk)) { + if (in_array($column, $pk, true)) { continue; } diff --git a/src/Plugins/Auth/AuthenticationSignon.php b/src/Plugins/Auth/AuthenticationSignon.php index bd9b7f467b..2def1e4df1 100644 --- a/src/Plugins/Auth/AuthenticationSignon.php +++ b/src/Plugins/Auth/AuthenticationSignon.php @@ -78,7 +78,7 @@ class AuthenticationSignon extends AuthenticationPlugin if ( isset($sessionCookieParams['samesite']) - && ! in_array($sessionCookieParams['samesite'], ['Lax', 'Strict']) + && ! in_array($sessionCookieParams['samesite'], ['Lax', 'Strict'], true) ) { // Not a valid value for samesite unset($sessionCookieParams['samesite']); diff --git a/src/Plugins/Export/ExportHtmlword.php b/src/Plugins/Export/ExportHtmlword.php index fe87c9ea8d..4695189055 100644 --- a/src/Plugins/Export/ExportHtmlword.php +++ b/src/Plugins/Export/ExportHtmlword.php @@ -584,7 +584,7 @@ class ExportHtmlword extends ExportPlugin $fmtPre = ''; $fmtPost = ''; - if (in_array($column->field, $uniqueKeys)) { + if (in_array($column->field, $uniqueKeys, true)) { $fmtPre = '' . $fmtPre; $fmtPost .= ''; } diff --git a/src/Plugins/Export/ExportLatex.php b/src/Plugins/Export/ExportLatex.php index f705fd00e2..d74ee2eb36 100644 --- a/src/Plugins/Export/ExportLatex.php +++ b/src/Plugins/Export/ExportLatex.php @@ -598,7 +598,7 @@ class ExportLatex extends ExportPlugin $localBuffer = '\\textit{' . mb_substr($localBuffer, 0, $pos) . '}' . mb_substr($localBuffer, $pos); } - if (in_array($fieldName, $uniqueKeys)) { + if (in_array($fieldName, $uniqueKeys, true)) { $pos = (int) mb_strpos($localBuffer, "\000"); $localBuffer = '\\textbf{' . mb_substr($localBuffer, 0, $pos) . '}' . mb_substr($localBuffer, $pos); } diff --git a/src/Plugins/Export/ExportTexytext.php b/src/Plugins/Export/ExportTexytext.php index c6c3681a0b..98befb3d9a 100644 --- a/src/Plugins/Export/ExportTexytext.php +++ b/src/Plugins/Export/ExportTexytext.php @@ -540,7 +540,7 @@ class ExportTexytext extends ExportPlugin $fmtPre = ''; $fmtPost = ''; - if (in_array($column->field, $uniqueKeys)) { + if (in_array($column->field, $uniqueKeys, true)) { $fmtPre = '**' . $fmtPre; $fmtPost .= '**'; } diff --git a/src/Plugins/Schema/Dia/DiaRelationSchema.php b/src/Plugins/Schema/Dia/DiaRelationSchema.php index 4f46cffa6d..c3b94b09f2 100644 --- a/src/Plugins/Schema/Dia/DiaRelationSchema.php +++ b/src/Plugins/Schema/Dia/DiaRelationSchema.php @@ -102,7 +102,7 @@ class DiaRelationSchema extends ExportRelationSchema // put the foreign table on the schema only if selected by the user // (do not use array_search() because we would have to do a === false and this is not PHP3 compatible) if ($masterField !== 'foreign_keys_data') { - if (in_array($rel['foreign_table'], $alltables)) { + if (in_array($rel['foreign_table'], $alltables, true)) { $this->addRelation( $oneTable, $masterField, @@ -116,7 +116,7 @@ class DiaRelationSchema extends ExportRelationSchema } foreach ($rel as $oneKey) { - if (! in_array($oneKey['ref_table_name'], $alltables)) { + if (! in_array($oneKey['ref_table_name'], $alltables, true)) { continue; } diff --git a/src/Plugins/Schema/Eps/EpsRelationSchema.php b/src/Plugins/Schema/Eps/EpsRelationSchema.php index 3d28c28469..20b43e8fb5 100644 --- a/src/Plugins/Schema/Eps/EpsRelationSchema.php +++ b/src/Plugins/Schema/Eps/EpsRelationSchema.php @@ -111,7 +111,7 @@ class EpsRelationSchema extends ExportRelationSchema * to do a === false and this is not PHP3 compatible) */ if ($masterField !== 'foreign_keys_data') { - if (in_array($rel['foreign_table'], $alltables)) { + if (in_array($rel['foreign_table'], $alltables, true)) { $this->addRelation( $oneTable, $this->eps->getFont(), @@ -127,7 +127,7 @@ class EpsRelationSchema extends ExportRelationSchema } foreach ($rel as $oneKey) { - if (! in_array($oneKey['ref_table_name'], $alltables)) { + if (! in_array($oneKey['ref_table_name'], $alltables, true)) { continue; } diff --git a/src/Plugins/Schema/Pdf/PdfRelationSchema.php b/src/Plugins/Schema/Pdf/PdfRelationSchema.php index 9cd8990fee..094fb74ebd 100644 --- a/src/Plugins/Schema/Pdf/PdfRelationSchema.php +++ b/src/Plugins/Schema/Pdf/PdfRelationSchema.php @@ -211,7 +211,7 @@ class PdfRelationSchema extends ExportRelationSchema // (do not use array_search() because we would have to // to do a === false and this is not PHP3 compatible) if ($masterField !== 'foreign_keys_data') { - if (in_array($rel['foreign_table'], $alltables)) { + if (in_array($rel['foreign_table'], $alltables, true)) { $this->addRelation($oneTable, $masterField, $rel['foreign_table'], $rel['foreign_field']); } @@ -219,7 +219,7 @@ class PdfRelationSchema extends ExportRelationSchema } foreach ($rel as $oneKey) { - if (! in_array($oneKey['ref_table_name'], $alltables)) { + if (! in_array($oneKey['ref_table_name'], $alltables, true)) { continue; } diff --git a/src/Plugins/Schema/Svg/SvgRelationSchema.php b/src/Plugins/Schema/Svg/SvgRelationSchema.php index 32363d4928..79f6cd7436 100644 --- a/src/Plugins/Schema/Svg/SvgRelationSchema.php +++ b/src/Plugins/Schema/Svg/SvgRelationSchema.php @@ -126,7 +126,7 @@ class SvgRelationSchema extends ExportRelationSchema * to do a === false and this is not PHP3 compatible) */ if ($masterField !== 'foreign_keys_data') { - if (in_array($rel['foreign_table'], $alltables)) { + if (in_array($rel['foreign_table'], $alltables, true)) { $this->addRelation( $oneTable, $this->svg->getFont(), @@ -142,7 +142,7 @@ class SvgRelationSchema extends ExportRelationSchema } foreach ($rel as $oneKey) { - if (! in_array($oneKey['ref_table_name'], $alltables)) { + if (! in_array($oneKey['ref_table_name'], $alltables, true)) { continue; } diff --git a/src/Query/Compatibility.php b/src/Query/Compatibility.php index 75279cfae3..327837570a 100644 --- a/src/Query/Compatibility.php +++ b/src/Query/Compatibility.php @@ -185,7 +185,7 @@ class Compatibility // except TINYINT(1). // See: https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-19.html $integerTypes = ['SMALLINT', 'MEDIUMINT', 'INT', 'BIGINT']; - $typeLengthNotAllowed = in_array($type, $integerTypes) || $type === 'TINYINT' && $length !== '1'; + $typeLengthNotAllowed = in_array($type, $integerTypes, true) || $type === 'TINYINT' && $length !== '1'; return ! (self::isIntegersLengthRestricted($dbi) && $typeLengthNotAllowed); } diff --git a/src/Replication/ReplicationGui.php b/src/Replication/ReplicationGui.php index 5a07548c5b..801f82c1cb 100644 --- a/src/Replication/ReplicationGui.php +++ b/src/Replication/ReplicationGui.php @@ -290,7 +290,7 @@ class ReplicationGui 'Replicate_Wild_Do_Table', 'Replicate_Wild_Ignore_Table', ]; - if (! in_array($variable, $variablesWrap)) { + if (! in_array($variable, $variablesWrap, true)) { continue; } diff --git a/src/Server/Privileges.php b/src/Server/Privileges.php index dd80c22b5d..b4d90c88be 100644 --- a/src/Server/Privileges.php +++ b/src/Server/Privileges.php @@ -183,7 +183,7 @@ class Privileges $usersGrants = explode(',', $row['Table_priv']); foreach ($avGrants as $currentGrant) { - $row[$currentGrant . '_priv'] = in_array($currentGrant, $usersGrants) ? 'Y' : 'N'; + $row[$currentGrant . '_priv'] = in_array($currentGrant, $usersGrants, true) ? 'Y' : 'N'; } unset($row['Table_priv']); @@ -1462,7 +1462,7 @@ class Privileges $dbRightsSqls = []; foreach ($tablesToSearchForUsers as $tableSearchIn) { - if (! in_array($tableSearchIn, $tables)) { + if (! in_array($tableSearchIn, $tables, true)) { continue; } @@ -1614,6 +1614,7 @@ class Privileges $onePrivilege['grant'] = in_array( 'Grant', explode(',', $row['Table_priv']), + true, ); $onePrivilege['column_privs'] = ! empty($row['Column_priv']); $onePrivilege['privileges'] = implode(',', $this->extractPrivInfo($row, true)); @@ -1625,6 +1626,7 @@ class Privileges $onePrivilege['grant'] = in_array( 'Grant', explode(',', $row['Proc_priv']), + true, ); $privs = $this->parseProcPriv($row['Proc_priv']); @@ -1682,7 +1684,7 @@ class Privileges $databases = []; $escapedDatabases = []; foreach ($predDbArray as $currentDb) { - if (in_array($currentDb, $databasesToSkip)) { + if (in_array($currentDb, $databasesToSkip, true)) { continue; } @@ -1691,7 +1693,7 @@ class Privileges // because the list of databases has special characters // already escaped in $foundRows, // contrary to the output of SHOW DATABASES - if (in_array($currentDbEscaped, $foundRows)) { + if (in_array($currentDbEscaped, $foundRows, true)) { continue; } @@ -1707,7 +1709,7 @@ class Privileges $tables = []; if ($result) { while ($row = $result->fetchRow()) { - if (in_array($row[0], $foundRows)) { + if (in_array($row[0], $foundRows, true)) { continue; } @@ -1721,7 +1723,7 @@ class Privileges $routines = []; foreach ($routineData as $routine) { - if (in_array($routine['name'], $foundRows)) { + if (in_array($routine['name'], $foundRows, true)) { continue; } @@ -2797,38 +2799,38 @@ class Privileges while ($row2 = $res2->fetchAssoc()) { $tmpArray = explode(',', $row2['Column_priv']); - if (in_array('Select', $tmpArray)) { + if (in_array('Select', $tmpArray, true)) { $tmpPrivs2['Select'][] = $row2['Column_name']; } - if (in_array('Insert', $tmpArray)) { + if (in_array('Insert', $tmpArray, true)) { $tmpPrivs2['Insert'][] = $row2['Column_name']; } - if (in_array('Update', $tmpArray)) { + if (in_array('Update', $tmpArray, true)) { $tmpPrivs2['Update'][] = $row2['Column_name']; } - if (! in_array('References', $tmpArray)) { + if (! in_array('References', $tmpArray, true)) { continue; } $tmpPrivs2['References'][] = $row2['Column_name']; } - if ($tmpPrivs2['Select'] !== [] && ! in_array('SELECT', $tmpPrivs1)) { + if ($tmpPrivs2['Select'] !== [] && ! in_array('SELECT', $tmpPrivs1, true)) { $tmpPrivs1[] = 'SELECT (`' . implode('`, `', $tmpPrivs2['Select']) . '`)'; } - if ($tmpPrivs2['Insert'] !== [] && ! in_array('INSERT', $tmpPrivs1)) { + if ($tmpPrivs2['Insert'] !== [] && ! in_array('INSERT', $tmpPrivs1, true)) { $tmpPrivs1[] = 'INSERT (`' . implode('`, `', $tmpPrivs2['Insert']) . '`)'; } - if ($tmpPrivs2['Update'] !== [] && ! in_array('UPDATE', $tmpPrivs1)) { + if ($tmpPrivs2['Update'] !== [] && ! in_array('UPDATE', $tmpPrivs1, true)) { $tmpPrivs1[] = 'UPDATE (`' . implode('`, `', $tmpPrivs2['Update']) . '`)'; } - if ($tmpPrivs2['References'] !== [] && ! in_array('REFERENCES', $tmpPrivs1)) { + if ($tmpPrivs2['References'] !== [] && ! in_array('REFERENCES', $tmpPrivs1, true)) { $tmpPrivs1[] = 'REFERENCES (`' . implode('`, `', $tmpPrivs2['References']) . '`)'; } @@ -2837,7 +2839,7 @@ class Privileges . Util::backquote($row['Table_name']) . ' TO ' . $this->dbi->quoteString($username) . '@' . $this->dbi->quoteString($hostname) - . (in_array('Grant', explode(',', $row['Table_priv'])) + . (in_array('Grant', explode(',', $row['Table_priv']), true) ? ' WITH GRANT OPTION;' : ';'); } diff --git a/src/Table/ColumnsDefinition.php b/src/Table/ColumnsDefinition.php index 5d5e34d116..130d4eb6bb 100644 --- a/src/Table/ColumnsDefinition.php +++ b/src/Table/ColumnsDefinition.php @@ -180,7 +180,7 @@ final class ColumnsDefinition } elseif (isset($fieldsMeta[$columnNumber])) { $columnMeta = $fieldsMeta[$columnNumber]; $virtual = ['VIRTUAL', 'PERSISTENT', 'VIRTUAL GENERATED', 'STORED GENERATED']; - if (in_array($columnMeta['Extra'], $virtual)) { + if (in_array($columnMeta['Extra'], $virtual, true)) { $tableObj = new Table($GLOBALS['table'], $GLOBALS['db'], $this->dbi); $expressions = $tableObj->getColumnGenerationExpression($columnMeta['Field']); $columnMeta['Expression'] = is_array($expressions) ? $expressions[$columnMeta['Field']] : null; diff --git a/src/Table/Search.php b/src/Table/Search.php index d84a13a2ce..f88ec8a351 100644 --- a/src/Table/Search.php +++ b/src/Table/Search.php @@ -287,7 +287,7 @@ final class Search // If the where clause is something like 'IsEmpty(`spatial_col_name`)' if (isset($geomUnaryFunctions[$geomFunc]) && trim($criteriaValues) == '') { $where = $geomFunctionApplied; - } elseif (in_array($type, Gis::getDataTypes()) && ! empty($criteriaValues)) { + } elseif (in_array($type, Gis::getDataTypes(), true) && ! empty($criteriaValues)) { // create gis data from the criteria input $gisData = Gis::createData($criteriaValues, $this->dbi->getVersion()); $where = $geomFunctionApplied . ' ' . $funcType . ' ' . $gisData; diff --git a/src/Table/Table.php b/src/Table/Table.php index 6bd75a5063..fa29abe48d 100644 --- a/src/Table/Table.php +++ b/src/Table/Table.php @@ -1475,7 +1475,7 @@ class Table implements Stringable } // a column might have a primary and an unique index on it - if (in_array($possibleColumn, $return)) { + if (in_array($possibleColumn, $return, true)) { continue; } @@ -2007,7 +2007,7 @@ class Table implements Stringable if ( $index->getChoice() !== 'SPATIAL' && $index->getChoice() !== 'FULLTEXT' - && in_array($type, Index::getIndexTypes()) + && in_array($type, Index::getIndexTypes(), true) && ! $this->isEngine('TOKUDB') ) { $sqlQuery .= ' USING ' . $type; diff --git a/src/Triggers/Triggers.php b/src/Triggers/Triggers.php index dab916b121..06cd31dd83 100644 --- a/src/Triggers/Triggers.php +++ b/src/Triggers/Triggers.php @@ -191,20 +191,23 @@ class Triggers $GLOBALS['errors'][] = __('You must provide a trigger name!'); } - if (! empty($_POST['item_timing']) && in_array($_POST['item_timing'], $this->time)) { + if (! empty($_POST['item_timing']) && in_array($_POST['item_timing'], $this->time, true)) { $query .= $_POST['item_timing'] . ' '; } else { $GLOBALS['errors'][] = __('You must provide a valid timing for the trigger!'); } - if (! empty($_POST['item_event']) && in_array($_POST['item_event'], $this->event)) { + if (! empty($_POST['item_event']) && in_array($_POST['item_event'], $this->event, true)) { $query .= $_POST['item_event'] . ' '; } else { $GLOBALS['errors'][] = __('You must provide a valid event for the trigger!'); } $query .= 'ON '; - if (! empty($_POST['item_table']) && in_array($_POST['item_table'], $this->dbi->getTables($GLOBALS['db']))) { + if ( + ! empty($_POST['item_table']) + && in_array($_POST['item_table'], $this->dbi->getTables($GLOBALS['db']), true) + ) { $query .= Util::backquote($_POST['item_table']); } else { $GLOBALS['errors'][] = __('You must provide a valid table name!'); diff --git a/src/TwoFactor.php b/src/TwoFactor.php index 822045ad0c..309916f205 100644 --- a/src/TwoFactor.php +++ b/src/TwoFactor.php @@ -42,7 +42,7 @@ class TwoFactor protected TwoFactorPlugin $backend; - /** @var mixed[] */ + /** @var string[] */ protected array $available; private UserPreferences $userPreferences; @@ -101,7 +101,7 @@ class TwoFactor return $this->backend; } - /** @return mixed[] */ + /** @return string[] */ public function getAvailable(): array { return $this->available; @@ -174,7 +174,7 @@ class TwoFactor public function getBackendClass(string $name): string { $result = TwoFactorPlugin::class; - if (in_array($name, $this->available)) { + if (in_array($name, $this->available, true)) { /** @psalm-var class-string $result */ $result = 'PhpMyAdmin\\Plugins\\TwoFactor\\' . ucfirst($name); } elseif ($name !== '') { @@ -257,7 +257,7 @@ class TwoFactor $cls = $this->getBackendClass($name); $this->backend = new $cls($this); } else { - if (! in_array($name, $this->available)) { + if (! in_array($name, $this->available, true)) { return false; } diff --git a/src/Types.php b/src/Types.php index 5b04d99b50..be78080e78 100644 --- a/src/Types.php +++ b/src/Types.php @@ -47,7 +47,7 @@ class Types */ public function isUnaryOperator(string $op): bool { - return in_array($op, $this->getUnaryOperators()); + return in_array($op, $this->getUnaryOperators(), true); } /** diff --git a/src/Util.php b/src/Util.php index 60d9121e55..9ad79ae894 100644 --- a/src/Util.php +++ b/src/Util.php @@ -95,7 +95,7 @@ class Util */ public static function showIcons(string $value): bool { - return in_array(Config::getInstance()->settings[$value], ['icons', 'both']); + return in_array(Config::getInstance()->settings[$value], ['icons', 'both'], true); } /** @@ -105,7 +105,7 @@ class Util */ public static function showText(string $value): bool { - return in_array(Config::getInstance()->settings[$value], ['text', 'both']); + return in_array(Config::getInstance()->settings[$value], ['text', 'both'], true); } /** @@ -1819,7 +1819,7 @@ class Util $whereAdded = true; } - if (isset($_REQUEST['tbl_type']) && in_array($_REQUEST['tbl_type'], ['table', 'view'])) { + if (isset($_REQUEST['tbl_type']) && in_array($_REQUEST['tbl_type'], ['table', 'view'], true)) { $tblGroupSql .= $whereAdded ? ' AND' : ' WHERE'; if ($_REQUEST['tbl_type'] === 'view') { $tblGroupSql .= " `Table_type` NOT IN ('BASE TABLE', 'SYSTEM VERSIONED')"; @@ -2055,7 +2055,7 @@ class Util 'sort_order' => $futureSortOrder, ]; - if (isset($_REQUEST['tbl_type']) && in_array($_REQUEST['tbl_type'], ['view', 'table'])) { + if (isset($_REQUEST['tbl_type']) && in_array($_REQUEST['tbl_type'], ['view', 'table'], true)) { $urlParams['tbl_type'] = $_REQUEST['tbl_type']; } @@ -2098,7 +2098,7 @@ class Util [$keyName, $value] = $keyValueArray; $value = trim(strtolower($value)); - if (strtolower(trim($keyName)) === 'proto' && in_array($value, ['http', 'https'])) { + if (strtolower(trim($keyName)) === 'proto' && in_array($value, ['http', 'https'], true)) { return $value; } } diff --git a/tests/classes/AbstractTestCase.php b/tests/classes/AbstractTestCase.php index cbde2d83c5..470baea158 100644 --- a/tests/classes/AbstractTestCase.php +++ b/tests/classes/AbstractTestCase.php @@ -50,7 +50,7 @@ abstract class AbstractTestCase extends TestCase protected function setUp(): void { foreach (array_keys($GLOBALS) as $key) { - if (in_array($key, $this->globalsAllowList)) { + if (in_array($key, $this->globalsAllowList, true)) { continue; } @@ -189,7 +189,7 @@ abstract class AbstractTestCase extends TestCase Config::$instance = null; (new ReflectionProperty(Template::class, 'twig'))->setValue(null, null); foreach (array_keys($GLOBALS) as $key) { - if (in_array($key, $this->globalsAllowList)) { + if (in_array($key, $this->globalsAllowList, true)) { continue; } diff --git a/tests/classes/TwoFactorTest.php b/tests/classes/TwoFactorTest.php index 72404b0206..50a7dbaeeb 100644 --- a/tests/classes/TwoFactorTest.php +++ b/tests/classes/TwoFactorTest.php @@ -255,7 +255,7 @@ class TwoFactorTest extends AbstractTestCase $request = new ServerRequest($this->createStub(ServerRequestInterface::class)); $object = $this->getTwoFactorAndLoadConfig('user', null); - if (! in_array('application', $object->getAvailable())) { + if (! in_array('application', $object->getAvailable(), true)) { $this->markTestSkipped('google2fa not available'); } @@ -309,7 +309,7 @@ class TwoFactorTest extends AbstractTestCase $request = new ServerRequest($this->createStub(ServerRequestInterface::class)); $object = $this->getTwoFactorAndLoadConfig('user', null); - if (! in_array('key', $object->getAvailable())) { + if (! in_array('key', $object->getAvailable(), true)) { $this->markTestSkipped('u2f-php-server not available'); } @@ -375,7 +375,7 @@ class TwoFactorTest extends AbstractTestCase $request = new ServerRequest($this->createStub(ServerRequestInterface::class)); $object = $this->getTwoFactorAndLoadConfig('user', null); - if (! in_array('key', $object->getAvailable())) { + if (! in_array('key', $object->getAvailable(), true)) { $this->markTestSkipped('u2f-php-server not available'); } From 2ab75067f8c191889e44f3b506e781400664c5ad Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Wed, 6 Dec 2023 00:06:47 +0100 Subject: [PATCH 11/11] Simplify checkPageValidity() Signed-off-by: Kamil Tekiela --- phpstan-baseline.neon | 5 ----- src/Core.php | 24 ++++++------------------ tests/classes/CoreTest.php | 26 +++++++++++--------------- 3 files changed, 17 insertions(+), 38 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index f94fe5992b..4191f423dd 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -8245,11 +8245,6 @@ parameters: count: 1 path: src/Core.php - - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 3 - path: src/Core.php - - message: "#^Cannot access offset string on mixed\\.$#" count: 8 diff --git a/src/Core.php b/src/Core.php index 4f08043ae0..53ad31f51e 100644 --- a/src/Core.php +++ b/src/Core.php @@ -157,37 +157,25 @@ class Core } /** - * Checks given $page against given $allowList and returns true if valid - * it optionally ignores query parameters in $page (script.php?ignored) - * - * @param string $page page to check - * @param mixed[] $allowList allow list to check page against - * @param bool $include whether the page is going to be included + * Checks if the given $page is index.php and returns true if valid. + * It ignores query parameters in $page (script.php?ignored) */ - public static function checkPageValidity(string $page, array $allowList = [], bool $include = false): bool + public static function checkPageValidity(string $page): bool { - if ($allowList === []) { - $allowList = ['index.php']; - } - if ($page === '') { return false; } - if (in_array($page, $allowList)) { + if ($page === 'index.php') { return true; } - if ($include) { - return false; - } - $newPage = mb_substr( $page, 0, (int) mb_strpos($page . '?', '?'), ); - if (in_array($newPage, $allowList)) { + if ($newPage === 'index.php') { return true; } @@ -198,7 +186,7 @@ class Core (int) mb_strpos($newPage . '?', '?'), ); - return in_array($newPage, $allowList); + return $newPage === 'index.php'; } /** diff --git a/tests/classes/CoreTest.php b/tests/classes/CoreTest.php index 0f0a0c7668..c5a2ce6ce7 100644 --- a/tests/classes/CoreTest.php +++ b/tests/classes/CoreTest.php @@ -237,33 +237,29 @@ class CoreTest extends AbstractTestCase /** * Test for Core::checkPageValidity * - * @param string $page Page - * @param string[] $allowList Allow list - * @param bool $include whether the page is going to be included - * @param bool $expected Expected value + * @param string $page Page + * @param bool $expected Expected value */ #[DataProvider('providerTestGotoNowhere')] - public function testGotoNowhere(string $page, array $allowList, bool $include, bool $expected): void + public function testGotoNowhere(string $page, bool $expected): void { - $this->assertSame($expected, Core::checkPageValidity($page, $allowList, $include)); + $this->assertSame($expected, Core::checkPageValidity($page)); } /** * Data provider for testGotoNowhere * - * @return array + * @return array */ public static function providerTestGotoNowhere(): array { return [ - ['', [], false, false], - ['', [], true, false], - ['shell.php', ['index.php'], false, false], - ['shell.php', ['index.php'], true, false], - ['index.php?sql.php&test=true', ['index.php'], false, true], - ['index.php?sql.php&test=true', ['index.php'], true, false], - ['index.php%3Fsql.php%26test%3Dtrue', ['index.php'], false, true], - ['index.php%3Fsql.php%26test%3Dtrue', ['index.php'], true, false], + ['', false], + ['shell.php', false], + ['index.php?sql.php&test=true', true], + ['shell.php?sql.php&test=true', false], + ['index.php%3Fsql.php%26test%3Dtrue', true], + ['shell.php%3Fsql.php%26test%3Dtrue', false], ]; }