Skip to content

Commit c30bc4d

Browse files
Merge pull request #19464 from MauricioFauth/export-globals
Remove some global variables from export plugins
2 parents 8e72191 + 75d11f9 commit c30bc4d

File tree

15 files changed

+481
-606
lines changed

15 files changed

+481
-606
lines changed

phpstan-baseline.neon

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11853,12 +11853,6 @@ parameters:
1185311853
count: 2
1185411854
path: src/Plugins/Export/ExportCodegen.php
1185511855

11856-
-
11857-
message: '#^Cannot cast mixed to int\.$#'
11858-
identifier: cast.int
11859-
count: 1
11860-
path: src/Plugins/Export/ExportCodegen.php
11861-
1186211856
-
1186311857
message: '#^Parameter \#1 \$str of static method PhpMyAdmin\\Plugins\\Export\\ExportCodegen\:\:cgMakeIdentifier\(\) expects string, string\|null given\.$#'
1186411858
identifier: argument.type
@@ -12435,12 +12429,6 @@ parameters:
1243512429
count: 1
1243612430
path: src/Plugins/Export/ExportPhparray.php
1243712431

12438-
-
12439-
message: '#^Binary operation "\." between ''SET SQL_MODE\="'' and mixed results in an error\.$#'
12440-
identifier: binaryOp.invalid
12441-
count: 1
12442-
path: src/Plugins/Export/ExportSql.php
12443-
1244412432
-
1244512433
message: '#^Binary operation "\." between ''SET time_zone \= "'' and mixed results in an error\.$#'
1244612434
identifier: binaryOp.invalid
@@ -12570,7 +12558,7 @@ parameters:
1257012558
-
1257112559
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
1257212560
identifier: empty.notAllowed
12573-
count: 41
12561+
count: 27
1257412562
path: src/Plugins/Export/ExportSql.php
1257512563

1257612564
-
@@ -12585,6 +12573,12 @@ parameters:
1258512573
count: 1
1258612574
path: src/Plugins/Export/ExportSql.php
1258712575

12576+
-
12577+
message: '#^Method PhpMyAdmin\\Plugins\\Export\\ExportSql\:\:setMaxQuerySize\(\) should return int\<0, max\> but returns int\.$#'
12578+
identifier: return.type
12579+
count: 2
12580+
path: src/Plugins/Export/ExportSql.php
12581+
1258812582
-
1258912583
message: '#^Only booleans are allowed in &&, bool\|null given on the left side\.$#'
1259012584
identifier: booleanAnd.leftNotBoolean
@@ -12597,12 +12591,6 @@ parameters:
1259712591
count: 1
1259812592
path: src/Plugins/Export/ExportSql.php
1259912593

12600-
-
12601-
message: '#^Only booleans are allowed in &&, mixed given on the right side\.$#'
12602-
identifier: booleanAnd.rightNotBoolean
12603-
count: 4
12604-
path: src/Plugins/Export/ExportSql.php
12605-
1260612594
-
1260712595
message: '#^Only booleans are allowed in an if condition, bool\|null given\.$#'
1260812596
identifier: if.condNotBoolean
@@ -12639,18 +12627,6 @@ parameters:
1263912627
count: 5
1264012628
path: src/Plugins/Export/ExportSql.php
1264112629

12642-
-
12643-
message: '#^Parameter \#2 \$compat of method PhpMyAdmin\\Plugins\\Export\\ExportSql\:\:exportUseStatement\(\) expects string, mixed given\.$#'
12644-
identifier: argument.type
12645-
count: 2
12646-
path: src/Plugins/Export/ExportSql.php
12647-
12648-
-
12649-
message: '#^Parameter \#2 \$compatibility of static method PhpMyAdmin\\Util\:\:backquoteCompat\(\) expects string, mixed given\.$#'
12650-
identifier: argument.type
12651-
count: 13
12652-
path: src/Plugins/Export/ExportSql.php
12653-
1265412630
-
1265512631
message: '#^Parameter \#2 \$haystack of function in_array expects array, mixed given\.$#'
1265612632
identifier: argument.type
@@ -12669,12 +12645,6 @@ parameters:
1266912645
count: 2
1267012646
path: src/Plugins/Export/ExportSql.php
1267112647

