Skip to content

Commit

Permalink
Extract privileges globals to static props of UserPrivileges class
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Jan 5, 2024
1 parent a5850a0 commit 4fefea4
Show file tree
Hide file tree
Showing 29 changed files with 233 additions and 176 deletions.
68 changes: 49 additions & 19 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,6 @@ parameters:
count: 1
path: src/Charsets.php

-
message: "#^Cannot access an offset on mixed\\.$#"
count: 1
path: src/CheckUserPrivileges.php

-
message: "#^Only booleans are allowed in a negated boolean, PhpMyAdmin\\\\Dbal\\\\ResultInterface\\|false given\\.$#"
count: 1
Expand All @@ -215,6 +210,51 @@ parameters:
count: 1
path: src/CheckUserPrivileges.php

-
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$column \\(bool\\) does not accept mixed\\.$#"
count: 1
path: src/CheckUserPrivileges.php

-
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$database \\(bool\\) does not accept mixed\\.$#"
count: 1
path: src/CheckUserPrivileges.php

-
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$databaseToCreate \\(string\\) does not accept mixed\\.$#"
count: 1
path: src/CheckUserPrivileges.php

-
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$databaseToCreate \\(string\\) does not accept string\\|null\\.$#"
count: 2
path: src/CheckUserPrivileges.php

-
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$databasesToTest \\(array\\<string\\>\\|false\\) does not accept mixed\\.$#"
count: 2
path: src/CheckUserPrivileges.php

-
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$isCreateDatabase \\(bool\\) does not accept mixed\\.$#"
count: 1
path: src/CheckUserPrivileges.php

-
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$isReload \\(bool\\) does not accept mixed\\.$#"
count: 1
path: src/CheckUserPrivileges.php

-
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$routines \\(bool\\) does not accept mixed\\.$#"
count: 1
path: src/CheckUserPrivileges.php

-
message: "#^Static property PhpMyAdmin\\\\UserPrivileges\\:\\:\\$table \\(bool\\) does not accept mixed\\.$#"
count: 1
path: src/CheckUserPrivileges.php

-
message: "#^Parameter \\#1 \\$source of method PhpMyAdmin\\\\Config\\:\\:loadAndCheck\\(\\) expects string\\|null, mixed given\\.$#"
count: 1
Expand Down Expand Up @@ -9845,11 +9885,6 @@ parameters:
count: 1
path: src/Linter.php

-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
count: 1
path: src/ListDatabase.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
Expand All @@ -9865,11 +9900,6 @@ parameters:
count: 1
path: src/ListDatabase.php

-
message: "#^Parameter \\#1 \\$likeDbName of method PhpMyAdmin\\\\ListDatabase\\:\\:retrieve\\(\\) expects string\\|null, mixed given\\.$#"
count: 1
path: src/ListDatabase.php

-
message: "#^Parameter \\#1 \\$str of function strtr expects string, array\\<string\\>\\|bool\\|int\\<0, max\\>\\|string given\\.$#"
count: 1
Expand Down Expand Up @@ -9982,7 +10012,7 @@ parameters:

-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
count: 2
count: 1
path: src/Navigation/NavigationTree.php

-
Expand Down Expand Up @@ -10157,11 +10187,11 @@ parameters:

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 5
count: 4
path: src/Navigation/Nodes/Node.php

-
message: "#^Method PhpMyAdmin\\\\Navigation\\\\Nodes\\\\Node\\:\\:getDatabasesToSearch\\(\\) should return array but returns mixed\\.$#"
message: "#^Method PhpMyAdmin\\\\Navigation\\\\Nodes\\\\Node\\:\\:getDatabasesToSearch\\(\\) should return array but returns array\\<string\\>\\|string\\.$#"
count: 1
path: src/Navigation/Nodes/Node.php

Expand All @@ -10171,7 +10201,7 @@ parameters:
path: src/Navigation/Nodes/Node.php

-
message: "#^Parameter \\#1 \\$array of function sort expects TArray of array\\<T\\>, mixed given\\.$#"
message: "#^Parameter \\#1 \\$array of function sort expects TArray of array\\<string\\>, array\\<string\\>\\|string given\\.$#"
count: 1
path: src/Navigation/Nodes/Node.php

