Skip to content

Commit ed17c71

Browse files
Merge pull request #18833 from kamil-tekiela/in_array
Various fixes to make in_array a strict check
2 parents 8ace8b2 + 2ab7506 commit ed17c71

68 files changed

Lines changed: 279 additions & 637 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

phpstan-baseline.neon

Lines changed: 27 additions & 337 deletions
Large diffs are not rendered by default.

psalm-baseline.xml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,6 @@
12431243
<code><![CDATA[$_POST['item_type']]]></code>
12441244
<code><![CDATA[$_POST['item_type']]]></code>
12451245
<code><![CDATA[$_REQUEST['item_name']]]></code>
1246-
<code>$type</code>
12471246
</PossiblyInvalidArgument>
12481247
<PossiblyInvalidCast>
12491248
<code><![CDATA[$_GET['item_name']]]></code>
@@ -2079,7 +2078,6 @@
20792078
<code><![CDATA[$GLOBALS['timestamp']]]></code>
20802079
</InvalidArrayOffset>
20812080
<MixedArgument>
2082-
<code><![CDATA[$GLOBALS['format']]]></code>
20832081
<code><![CDATA[$GLOBALS['import_file']]]></code>
20842082
<code><![CDATA[$GLOBALS['import_file']]]></code>
20852083
<code><![CDATA[$GLOBALS['import_notice']]]></code>
@@ -2154,7 +2152,6 @@
21542152
</MixedMethodCall>
21552153
<MixedOperand>
21562154
<code><![CDATA[$GLOBALS['charset_of_file']]]></code>
2157-
<code><![CDATA[$GLOBALS['format']]]></code>
21582155
<code><![CDATA[$GLOBALS['local_import_file']]]></code>
21592156
</MixedOperand>
21602157
<PossiblyInvalidArgument>
@@ -3828,7 +3825,6 @@
38283825
<code><![CDATA[$GLOBALS['query']]]></code>
38293826
<code><![CDATA[$GLOBALS['unsaved_values']]]></code>
38303827
<code><![CDATA[$GLOBALS['unsaved_values'][$rowNumber]]]></code>
3831-
<code><![CDATA[$GLOBALS['urlParams']['after_insert']]]></code>
38323828
<code><![CDATA[$GLOBALS['urlParams']['where_clause'][]]]></code>
38333829
<code>$afterInsert</code>
38343830
<code>$clauseIsUnique</code>
@@ -4418,11 +4414,8 @@
44184414
<code><![CDATA[$viewData['with']]]></code>
44194415
</MixedAssignment>
44204416
<MixedOperand>
4421-
<code><![CDATA[$view['algorithm']]]></code>
44224417
<code><![CDATA[$view['as']]]></code>
44234418
<code><![CDATA[$view['column_names']]]></code>
4424-
<code><![CDATA[$view['sql_security']]]></code>
4425-
<code><![CDATA[$view['with']]]></code>
44264419
</MixedOperand>
44274420
<PossiblyUnusedMethod>
44284421
<code>__construct</code>
@@ -4540,7 +4533,6 @@
45404533
</MixedAssignment>
45414534
<MixedOperand>
45424535
<code><![CDATA[$column['size']]]></code>
4543-
<code><![CDATA[$index['Index_type']]]></code>
45444536
<code><![CDATA[$partition['comment']]]></code>
45454537
<code><![CDATA[$partition['data_directory']]]></code>
45464538
<code><![CDATA[$partition['engine']]]></code>
@@ -5034,7 +5026,6 @@
50345026
</PossiblyInvalidCast>
50355027
<PossiblyInvalidOperand>
50365028
<code><![CDATA[$_POST['item_definition']]]></code>
5037-
<code><![CDATA[$_POST['item_interval_field']]]></code>
50385029
</PossiblyInvalidOperand>
50395030
<PossiblyNullArgument>
50405031
<code>$createItem</code>
@@ -5152,7 +5143,6 @@
51525143
<code><![CDATA[$GLOBALS['errors'][]]]></code>
51535144
<code><![CDATA[$GLOBALS['errors'][]]]></code>
51545145
<code><![CDATA[$GLOBALS['errors'][]]]></code>
5155-
<code><![CDATA[$params[$i]['htmlentities'][]]]></code>
51565146
<code><![CDATA[$routine['item_param_name'][$i]]]></code>
51575147
</MixedArrayAssignment>
51585148
<MixedArrayOffset>
@@ -5248,8 +5238,6 @@
52485238
<code><![CDATA[$_POST['item_returnlength']]]></code>
52495239
<code><![CDATA[$_POST['item_type']]]></code>
52505240
<code>$itemDefinition</code>
5251-
<code>$itemReturnType</code>
5252-
<code>$itemSqlDataAccess</code>
52535241
</PossiblyInvalidOperand>
52545242
<PossiblyNullArgument>
52555243
<code>$createRoutine</code>
@@ -5954,11 +5942,9 @@
59545942
<code>$dbAlias</code>
59555943
<code>$dbAlias</code>
59565944
<code>$table</code>
5957-
<code>$table</code>
59585945
</MixedArgument>
59595946
<MixedArgumentTypeCoercion>
59605947
<code>$dbSelect</code>
5961-
<code>$tables</code>
59625948
</MixedArgumentTypeCoercion>
59635949
<MixedArrayAccess>
59645950
<code><![CDATA[$aliases[$db->getName()]['alias']]]></code>
@@ -5989,7 +5975,6 @@
59895975
<code>$dbAlias</code>
59905976
<code>$dbAlias</code>
59915977
<code>$table</code>
5992-
<code>$table</code>
59935978
<code>$tableName</code>
59945979
<code>$tbl</code>
59955980
<code>$val</code>
@@ -7483,9 +7468,6 @@
74837468
<code>int</code>
74847469
<code>int</code>
74857470
</InvalidReturnType>
7486-
<MixedAssignment>
7487-
<code>$item</code>
7488-
</MixedAssignment>
74897471
</file>
74907472
<file src="src/Navigation/Nodes/NodeDatabaseChild.php">
74917473
<PossiblyInvalidPropertyFetch>
@@ -12351,15 +12333,12 @@
1235112333
<code><![CDATA[$_POST['item_name']]]></code>
1235212334
<code><![CDATA[$_POST['item_name']]]></code>
1235312335
<code><![CDATA[$_POST['item_original_name']]]></code>
12354-
<code><![CDATA[$_POST['item_table']]]></code>
1235512336
</PossiblyInvalidArgument>
1235612337
<PossiblyInvalidCast>
1235712338
<code><![CDATA[$_POST['item_original_name']]]></code>
1235812339
</PossiblyInvalidCast>
1235912340
<PossiblyInvalidOperand>
1236012341
<code><![CDATA[$_POST['item_definition']]]></code>
12361-
<code><![CDATA[$_POST['item_event']]]></code>
12362-
<code><![CDATA[$_POST['item_timing']]]></code>
1236312342
</PossiblyInvalidOperand>
1236412343
<PossiblyNullReference>
1236512344
<code>getCreateSql</code>
@@ -12373,12 +12352,6 @@
1237312352
<code>Config::getInstance()</code>
1237412353
<code>DatabaseInterface::getInstance()</code>
1237512354
</DeprecatedMethod>
12376-
<MixedArgument>
12377-
<code>$name</code>
12378-
</MixedArgument>
12379-
<MixedAssignment>
12380-
<code>$name</code>
12381-
</MixedAssignment>
1238212355
<UnsafeInstantiation>
1238312356
<code>new $cls($this)</code>
1238412357
<code>new $cls($this)</code>