12672-
-
12673-
message: '#^Parameter \#2 \$string of function explode expects string, mixed given\.$#'
12674-
identifier: argument.type
12675-
count: 1
12676-
path: src/Plugins/Export/ExportSql.php
12677-
1267812648
-
1267912649
message: '#^Parameter \#3 \$name of static method PhpMyAdmin\\Database\\Events\:\:getDefinition\(\) expects string, mixed given\.$#'
1268012650
identifier: argument.type
@@ -12699,12 +12669,6 @@ parameters:
1269912669
count: 3
1270012670
path: src/Plugins/Export/ExportSql.php
1270112671

12702-
-
12703-
message: '#^Parameter \#5 \$compat of method PhpMyAdmin\\Plugins\\Export\\ExportSql\:\:generateComment\(\) expects string, mixed given\.$#'
12704-
identifier: argument.type
12705-
count: 3
12706-
path: src/Plugins/Export/ExportSql.php
12707-
1270812672
-
1270912673
message: '#^Property PhpMyAdmin\\SqlParser\\Components\\CreateDefinition\:\:\$name \(string\|null\) does not accept mixed\.$#'
1271012674
identifier: assign.propertyType
@@ -12852,18 +12816,6 @@ parameters:
1285212816
count: 1
1285312817
path: src/Plugins/Export/ExportXml.php
1285412818

12855-
-
12856-
message: '#^Only booleans are allowed in &&, mixed given on the right side\.$#'
12857-
identifier: booleanAnd.rightNotBoolean
12858-
count: 6
12859-
path: src/Plugins/Export/ExportXml.php
12860-
12861-
-
12862-
message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#'
12863-
identifier: booleanNot.exprNotBoolean
12864-
count: 1
12865-
path: src/Plugins/Export/ExportXml.php
12866-
1286712819
-
1286812820
message: '#^Only booleans are allowed in a ternary operator condition, mixed given\.$#'
1286912821
identifier: ternary.condNotBoolean
@@ -21753,7 +21705,7 @@ parameters:
2175321705
-
2175421706
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertStringContainsString\(\) expects string, mixed given\.$#'
2175521707
identifier: argument.type
21756-
count: 4
21708+
count: 2
2175721709
path: tests/unit/Plugins/Export/ExportSqlTest.php
2175821710

2175921711
-

psalm-baseline.xml