Expand Down
23 changes: 10 additions & 13 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@
</file>
<file src="src/CheckUserPrivileges.php">
<MixedAssignment>
<code><![CDATA[$GLOBALS['col_priv']]]></code>
<code><![CDATA[$GLOBALS['db_priv']]]></code>
<code><![CDATA[$GLOBALS['db_to_create']]]></code>
<code><![CDATA[$GLOBALS['dbs_to_test']]]></code>
<code><![CDATA[$GLOBALS['is_create_db_priv']]]></code>
<code><![CDATA[$GLOBALS['is_reload_priv']]]></code>
<code><![CDATA[$GLOBALS['proc_priv']]]></code>
<code><![CDATA[$GLOBALS['table_priv']]]></code>
<code>UserPrivileges::$column</code>
<code>UserPrivileges::$database</code>
<code>UserPrivileges::$databaseToCreate</code>
<code>UserPrivileges::$databasesToTest</code>
<code>UserPrivileges::$isCreateDatabase</code>
<code>UserPrivileges::$isReload</code>
<code>UserPrivileges::$routines</code>
<code>UserPrivileges::$table</code>
</MixedAssignment>
</file>
<file src="src/Command/CacheWarmupCommand.php">
Expand Down Expand Up @@ -2674,7 +2674,6 @@
<code>Config::getInstance()</code>
</DeprecatedMethod>
<InvalidArrayOffset>
<code><![CDATA[$GLOBALS['db_to_create']]]></code>
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
</InvalidArrayOffset>
<MixedArgument>
Expand Down Expand Up @@ -2716,7 +2715,6 @@
<code><![CDATA[$databases[$database['SCHEMA_NAME']]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code><![CDATA[$GLOBALS['db_to_create']]]></code>
<code><![CDATA[$GLOBALS['errorUrl']]]></code>
<code>$database</code>
<code>$key</code>
Expand Down Expand Up @@ -7246,22 +7244,21 @@
<code>DatabaseInterface::getInstance()</code>
</DeprecatedMethod>
<MixedArgument>
<code>$databases</code>
<code>$db</code>
<code>$db</code>
<code>$db</code>
<code>$db</code>
<code>$db</code>
</MixedArgument>
<MixedAssignment>
<code>$databases</code>
<code>$db</code>
<code>$db</code>
<code>$db</code>
<code>$db</code>
<code>$db</code>
</MixedAssignment>
<PossiblyInvalidArgument>
<code>$databases</code>
</PossiblyInvalidArgument>
<PossiblyNullArgument>
<code>$arr[0]</code>
<code>$arr[0]</code>
Expand Down
7 changes: 0 additions & 7 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
charset: string,
charset_connection: string,
codegen_format: 0|1,
col_priv: bool,
collation_connection: string,
complete_query: string,
compression: 'none'|'zip'|'gzip',
Expand All @@ -56,8 +55,6 @@
csv_escaped: string,
csv_separator: string,
csv_terminated: string,
db_priv: bool,
dbs_to_test: string[]|false,
display_query: string,
errno: int,
error: bool,
Expand All @@ -71,8 +68,6 @@
import_file: string,
import_file_name: string,
import_text: string,
is_create_db_priv: bool,
is_reload_priv: bool,
knjenc: string,
lang: string,
latex_data_caption: string,
Expand All @@ -97,7 +92,6 @@
plugin_scripts: string[],
pma_auth_server: string,
PMA_PHP_SELF: string,
proc_priv: bool,
querytime: float|int,
read_limit: int,
save_on_server: bool,
Expand All @@ -114,7 +108,6 @@
sql_query: string,
sql_structure_or_data: 'structure'|'data'|'structure_and_data',
sql_type: 'INSERT'|'UPDATE'|'REPLACE',
table_priv: bool,
tbl_storage_engine: string,
token_mismatch: bool,
token_provided: bool,
Expand Down

0 comments on commit 4fefea4

Please sign in to comment.