Skip to content

Commit 1258b2c

Browse files
committed
Fix PHPStan iterable type errors in LocalizationFinder, AutoRouteCollector and Modules; clean baseline (#8732)
1 parent dd9d4b2 commit 1258b2c

File tree

4 files changed

+20
-38
lines changed

4 files changed

+20
-38
lines changed

system/Commands/Translation/LocalizationFinder.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@ private function replaceArraySyntax(string $code): string
304304

305305
/**
306306
* Create multidimensional array from another keys
307+
*
308+
* @param array<int,string> $fromKeys List of keys to build nested array
309+
* @param string $lastArrayValue Value to assign at the deepest key
310+
*
311+
* @return array<string,mixed> Multidimensional associative array
307312
*/
308313
private function buildMultiArray(array $fromKeys, string $lastArrayValue = ''): array
309314
{
@@ -323,6 +328,10 @@ private function buildMultiArray(array $fromKeys, string $lastArrayValue = ''):
323328

324329
/**
325330
* Convert multi arrays to specific CLI table rows (flat array)
331+
*
332+
* @param array<int,mixed> $array Input translations (nested array or strings)
333+
*
334+
* @return array<int,array{0:string,1:string}> Flat list of table rows [langFileNames, value]
326335
*/
327336
private function arrayToTableRows(string $langFileName, array $array): array
328337
{

system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ public function get(): array
9595
/**
9696
* Adding Filters
9797
*
98-
* @param list<array<string, array|string>> $routes
98+
* @param array<int,array<string,string|array<string>>> $routes List of route definitions
99+
*
100+
* @return array<int,array<string,string|array<string>>> $Updated route definitions with filters
99101
*
100-
* @return list<array<string, array|string>>
101102
*/
102103
private function addFilters(array $routes): array
103104
{

system/Modules/Modules.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ public function shouldDiscover(string $alias): bool
6060
return in_array(strtolower($alias), $this->aliases, true);
6161
}
6262

63+
/**
64+
* Restores the state of the object when exported with var_export()
65+
*
66+
* @param array<string,mixed> $array Properties and their values
67+
*
68+
* @return static
69+
*/
6370
public static function __set_state(array $array)
6471
{
6572
$obj = new static();

utils/phpstan-baseline/missingType.iterableValue.neon

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 1209 errors
1+
# total 1200 errors
22

33
parameters:
44
ignoreErrors:
@@ -207,26 +207,6 @@ parameters:
207207
count: 1
208208
path: ../../system/Commands/ListCommands.php
209209

210-
-
211-
message: '#^Method CodeIgniter\\Commands\\Translation\\LocalizationFinder\:\:arrayToTableRows\(\) has parameter \$array with no value type specified in iterable type array\.$#'
212-
count: 1
213-
path: ../../system/Commands/Translation/LocalizationFinder.php
214-
215-
-
216-
message: '#^Method CodeIgniter\\Commands\\Translation\\LocalizationFinder\:\:arrayToTableRows\(\) return type has no value type specified in iterable type array\.$#'
217-
count: 1
218-
path: ../../system/Commands/Translation/LocalizationFinder.php
219-
220-
-
221-
message: '#^Method CodeIgniter\\Commands\\Translation\\LocalizationFinder\:\:buildMultiArray\(\) has parameter \$fromKeys with no value type specified in iterable type array\.$#'
222-
count: 1
223-
path: ../../system/Commands/Translation/LocalizationFinder.php
224-
225-
-
226-
message: '#^Method CodeIgniter\\Commands\\Translation\\LocalizationFinder\:\:buildMultiArray\(\) return type has no value type specified in iterable type array\.$#'
227-
count: 1
228-
path: ../../system/Commands/Translation/LocalizationFinder.php
229-
230210
-
231211
message: '#^Method CodeIgniter\\Commands\\Translation\\LocalizationFinder\:\:findTranslationsInFile\(\) return type has no value type specified in iterable type array\.$#'
232212
count: 1
@@ -257,16 +237,6 @@ parameters:
257237
count: 1
258238
path: ../../system/Commands/Utilities/Namespaces.php
259239

260-
-
261-
message: '#^Method CodeIgniter\\Commands\\Utilities\\Routes\\AutoRouterImproved\\AutoRouteCollector\:\:addFilters\(\) has parameter \$routes with no value type specified in iterable type array\.$#'
262-
count: 1
263-
path: ../../system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php
264-
265-
-
266-
message: '#^Method CodeIgniter\\Commands\\Utilities\\Routes\\AutoRouterImproved\\AutoRouteCollector\:\:addFilters\(\) return type has no value type specified in iterable type array\.$#'
267-
count: 1
268-
path: ../../system/Commands/Utilities/Routes/AutoRouterImproved/AutoRouteCollector.php
269-
270240
-
271241
message: '#^Method CodeIgniter\\Commands\\Utilities\\Routes\\AutoRouterImproved\\AutoRouteCollector\:\:generateSampleUri\(\) has parameter \$route with no value type specified in iterable type array\.$#'
272242
count: 1
@@ -4127,11 +4097,6 @@ parameters:
41274097
count: 1
41284098
path: ../../system/Model.php
41294099

4130-
-
4131-
message: '#^Method CodeIgniter\\Modules\\Modules\:\:__set_state\(\) has parameter \$array with no value type specified in iterable type array\.$#'
4132-
count: 1
4133-
path: ../../system/Modules/Modules.php
4134-
41354100
-
41364101
message: '#^Method CodeIgniter\\Pager\\Pager\:\:getDetails\(\) return type has no value type specified in iterable type array\.$#'
41374102
count: 1

0 commit comments

Comments
 (0)