Lines changed: 9 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,6 @@
14411441
</MixedArrayAssignment>
14421442
<MixedAssignment>
14431443
<code><![CDATA[$GLOBALS['charset']]]></code>
1444-
<code><![CDATA[$GLOBALS['codegen_format']]]></code>
14451444
<code><![CDATA[$GLOBALS['compression']]]></code>
14461445
<code><![CDATA[$GLOBALS['csv_columns']]]></code>
14471446
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
@@ -1459,45 +1458,12 @@
14591458
<code><![CDATA[$GLOBALS['save_filename']]]></code>
14601459
<code><![CDATA[$GLOBALS['single_table']]]></code>
14611460
<code><![CDATA[$GLOBALS['single_table']]]></code>
1462-
<code><![CDATA[$GLOBALS['sql_auto_increment']]]></code>
1463-
<code><![CDATA[$GLOBALS['sql_compatibility']]]></code>
1464-
<code><![CDATA[$GLOBALS['sql_create_database']]]></code>
1465-
<code><![CDATA[$GLOBALS['sql_create_table']]]></code>
1466-
<code><![CDATA[$GLOBALS['sql_create_trigger']]]></code>
1467-
<code><![CDATA[$GLOBALS['sql_create_view']]]></code>
1468-
<code><![CDATA[$GLOBALS['sql_delayed']]]></code>
1469-
<code><![CDATA[$GLOBALS['sql_disable_fk']]]></code>
1470-
<code><![CDATA[$GLOBALS['sql_drop_database']]]></code>
1471-
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
1472-
<code><![CDATA[$GLOBALS['sql_header_comment']]]></code>
1473-
<code><![CDATA[$GLOBALS['sql_hex_for_binary']]]></code>
1474-
<code><![CDATA[$GLOBALS['sql_if_not_exists']]]></code>
1475-
<code><![CDATA[$GLOBALS['sql_ignore']]]></code>
1476-
<code><![CDATA[$GLOBALS['sql_insert_syntax']]]></code>
1477-
<code><![CDATA[$GLOBALS['sql_max_query_size']]]></code>
1478-
<code><![CDATA[$GLOBALS['sql_metadata']]]></code>
1479-
<code><![CDATA[$GLOBALS['sql_or_replace_view']]]></code>
1480-
<code><![CDATA[$GLOBALS['sql_procedure_function']]]></code>
1481-
<code><![CDATA[$GLOBALS['sql_simple_view_export']]]></code>
1482-
<code><![CDATA[$GLOBALS['sql_truncate']]]></code>
1483-
<code><![CDATA[$GLOBALS['sql_type']]]></code>
1484-
<code><![CDATA[$GLOBALS['sql_use_transaction']]]></code>
1485-
<code><![CDATA[$GLOBALS['sql_utc_time']]]></code>
1486-
<code><![CDATA[$GLOBALS['sql_view_current_user']]]></code>
1487-
<code><![CDATA[$GLOBALS['sql_views_as_tables']]]></code>
14881461
<code><![CDATA[$GLOBALS['table_data']]]></code>
14891462
<code><![CDATA[$GLOBALS['table_data']]]></code>
14901463
<code><![CDATA[$GLOBALS['table_select']]]></code>
14911464
<code><![CDATA[$GLOBALS['table_select']]]></code>
14921465
<code><![CDATA[$GLOBALS['time_start']]]></code>
14931466
<code><![CDATA[$GLOBALS['xkana']]]></code>
1494-
<code><![CDATA[$GLOBALS['xml_export_contents']]]></code>
1495-
<code><![CDATA[$GLOBALS['xml_export_events']]]></code>
1496-
<code><![CDATA[$GLOBALS['xml_export_functions']]]></code>
1497-
<code><![CDATA[$GLOBALS['xml_export_procedures']]]></code>
1498-
<code><![CDATA[$GLOBALS['xml_export_tables']]]></code>
1499-
<code><![CDATA[$GLOBALS['xml_export_triggers']]]></code>
1500-
<code><![CDATA[$GLOBALS['xml_export_views']]]></code>
15011467
<code><![CDATA[$dbSelect]]></code>
15021468
<code><![CDATA[$tableNames]]></code>
15031469
<code><![CDATA[$tableStructure]]></code>
@@ -4884,17 +4850,6 @@
48844850
</DeprecatedMethod>
48854851
<InvalidArrayOffset>
48864852
<code><![CDATA[$GLOBALS['save_filename']]]></code>
4887-
<code><![CDATA[$GLOBALS['sql_create_table']]]></code>
4888-
<code><![CDATA[$GLOBALS['sql_create_table']]]></code>
4889-
<code><![CDATA[$GLOBALS['sql_create_trigger']]]></code>
4890-
<code><![CDATA[$GLOBALS['sql_create_trigger']]]></code>
4891-
<code><![CDATA[$GLOBALS['sql_create_view']]]></code>
4892-
<code><![CDATA[$GLOBALS['sql_create_view']]]></code>
4893-
<code><![CDATA[$GLOBALS['sql_create_view']]]></code>
4894-
<code><![CDATA[$GLOBALS['sql_metadata']]]></code>
4895-
<code><![CDATA[$GLOBALS['sql_metadata']]]></code>
4896-
<code><![CDATA[$GLOBALS['sql_procedure_function']]]></code>
4897-
<code><![CDATA[$GLOBALS['sql_procedure_function']]]></code>
48984853
<code><![CDATA[$GLOBALS['time_start']]]></code>
48994854
<code><![CDATA[$GLOBALS['xkana']]]></code>
49004855
</InvalidArrayOffset>
@@ -6895,9 +6850,6 @@
68956850
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
68966851
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
68976852
</DeprecatedMethod>
6898-
<NoValue>
6899-
<code><![CDATA[$format]]></code>
6900-
</NoValue>
69016853
<PossiblyNullArgument>
69026854
<code><![CDATA[$row[0]]]></code>
69036855
<code><![CDATA[$row[0]]]></code>
@@ -6907,12 +6859,6 @@
69076859
<PossiblyUnusedReturnValue>
69086860
<code><![CDATA[bool]]></code>
69096861
</PossiblyUnusedReturnValue>
6910-
<RedundantCast>
6911-
<code><![CDATA[(int) $GLOBALS['codegen_format']]]></code>
6912-
</RedundantCast>
6913-
<RedundantCondition>
6914-
<code><![CDATA[$format === self::HANDLER_NHIBERNATE_XML]]></code>
6915-
</RedundantCondition>
69166862
</file>
69176863
<file src="src/Plugins/Export/ExportCsv.php">
69186864
<DeprecatedMethod>
@@ -7217,34 +7163,16 @@
72177163
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
72187164
</DeprecatedMethod>
72197165
<InvalidArrayOffset>
7166+
<code><![CDATA[$GLOBALS['exporting_metadata']]]></code>
72207167
<code><![CDATA[$GLOBALS['no_constraints_comments']]]></code>
72217168
<code><![CDATA[$GLOBALS['no_constraints_comments']]]></code>
7222-
<code><![CDATA[$GLOBALS['sql_auto_increment']]]></code>
7223-
<code><![CDATA[$GLOBALS['sql_create_database']]]></code>
7224-
<code><![CDATA[$GLOBALS['sql_delayed']]]></code>
7225-
<code><![CDATA[$GLOBALS['sql_disable_fk']]]></code>
7226-
<code><![CDATA[$GLOBALS['sql_disable_fk']]]></code>
7227-
<code><![CDATA[$GLOBALS['sql_drop_database']]]></code>
7228-
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
7229-
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
7230-
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
7231-
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
7232-
<code><![CDATA[$GLOBALS['sql_header_comment']]]></code>
7233-
<code><![CDATA[$GLOBALS['sql_indexes_query']]]></code>
7234-
<code><![CDATA[$GLOBALS['sql_or_replace_view']]]></code>
7235-
<code><![CDATA[$GLOBALS['sql_simple_view_export']]]></code>
7236-
<code><![CDATA[$GLOBALS['sql_truncate']]]></code>
7237-
<code><![CDATA[$GLOBALS['sql_use_transaction']]]></code>
7238-
<code><![CDATA[$GLOBALS['sql_use_transaction']]]></code>
7239-
<code><![CDATA[$GLOBALS['sql_utc_time']]]></code>
7240-
<code><![CDATA[$GLOBALS['sql_utc_time']]]></code>
7241-
<code><![CDATA[$GLOBALS['sql_view_current_user']]]></code>
7242-
<code><![CDATA[$GLOBALS['sql_views_as_tables']]]></code>
7243-
<code><![CDATA[$GLOBALS['sql_views_as_tables']]]></code>
72447169
<code><![CDATA[$GLOBALS['table_data']]]></code>
72457170
</InvalidArrayOffset>
7171+
<LessSpecificReturnStatement>
7172+
<code><![CDATA[(int) $fromConfig]]></code>
7173+
<code><![CDATA[(int) $fromRequest]]></code>
7174+
</LessSpecificReturnStatement>
72467175
<MixedArgument>
7247-
<code><![CDATA[$GLOBALS['sql_header_comment']]]></code>
72487176
<code><![CDATA[$GLOBALS['table_data']]]></code>
72497177
<code><![CDATA[$colAlias]]></code>
72507178
<code><![CDATA[$colAlias]]></code>
@@ -7267,8 +7195,6 @@
72677195
<code><![CDATA[$row[$j]]]></code>
72687196
</MixedArrayTypeCoercion>
72697197
<MixedAssignment>
7270-
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
7271-
<code><![CDATA[$GLOBALS['sql_indexes_query']]]></code>
72727198
<code><![CDATA[$colAlias]]></code>
72737199
<code><![CDATA[$colAlias]]></code>
72747200
<code><![CDATA[$colAs]]></code>
@@ -7292,6 +7218,9 @@
72927218
<code><![CDATA[$field->key->columns]]></code>
72937219
<code><![CDATA[$field->references->columns]]></code>
72947220
</MixedPropertyTypeCoercion>
7221+
<MoreSpecificReturnType>
7222+
<code><![CDATA[int<0, max>]]></code>
7223+
</MoreSpecificReturnType>
72957224
<PossiblyNullArgument>
72967225
<code><![CDATA[$createQuery]]></code>
72977226
<code><![CDATA[$definition]]></code>
@@ -7330,14 +7259,9 @@
73307259
</PossiblyNullReference>
73317260
<PossiblyUnusedReturnValue>
73327261
<code><![CDATA[bool]]></code>
7262+
<code><![CDATA[bool]]></code>
73337263
</PossiblyUnusedReturnValue>
73347264
<RiskyTruthyFalsyComparison>
7335-
<code><![CDATA[empty($GLOBALS['exporting_metadata'])]]></code>
7336-
<code><![CDATA[empty($GLOBALS['sql_auto_increment'])]]></code>
7337-
<code><![CDATA[empty($GLOBALS['sql_drop_table'])]]></code>
7338-
<code><![CDATA[empty($GLOBALS['sql_drop_table'])]]></code>
7339-
<code><![CDATA[empty($GLOBALS['sql_drop_table'])]]></code>
7340-
<code><![CDATA[empty($GLOBALS['sql_views_as_tables'])]]></code>
73417265
<code><![CDATA[empty($column->collation)]]></code>
73427266
<code><![CDATA[empty($config->selectedServer['port'])]]></code>
73437267
<code><![CDATA[empty($delimiter)]]></code>
@@ -7349,9 +7273,6 @@
73497273
<code><![CDATA[empty($tmpres['Create_time'])]]></code>
73507274
<code><![CDATA[empty($tmpres['Update_time'])]]></code>
73517275
</RiskyTruthyFalsyComparison>
7352-
<TypeDoesNotContainType>
7353-
<code><![CDATA[$GLOBALS['sql_type'] !== 'UPDATE']]></code>
7354-
</TypeDoesNotContainType>
73557276
<UnnecessaryVarAnnotation>
73567277
<code><![CDATA[CreateDefinition]]></code>
73577278
</UnnecessaryVarAnnotation>
@@ -7404,19 +7325,6 @@
74047325
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
74057326
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
74067327
</DeprecatedMethod>
7407-
<InvalidArrayOffset>
7408-
<code><![CDATA[$GLOBALS['xml_export_contents']]]></code>
7409-
<code><![CDATA[$GLOBALS['xml_export_contents']]]></code>
7410-
<code><![CDATA[$GLOBALS['xml_export_contents']]]></code>
7411-
<code><![CDATA[$GLOBALS['xml_export_contents']]]></code>
7412-
<code><![CDATA[$GLOBALS['xml_export_events']]]></code>
7413-
<code><![CDATA[$GLOBALS['xml_export_functions']]]></code>
7414-
<code><![CDATA[$GLOBALS['xml_export_functions']]]></code>
7415-
<code><![CDATA[$GLOBALS['xml_export_procedures']]]></code>
7416-
<code><![CDATA[$GLOBALS['xml_export_procedures']]]></code>
7417-
<code><![CDATA[$GLOBALS['xml_export_tables']]]></code>
7418-
<code><![CDATA[$GLOBALS['xml_export_tables']]]></code>
7419-
</InvalidArrayOffset>
74207328
<MixedArgument>
74217329
<code><![CDATA[$colAs]]></code>
74227330
<code><![CDATA[$dbCharset]]></code>
@@ -13468,9 +13376,6 @@
1346813376
<code><![CDATA[Config::getInstance()]]></code>
1346913377
<code><![CDATA[Config::getInstance()]]></code>
1347013378
</DeprecatedMethod>
13471-
<InvalidArrayOffset>
13472-
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
13473-
</InvalidArrayOffset>
1347413379
<MixedAssignment>
1347513380
<code><![CDATA[$isDefineProperty]]></code>
1347613381
<code><![CDATA[$sql]]></code>

