Skip to content

Commit

Permalink
Merge pull request phpmyadmin#19464 from MauricioFauth/export-globals
Browse files Browse the repository at this point in the history
Remove some global variables from export plugins
  • Loading branch information
MauricioFauth authored Dec 21, 2024
2 parents 8e72191 + 75d11f9 commit c30bc4d
Show file tree
Hide file tree
Showing 15 changed files with 481 additions and 606 deletions.
64 changes: 8 additions & 56 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11853,12 +11853,6 @@ parameters:
count: 2
path: src/Plugins/Export/ExportCodegen.php

-
message: '#^Cannot cast mixed to int\.$#'
identifier: cast.int
count: 1
path: src/Plugins/Export/ExportCodegen.php

-
message: '#^Parameter \#1 \$str of static method PhpMyAdmin\\Plugins\\Export\\ExportCodegen\:\:cgMakeIdentifier\(\) expects string, string\|null given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -12435,12 +12429,6 @@ parameters:
count: 1
path: src/Plugins/Export/ExportPhparray.php

-
message: '#^Binary operation "\." between ''SET SQL_MODE\="'' and mixed results in an error\.$#'
identifier: binaryOp.invalid
count: 1
path: src/Plugins/Export/ExportSql.php

-
message: '#^Binary operation "\." between ''SET time_zone \= "'' and mixed results in an error\.$#'
identifier: binaryOp.invalid
Expand Down Expand Up @@ -12570,7 +12558,7 @@ parameters:
-
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
identifier: empty.notAllowed
count: 41
count: 27
path: src/Plugins/Export/ExportSql.php

-
Expand All @@ -12585,6 +12573,12 @@ parameters:
count: 1
path: src/Plugins/Export/ExportSql.php

-
message: '#^Method PhpMyAdmin\\Plugins\\Export\\ExportSql\:\:setMaxQuerySize\(\) should return int\<0, max\> but returns int\.$#'
identifier: return.type
count: 2
path: src/Plugins/Export/ExportSql.php

-
message: '#^Only booleans are allowed in &&, bool\|null given on the left side\.$#'
identifier: booleanAnd.leftNotBoolean
Expand All @@ -12597,12 +12591,6 @@ parameters:
count: 1
path: src/Plugins/Export/ExportSql.php

-
message: '#^Only booleans are allowed in &&, mixed given on the right side\.$#'
identifier: booleanAnd.rightNotBoolean
count: 4
path: src/Plugins/Export/ExportSql.php

-
message: '#^Only booleans are allowed in an if condition, bool\|null given\.$#'
identifier: if.condNotBoolean
Expand Down Expand Up @@ -12639,18 +12627,6 @@ parameters:
count: 5
path: src/Plugins/Export/ExportSql.php

-
message: '#^Parameter \#2 \$compat of method PhpMyAdmin\\Plugins\\Export\\ExportSql\:\:exportUseStatement\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 2
path: src/Plugins/Export/ExportSql.php

-
message: '#^Parameter \#2 \$compatibility of static method PhpMyAdmin\\Util\:\:backquoteCompat\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 13
path: src/Plugins/Export/ExportSql.php

-
message: '#^Parameter \#2 \$haystack of function in_array expects array, mixed given\.$#'
identifier: argument.type
Expand All @@ -12669,12 +12645,6 @@ parameters:
count: 2
path: src/Plugins/Export/ExportSql.php

-
message: '#^Parameter \#2 \$string of function explode expects string, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Plugins/Export/ExportSql.php

-
message: '#^Parameter \#3 \$name of static method PhpMyAdmin\\Database\\Events\:\:getDefinition\(\) expects string, mixed given\.$#'
identifier: argument.type
Expand All @@ -12699,12 +12669,6 @@ parameters:
count: 3
path: src/Plugins/Export/ExportSql.php

-
message: '#^Parameter \#5 \$compat of method PhpMyAdmin\\Plugins\\Export\\ExportSql\:\:generateComment\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 3
path: src/Plugins/Export/ExportSql.php

-
message: '#^Property PhpMyAdmin\\SqlParser\\Components\\CreateDefinition\:\:\$name \(string\|null\) does not accept mixed\.$#'
identifier: assign.propertyType
Expand Down Expand Up @@ -12852,18 +12816,6 @@ parameters:
count: 1
path: src/Plugins/Export/ExportXml.php

-
message: '#^Only booleans are allowed in &&, mixed given on the right side\.$#'
identifier: booleanAnd.rightNotBoolean
count: 6
path: src/Plugins/Export/ExportXml.php

