Skip to content

Commit e887557

Browse files
committed
Fix PHPStan iterable type errors in diferent files issue (#8732)
1 parent f5b9ac7 commit e887557

File tree

12 files changed

+43
-108
lines changed

12 files changed

+43
-108
lines changed

admin/framework/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"codeigniter/coding-standard": "^1.7",
2121
"fakerphp/faker": "^1.24",
2222
"friendsofphp/php-cs-fixer": "^3.47.1",
23-
"kint-php/kint": "^6.1",
23+
"kint-php/kint": "^6.0",
2424
"mikey179/vfsstream": "^1.6.12",
2525
"nexusphp/cs-config": "^3.6",
2626
"phpunit/phpunit": "^10.5.16 || ^11.2",

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"require-dev": {
2020
"codeigniter/phpstan-codeigniter": "1.x-dev",
2121
"fakerphp/faker": "^1.24",
22-
"kint-php/kint": "^6.1",
22+
"kint-php/kint": "^6.0",
2323
"mikey179/vfsstream": "^1.6.12",
2424
"nexusphp/tachycardia": "^2.0",
2525
"phpstan/extension-installer": "^1.4",

system/BaseModel.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ abstract protected function doFindColumn(string $columnName);
436436
* @param int|null $limit Limit
437437
* @param int $offset Offset
438438
*
439-
* @return array
439+
* @return array<int,array<int|string,bool|float|int|object|string|null>|object>
440440
*/
441441
abstract protected function doFindAll(?int $limit = null, int $offset = 0);
442442

@@ -629,7 +629,7 @@ public function find($id = null)
629629
*
630630
* @param string $columnName Column Name
631631
*
632-
* @return array|null The resulting row of data, or null if no data found.
632+
* @return array<int,mixed>|null The resulting row of data, or null if no data found.
633633
*
634634
* @throws DataException
635635
*/
@@ -650,7 +650,7 @@ public function findColumn(string $columnName)
650650
* @param int $limit Limit
651651
* @param int $offset Offset
652652
*
653-
* @return array
653+
* @return array<mixed>
654654
*/
655655
public function findAll(?int $limit = null, int $offset = 0)
656656
{
@@ -695,7 +695,7 @@ public function findAll(?int $limit = null, int $offset = 0)
695695
/**
696696
* Returns the first row of the result set.
697697
*
698-
* @return array|object|null
698+
* @return array<string,mixed>|object|null
699699
*/
700700
public function first()
701701
{
@@ -1593,9 +1593,10 @@ public function getValidationMessages(): array
15931593
* currently so that rules don't block updating when only updating
15941594
* a partial row.
15951595
*
1596-
* @param array $rules Array containing field name and rule
1597-
* @param array $row Row data (@TODO Remove null in param type)
1596+
* @param array<string,string> $rules
1597+
* @param array<string,mixed>|null $row
15981598
* @phpstan-param row_array $row
1599+
* @phpstan-return array<string,string>
15991600
*/
16001601
protected function cleanValidationRules(array $rules, ?array $row = null): array
16011602
{
@@ -1889,7 +1890,7 @@ protected function transformDataToArray($row, string $type): array
18891890
*
18901891
* @param string $name Name
18911892
*
1892-
* @return array|bool|float|int|object|string|null
1893+
* @return array<mixed>|bool|float|int|object|string|null
18931894
*/
18941895
public function __get(string $name)
18951896
{

system/CLI/CLI.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ public static function promptByMultipleKeys(string $text, array $options): array
374374

375375
/**
376376
* Validation for $options in promptByKey() and promptByMultipleKeys(). Return an error if $options is an empty array.
377+
*
378+
* @param array<int,string> $options List of options
379+
*
380+
* @return void
377381
*/
378382
private static function isZeroOptions(array $options): void
379383
{

system/Commands/ListCommands.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public function run(array $params)
8787

8888
/**
8989
* Lists the commands with accompanying info.
90+
*
91+
* @param array<string,array<string,string>> $commands Array of commands keyed by name, each with metadata
9092
*
9193
* @return int
9294
*/

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/Namespaces.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ public function run(array $params)
9191
CLI::table($tbody, $thead);
9292
}
9393

94+
/**
95+
* @param array{m:int,r?:mixed} $params
96+
*
97+
* @return array<int,array{0:string,1:string,2:string}>
98+
*/
9499
private function outputAllNamespaces(array $params): array
95100
{
96101
$maxLength = $params['m'];

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/Config/BaseService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ public static function locator(bool $getShared = true)
304304
* Provides the ability to perform case-insensitive calling of service
305305
* names.
306306
*
307+
* @param array<int,mixed> $arguments
307308
* @return object|null
308309
*/
309310
public static function __callStatic(string $name, array $arguments)

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();

0 commit comments

Comments
 (0)