psalm.xml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
cached_affected_rows: int|numeric-string,
4545
charset: string,
4646
charset_connection: string,
47-
codegen_format: 0|1,
4847
collation_connection: string,
4948
complete_query: string,
5049
compression: 'none'|'zip'|'gzip',
@@ -85,21 +84,10 @@
8584
save_on_server: bool,
8685
SESSION_KEY: string,
8786
showtable: array&lt;string, string|null&gt;,
88-
sql_compatibility: 'NONE'|'ANSI'|'DB2'|'MAXDB'|'MYSQL323'|'MYSQL40'|'MSSQL'|'ORACLE'|'TRADITIONAL',
89-
sql_constraints: string,
90-
sql_constraints_query: string,
91-
sql_drop_foreign_keys: string,
92-
sql_if_not_exists: bool,
93-
sql_ignore: bool,
94-
sql_insert_syntax: 'complete'|'extended'|'both'|'none',
95-
sql_max_query_size: 0|positive-int,
96-
sql_type: 'INSERT'|'UPDATE'|'REPLACE',
9787
tbl_storage_engine: string,
9888
token_mismatch: bool,
9989
token_provided: bool,
100-
username: string,
101-
xml_export_triggers: bool,
102-
xml_export_views: bool
90+
username: string
10391
}"/>
10492
</globals>
10593
</psalm>

0 commit comments

Comments
 (0)