Skip to content

Commit

Permalink
Add better type description to Index::$registry
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 Sep 7, 2022
1 parent ec9af1b commit e9d742f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion libraries/classes/Index.php
Expand Up @@ -24,7 +24,7 @@ class Index
/**
* Class-wide storage container for indexes (caching, singleton)
*
* @var array
* @var array<string, array<string, array<string, Index>>>
*/
private static $registry = [];

Expand Down
17 changes: 16 additions & 1 deletion phpstan-baseline.neon
Expand Up @@ -4241,7 +4241,7 @@ parameters:
path: libraries/classes/Index.php

-
message: "#^Property PhpMyAdmin\\\\Index\\:\\:\\$registry type has no value type specified in iterable type array\\.$#"
message: "#^Static property PhpMyAdmin\\\\Index\\:\\:\\$registry \\(array\\<string, array\\<string, array\\<string, PhpMyAdmin\\\\Index\\>\\>\\>\\) does not accept array\\<string, array\\<string, array\\<int\\|string, PhpMyAdmin\\\\Index\\>\\>\\>\\.$#"
count: 1
path: libraries/classes/Index.php

Expand Down Expand Up @@ -5850,6 +5850,11 @@ parameters:
count: 1
path: libraries/classes/Plugins/Import/ImportSql.php

-
message: "#^Cannot assign new offset to array\\<int, array\\<int, string\\>\\|string\\>\\|string\\.$#"
count: 1
path: libraries/classes/Plugins/Import/ImportXml.php

-
message: "#^Offset 'charset' does not exist on SimpleXMLElement\\|null\\.$#"
count: 1
Expand All @@ -5865,6 +5870,16 @@ parameters:
count: 8
path: libraries/classes/Plugins/Import/ImportXml.php

-
message: "#^Parameter \\#1 \\$str1 of function strcmp expects string, array\\<int, array\\<int, string\\>\\|string\\>\\|string given\\.$#"
count: 1
path: libraries/classes/Plugins/Import/ImportXml.php

-
message: "#^array\\<int, array\\<int, string\\>\\|string\\>\\|string does not accept array\\<int, string\\>\\.$#"
count: 1
path: libraries/classes/Plugins/Import/ImportXml.php

-
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Import\\\\Upload\\\\UploadNoplugin\\:\\:getUploadStatus\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down
29 changes: 8 additions & 21 deletions psalm-baseline.xml
Expand Up @@ -7726,28 +7726,23 @@
<code>$key</code>
<code>$params['columns']</code>
</MixedArgument>
<MixedArrayAccess occurrences="2">
<MixedArrayAccess occurrences="1">
<code>$_each_index['Key_name']</code>
<code>self::$registry[$schema][$table][$keyName]</code>
</MixedArrayAccess>
<MixedArrayAssignment occurrences="3">
<MixedArrayAssignment occurrences="1">
<code>$_each_index['Schema']</code>
<code>self::$registry[$schema][$table]</code>
<code>self::$registry[$schema][$table]</code>
</MixedArrayAssignment>
<MixedArrayOffset occurrences="4">
<MixedArrayOffset occurrences="3">
<code>$columns['sub_parts'][$key]</code>
<code>self::$registry[$schema][$table][$keyName]</code>
<code>self::$registry[$schema][$table][$keyName]</code>
<code>self::$registry[$schema][$table][$keyName]</code>
</MixedArrayOffset>
<MixedAssignment occurrences="20">
<MixedAssignment occurrences="19">
<code>$column</code>
<code>$column</code>
<code>$data['columns'][]</code>
<code>$key</code>
<code>$key</code>
<code>$key</code>
<code>$keyName</code>
<code>$name</code>
<code>$sub_part</code>
Expand All @@ -7763,23 +7758,15 @@
<code>$this-&gt;table</code>
<code>$this-&gt;type</code>
</MixedAssignment>
<MixedInferredReturnType occurrences="3">
<code>Index</code>
<code>Index[]</code>
<code>Index|false</code>
</MixedInferredReturnType>
<MixedMethodCall occurrences="2">
<code>addColumn</code>
<MixedMethodCall occurrences="1">
<code>getCompareData</code>
</MixedMethodCall>
<MixedOperand occurrences="1">
<code>$key</code>
</MixedOperand>
<MixedReturnStatement occurrences="3">
<code>self::$registry[$schema][$table]</code>
<code>self::$registry[$schema][$table][$index_name]</code>
<code>self::$registry[$schema][$table]['PRIMARY']</code>
</MixedReturnStatement>
<MixedPropertyTypeCoercion occurrences="1">
<code>self::$registry</code>
</MixedPropertyTypeCoercion>
<MixedReturnTypeCoercion occurrences="2">
<code>$this-&gt;columns</code>
<code>IndexColumn[]</code>
Expand Down

0 comments on commit e9d742f

Please sign in to comment.