-
message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#'
identifier: booleanNot.exprNotBoolean
count: 1
path: src/Plugins/Export/ExportXml.php

-
message: '#^Only booleans are allowed in a ternary operator condition, mixed given\.$#'
identifier: ternary.condNotBoolean
Expand Down Expand Up @@ -21753,7 +21705,7 @@ parameters:
-
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertStringContainsString\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 4
count: 2
path: tests/unit/Plugins/Export/ExportSqlTest.php

-
Expand Down
113 changes: 9 additions & 104 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,6 @@
</MixedArrayAssignment>
<MixedAssignment>
<code><![CDATA[$GLOBALS['charset']]]></code>
<code><![CDATA[$GLOBALS['codegen_format']]]></code>
<code><![CDATA[$GLOBALS['compression']]]></code>
<code><![CDATA[$GLOBALS['csv_columns']]]></code>
<code><![CDATA[$GLOBALS['csv_enclosed']]]></code>
Expand All @@ -1459,45 +1458,12 @@
<code><![CDATA[$GLOBALS['save_filename']]]></code>
<code><![CDATA[$GLOBALS['single_table']]]></code>
<code><![CDATA[$GLOBALS['single_table']]]></code>
<code><![CDATA[$GLOBALS['sql_auto_increment']]]></code>
<code><![CDATA[$GLOBALS['sql_compatibility']]]></code>
<code><![CDATA[$GLOBALS['sql_create_database']]]></code>
<code><![CDATA[$GLOBALS['sql_create_table']]]></code>
<code><![CDATA[$GLOBALS['sql_create_trigger']]]></code>
<code><![CDATA[$GLOBALS['sql_create_view']]]></code>
<code><![CDATA[$GLOBALS['sql_delayed']]]></code>
<code><![CDATA[$GLOBALS['sql_disable_fk']]]></code>
<code><![CDATA[$GLOBALS['sql_drop_database']]]></code>
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
<code><![CDATA[$GLOBALS['sql_header_comment']]]></code>
<code><![CDATA[$GLOBALS['sql_hex_for_binary']]]></code>
<code><![CDATA[$GLOBALS['sql_if_not_exists']]]></code>
<code><![CDATA[$GLOBALS['sql_ignore']]]></code>
<code><![CDATA[$GLOBALS['sql_insert_syntax']]]></code>
<code><![CDATA[$GLOBALS['sql_max_query_size']]]></code>
<code><![CDATA[$GLOBALS['sql_metadata']]]></code>
<code><![CDATA[$GLOBALS['sql_or_replace_view']]]></code>
<code><![CDATA[$GLOBALS['sql_procedure_function']]]></code>
<code><![CDATA[$GLOBALS['sql_simple_view_export']]]></code>
<code><![CDATA[$GLOBALS['sql_truncate']]]></code>
<code><![CDATA[$GLOBALS['sql_type']]]></code>
<code><![CDATA[$GLOBALS['sql_use_transaction']]]></code>
<code><![CDATA[$GLOBALS['sql_utc_time']]]></code>
<code><![CDATA[$GLOBALS['sql_view_current_user']]]></code>
<code><![CDATA[$GLOBALS['sql_views_as_tables']]]></code>
<code><![CDATA[$GLOBALS['table_data']]]></code>
<code><![CDATA[$GLOBALS['table_data']]]></code>
<code><![CDATA[$GLOBALS['table_select']]]></code>
<code><![CDATA[$GLOBALS['table_select']]]></code>
<code><![CDATA[$GLOBALS['time_start']]]></code>
<code><![CDATA[$GLOBALS['xkana']]]></code>
<code><![CDATA[$GLOBALS['xml_export_contents']]]></code>
<code><![CDATA[$GLOBALS['xml_export_events']]]></code>
<code><![CDATA[$GLOBALS['xml_export_functions']]]></code>
<code><![CDATA[$GLOBALS['xml_export_procedures']]]></code>
<code><![CDATA[$GLOBALS['xml_export_tables']]]></code>
<code><![CDATA[$GLOBALS['xml_export_triggers']]]></code>
<code><![CDATA[$GLOBALS['xml_export_views']]]></code>
<code><![CDATA[$dbSelect]]></code>
<code><![CDATA[$tableNames]]></code>
<code><![CDATA[$tableStructure]]></code>
Expand Down Expand Up @@ -4884,17 +4850,6 @@
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['save_filename']]]></code>
<code><![CDATA[$GLOBALS['sql_create_table']]]></code>
<code><![CDATA[$GLOBALS['sql_create_table']]]></code>
<code><![CDATA[$GLOBALS['sql_create_trigger']]]></code>
<code><![CDATA[$GLOBALS['sql_create_trigger']]]></code>
<code><![CDATA[$GLOBALS['sql_create_view']]]></code>
<code><![CDATA[$GLOBALS['sql_create_view']]]></code>
<code><![CDATA[$GLOBALS['sql_create_view']]]></code>
<code><![CDATA[$GLOBALS['sql_metadata']]]></code>
<code><![CDATA[$GLOBALS['sql_metadata']]]></code>
<code><![CDATA[$GLOBALS['sql_procedure_function']]]></code>
<code><![CDATA[$GLOBALS['sql_procedure_function']]]></code>
<code><![CDATA[$GLOBALS['time_start']]]></code>
<code><![CDATA[$GLOBALS['xkana']]]></code>
</InvalidArrayOffset>
Expand Down Expand Up @@ -6895,9 +6850,6 @@
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
</DeprecatedMethod>
<NoValue>
<code><![CDATA[$format]]></code>
</NoValue>
<PossiblyNullArgument>
<code><![CDATA[$row[0]]]></code>
<code><![CDATA[$row[0]]]></code>
Expand All @@ -6907,12 +6859,6 @@
<PossiblyUnusedReturnValue>
<code><![CDATA[bool]]></code>
</PossiblyUnusedReturnValue>
<RedundantCast>
<code><![CDATA[(int) $GLOBALS['codegen_format']]]></code>
</RedundantCast>
<RedundantCondition>
<code><![CDATA[$format === self::HANDLER_NHIBERNATE_XML]]></code>
</RedundantCondition>
</file>
<file src="src/Plugins/Export/ExportCsv.php">
<DeprecatedMethod>
Expand Down Expand Up @@ -7217,34 +7163,16 @@
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['exporting_metadata']]]></code>
<code><![CDATA[$GLOBALS['no_constraints_comments']]]></code>
<code><![CDATA[$GLOBALS['no_constraints_comments']]]></code>
<code><![CDATA[$GLOBALS['sql_auto_increment']]]></code>
<code><![CDATA[$GLOBALS['sql_create_database']]]></code>
<code><![CDATA[$GLOBALS['sql_delayed']]]></code>
<code><![CDATA[$GLOBALS['sql_disable_fk']]]></code>
<code><![CDATA[$GLOBALS['sql_disable_fk']]]></code>
<code><![CDATA[$GLOBALS['sql_drop_database']]]></code>
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
<code><![CDATA[$GLOBALS['sql_header_comment']]]></code>
<code><![CDATA[$GLOBALS['sql_indexes_query']]]></code>
<code><![CDATA[$GLOBALS['sql_or_replace_view']]]></code>
<code><![CDATA[$GLOBALS['sql_simple_view_export']]]></code>
<code><![CDATA[$GLOBALS['sql_truncate']]]></code>
<code><![CDATA[$GLOBALS['sql_use_transaction']]]></code>
<code><![CDATA[$GLOBALS['sql_use_transaction']]]></code>
<code><![CDATA[$GLOBALS['sql_utc_time']]]></code>
<code><![CDATA[$GLOBALS['sql_utc_time']]]></code>
<code><![CDATA[$GLOBALS['sql_view_current_user']]]></code>
<code><![CDATA[$GLOBALS['sql_views_as_tables']]]></code>
<code><![CDATA[$GLOBALS['sql_views_as_tables']]]></code>
<code><![CDATA[$GLOBALS['table_data']]]></code>
</InvalidArrayOffset>
<LessSpecificReturnStatement>
<code><![CDATA[(int) $fromConfig]]></code>
<code><![CDATA[(int) $fromRequest]]></code>
</LessSpecificReturnStatement>
<MixedArgument>
<code><![CDATA[$GLOBALS['sql_header_comment']]]></code>
<code><![CDATA[$GLOBALS['table_data']]]></code>
<code><![CDATA[$colAlias]]></code>
<code><![CDATA[$colAlias]]></code>
Expand All @@ -7267,8 +7195,6 @@
<code><![CDATA[$row[$j]]]></code>
</MixedArrayTypeCoercion>
<MixedAssignment>
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
<code><![CDATA[$GLOBALS['sql_indexes_query']]]></code>
<code><![CDATA[$colAlias]]></code>
<code><![CDATA[$colAlias]]></code>
<code><![CDATA[$colAs]]></code>
Expand All @@ -7292,6 +7218,9 @@
<code><![CDATA[$field->key->columns]]></code>
<code><![CDATA[$field->references->columns]]></code>
</MixedPropertyTypeCoercion>
<MoreSpecificReturnType>
<code><![CDATA[int<0, max>]]></code>
</MoreSpecificReturnType>
<PossiblyNullArgument>
<code><![CDATA[$createQuery]]></code>
<code><![CDATA[$definition]]></code>
Expand Down Expand Up @@ -7330,14 +7259,9 @@
</PossiblyNullReference>
<PossiblyUnusedReturnValue>
<code><![CDATA[bool]]></code>
<code><![CDATA[bool]]></code>
</PossiblyUnusedReturnValue>
<RiskyTruthyFalsyComparison>
<code><![CDATA[empty($GLOBALS['exporting_metadata'])]]></code>
<code><![CDATA[empty($GLOBALS['sql_auto_increment'])]]></code>
<code><![CDATA[empty($GLOBALS['sql_drop_table'])]]></code>
<code><![CDATA[empty($GLOBALS['sql_drop_table'])]]></code>
<code><![CDATA[empty($GLOBALS['sql_drop_table'])]]></code>
<code><![CDATA[empty($GLOBALS['sql_views_as_tables'])]]></code>
<code><![CDATA[empty($column->collation)]]></code>
<code><![CDATA[empty($config->selectedServer['port'])]]></code>
<code><![CDATA[empty($delimiter)]]></code>
Expand All @@ -7349,9 +7273,6 @@
<code><![CDATA[empty($tmpres['Create_time'])]]></code>
<code><![CDATA[empty($tmpres['Update_time'])]]></code>
</RiskyTruthyFalsyComparison>
<TypeDoesNotContainType>
<code><![CDATA[$GLOBALS['sql_type'] !== 'UPDATE']]></code>
</TypeDoesNotContainType>
<UnnecessaryVarAnnotation>
<code><![CDATA[CreateDefinition]]></code>
</UnnecessaryVarAnnotation>
Expand Down Expand Up @@ -7404,19 +7325,6 @@
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['xml_export_contents']]]></code>
<code><![CDATA[$GLOBALS['xml_export_contents']]]></code>
<code><![CDATA[$GLOBALS['xml_export_contents']]]></code>
<code><![CDATA[$GLOBALS['xml_export_contents']]]></code>
<code><![CDATA[$GLOBALS['xml_export_events']]]></code>
<code><![CDATA[$GLOBALS['xml_export_functions']]]></code>
<code><![CDATA[$GLOBALS['xml_export_functions']]]></code>
<code><![CDATA[$GLOBALS['xml_export_procedures']]]></code>
<code><![CDATA[$GLOBALS['xml_export_procedures']]]></code>
<code><![CDATA[$GLOBALS['xml_export_tables']]]></code>
<code><![CDATA[$GLOBALS['xml_export_tables']]]></code>
</InvalidArrayOffset>
<MixedArgument>
<code><![CDATA[$colAs]]></code>
<code><![CDATA[$dbCharset]]></code>
Expand Down Expand Up @@ -13468,9 +13376,6 @@
<code><![CDATA[Config::getInstance()]]></code>
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['sql_drop_table']]]></code>
</InvalidArrayOffset>
<MixedAssignment>
<code><![CDATA[$isDefineProperty]]></code>
<code><![CDATA[$sql]]></code>
Expand Down
14 changes: 1 addition & 13 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
cached_affected_rows: int|numeric-string,
charset: string,
charset_connection: string,
codegen_format: 0|1,
collation_connection: string,
complete_query: string,
compression: 'none'|'zip'|'gzip',
Expand Down Expand Up @@ -85,21 +84,10 @@
save_on_server: bool,
SESSION_KEY: string,
showtable: array&lt;string, string|null&gt;,
sql_compatibility: 'NONE'|'ANSI'|'DB2'|'MAXDB'|'MYSQL323'|'MYSQL40'|'MSSQL'|'ORACLE'|'TRADITIONAL',
sql_constraints: string,
sql_constraints_query: string,
sql_drop_foreign_keys: string,
sql_if_not_exists: bool,
sql_ignore: bool,
sql_insert_syntax: 'complete'|'extended'|'both'|'none',
sql_max_query_size: 0|positive-int,
sql_type: 'INSERT'|'UPDATE'|'REPLACE',
tbl_storage_engine: string,
token_mismatch: bool,
token_provided: bool,
username: string,
xml_export_triggers: bool,
xml_export_views: bool
username: string
}"/>
</globals>
</psalm>
Loading

0 comments on commit c30bc4d

Please sign in to comment.