src/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ public function load(string|null $source = null): bool
351351
* Parses the configuration file, we throw away any errors or
352352
* output.
353353
*/
354-
$canUseErrorReporting = Util::isErrorReportingAvailable();
354+
$canUseErrorReporting = function_exists('error_reporting');
355355
$oldErrorReporting = null;
356356
if ($canUseErrorReporting) {
357357
$oldErrorReporting = error_reporting(0);

src/ConfigStorage/Relation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ public function fixPmaTables(string $db, bool $create = true): void
15191519
// Check if the table already exists
15201520
// use the possible replaced name first and fallback on the table name
15211521
// if no replacement exists
1522-
if (! in_array($tableNameReplacements[$table] ?? $table, $existingTables)) {
1522+
if (! in_array($tableNameReplacements[$table] ?? $table, $existingTables, true)) {
15231523
if (! $create) {
15241524
continue;
15251525
}

src/Controllers/Database/DesignerController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function __invoke(ServerRequest $request): void
197197
}
198198

199199
foreach ($tablePositions as $position) {
200-
if (in_array($position['dbName'] . '.' . $position['tableName'], $fullTableNames)) {
200+
if (in_array($position['dbName'] . '.' . $position['tableName'], $fullTableNames, true)) {
201201
continue;
202202
}
203203

src/Controllers/Database/RoutinesController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ public function __invoke(ServerRequest $request): void
6464
/**
6565
* Displays the header and tabs
6666
*/
67-
if (! empty($GLOBALS['table']) && in_array($GLOBALS['table'], $this->dbi->getTables($GLOBALS['db']))) {
67+
if (
68+
! empty($GLOBALS['table'])
69+
&& in_array($GLOBALS['table'], $this->dbi->getTables($GLOBALS['db']), true)
70+
) {
6871
if (! $this->checkParameters(['db', 'table'])) {
6972
return;
7073
}
@@ -452,7 +455,7 @@ public function __invoke(ServerRequest $request): void
452455
}
453456
}
454457

455-
if (! isset($type) || ! in_array($type, ['FUNCTION', 'PROCEDURE'])) {
458+
if (! isset($type) || ! in_array($type, ['FUNCTION', 'PROCEDURE'], true)) {
456459
$type = null;
457460
}
458461

src/Controllers/Database/StructureController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ protected function isRowCountApproximated(
557557
if (isset($currentTable['TABLE_ROWS']) && ($currentTable['ENGINE'] != null || $tableIsView)) {
558558
// InnoDB/TokuDB table: we did not get an accurate row count
559559
$approxRows = ! $tableIsView
560-
&& in_array($currentTable['ENGINE'], ['InnoDB', 'TokuDB'])
560+
&& in_array($currentTable['ENGINE'], ['InnoDB', 'TokuDB'], true)
561561
&& ! $currentTable['COUNTED'];
562562

563563
if ($tableIsView && $currentTable['TABLE_ROWS'] >= Config::getInstance()->settings['MaxExactCountViews']) {
@@ -828,7 +828,7 @@ protected function getValuesForInnodbTable(
828828
$formattedSize = $unit = '';
829829

830830
if (
831-
(in_array($currentTable['ENGINE'], ['InnoDB', 'TokuDB'])
831+
(in_array($currentTable['ENGINE'], ['InnoDB', 'TokuDB'], true)
832832
&& $currentTable['TABLE_ROWS'] < Config::getInstance()->settings['MaxExactCount'])
833833
|| ! isset($currentTable['TABLE_ROWS'])
834834
) {

src/Controllers/ErrorReportController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __invoke(ServerRequest $request): void
4848
/** @var string|null $alwaysSend */
4949
$alwaysSend = $request->getParsedBodyParam('always_send');
5050

51-
if (! in_array($exceptionType, ['js', 'php'])) {
51+
if (! in_array($exceptionType, ['js', 'php'], true)) {
5252
return;
5353
}
5454

src/Controllers/Export/ExportController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function __invoke(ServerRequest $request): void
153153
$separateFiles = $asSeparateFiles;
154154
}
155155

156-
if (in_array($compressionParam, $compressionMethods)) {
156+
if (in_array($compressionParam, $compressionMethods, true)) {
157157
$GLOBALS['compression'] = $compressionParam;
158158
$GLOBALS['buffer_needed'] = true;
159159
}

src/Controllers/Import/ImportController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function __invoke(ServerRequest $request): void
229229
* We only need to load the selected plugin
230230
*/
231231

232-
if (! in_array($GLOBALS['format'], ['csv', 'ldi', 'mediawiki', 'ods', 'shp', 'sql', 'xml'])) {
232+
if (! in_array($GLOBALS['format'], ['csv', 'ldi', 'mediawiki', 'ods', 'shp', 'sql', 'xml'], true)) {
233233
// this should not happen for a normal user
234234
// but only during an attack
235235
$this->response->setRequestStatus(false);

0 commit comments

Comments
 (0)