Skip to content

Commit 9973fb6

Browse files
committed
refactor: fix phpstan errors in DataConverter
1 parent 2cb29b7 commit 9973fb6

4 files changed

Lines changed: 24 additions & 62 deletions

File tree

‎system/DataConverter/DataConverter.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public function __construct(
7171
*
7272
* @param array<string, mixed> $data DataSource data
7373
*
74+
* @return array<string, mixed>
75+
*
7476
* @internal
7577
*/
7678
public function fromDataSource(array $data): array
@@ -89,6 +91,8 @@ public function fromDataSource(array $data): array
8991
*
9092
* @param array<string, mixed> $phpData PHP data
9193
*
94+
* @return array<string, mixed>
95+
*
9296
* @internal
9397
*/
9498
public function toDataSource(array $phpData): array

‎tests/system/DataConverter/DataConverterTest.php‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public function testInstantiate(): void
4444
$this->assertInstanceOf(DataConverter::class, $converter);
4545
}
4646

47+
/**
48+
* @param array<string, string> $types
49+
* @param array<string, mixed> $dbData
50+
* @param array<string, mixed> $expected
51+
*/
4752
#[DataProvider('provideConvertDataFromDB')]
4853
public function testConvertDataFromDB(array $types, array $dbData, array $expected): void
4954
{
@@ -54,6 +59,9 @@ public function testConvertDataFromDB(array $types, array $dbData, array $expect
5459
$this->assertSame($expected, $data);
5560
}
5661

62+
/**
63+
* @return iterable<string, array{array<string, string>, array<string, mixed>, array<string, mixed>}>
64+
*/
5765
public static function provideConvertDataFromDB(): iterable
5866
{
5967
yield from [
@@ -270,6 +278,11 @@ public static function provideConvertDataFromDB(): iterable
270278
];
271279
}
272280

281+
/**
282+
* @param array<string, string> $types
283+
* @param array<string, mixed> $phpData
284+
* @param array<string, mixed> $expected
285+
*/
273286
#[DataProvider('provideConvertDataToDB')]
274287
public function testConvertDataToDB(array $types, array $phpData, array $expected): void
275288
{
@@ -280,6 +293,9 @@ public function testConvertDataToDB(array $types, array $phpData, array $expecte
280293
$this->assertSame($expected, $data);
281294
}
282295

296+
/**
297+
* @return iterable<string, array{array<string, string>, array<string, mixed>, array<string, mixed>}>
298+
*/
283299
public static function provideConvertDataToDB(): iterable
284300
{
285301
yield from [
@@ -706,6 +722,8 @@ public function testNotNullable(): void
706722
}
707723

708724
/**
725+
* @param array<string, string> $types
726+
* @param array<string, class-string> $handlers
709727
* @param (Closure(array<string, mixed>): object)|string|null $reconstructor
710728
* @param (Closure(object, bool, bool): array<string, mixed>)|string|null $extractor
711729
*/

‎utils/phpstan-baseline/loader.neon‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 153 errors
1+
# total 141 errors
22

33
includes:
44
- argument.type.neon

‎utils/phpstan-baseline/missingType.iterableValue.neon‎

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 95 errors
1+
# total 83 errors
22

33
parameters:
44
ignoreErrors:
@@ -72,16 +72,6 @@ parameters:
7272
count: 1
7373
path: ../../system/Cookie/CookieStore.php
7474

75-
-
76-
message: '#^Method CodeIgniter\\DataConverter\\DataConverter\:\:fromDataSource\(\) return type has no value type specified in iterable type array\.$#'
77-
count: 1
78-
path: ../../system/DataConverter/DataConverter.php
79-
80-
-
81-
message: '#^Method CodeIgniter\\DataConverter\\DataConverter\:\:toDataSource\(\) return type has no value type specified in iterable type array\.$#'
82-
count: 1
83-
path: ../../system/DataConverter/DataConverter.php
84-
8575
-
8676
message: '#^Method CodeIgniter\\Exceptions\\PageNotFoundException\:\:lang\(\) has parameter \$args with no value type specified in iterable type array\.$#'
8777
count: 1
@@ -307,56 +297,6 @@ parameters:
307297
count: 1
308298
path: ../../tests/system/Cookie/CookieTest.php
309299

310-
-
311-
message: '#^Method CodeIgniter\\DataConverter\\DataConverterTest\:\:createDataConverter\(\) has parameter \$handlers with no value type specified in iterable type array\.$#'
312-
count: 1
313-
path: ../../tests/system/DataConverter/DataConverterTest.php
314-
315-
-
316-
message: '#^Method CodeIgniter\\DataConverter\\DataConverterTest\:\:createDataConverter\(\) has parameter \$types with no value type specified in iterable type array\.$#'
317-
count: 1
318-
path: ../../tests/system/DataConverter/DataConverterTest.php
319-
320-
-
321-
message: '#^Method CodeIgniter\\DataConverter\\DataConverterTest\:\:provideConvertDataFromDB\(\) return type has no value type specified in iterable type iterable\.$#'
322-
count: 1
323-
path: ../../tests/system/DataConverter/DataConverterTest.php
324-
325-
-
326-
message: '#^Method CodeIgniter\\DataConverter\\DataConverterTest\:\:provideConvertDataToDB\(\) return type has no value type specified in iterable type iterable\.$#'
327-
count: 1
328-
path: ../../tests/system/DataConverter/DataConverterTest.php
329-
330-
-
331-
message: '#^Method CodeIgniter\\DataConverter\\DataConverterTest\:\:testConvertDataFromDB\(\) has parameter \$dbData with no value type specified in iterable type array\.$#'
332-
count: 1
333-
path: ../../tests/system/DataConverter/DataConverterTest.php
334-
335-
-
336-
message: '#^Method CodeIgniter\\DataConverter\\DataConverterTest\:\:testConvertDataFromDB\(\) has parameter \$expected with no value type specified in iterable type array\.$#'
337-
count: 1
338-
path: ../../tests/system/DataConverter/DataConverterTest.php
339-
340-
-
341-
message: '#^Method CodeIgniter\\DataConverter\\DataConverterTest\:\:testConvertDataFromDB\(\) has parameter \$types with no value type specified in iterable type array\.$#'
342-
count: 1
343-
path: ../../tests/system/DataConverter/DataConverterTest.php
344-
345-
-
346-
message: '#^Method CodeIgniter\\DataConverter\\DataConverterTest\:\:testConvertDataToDB\(\) has parameter \$expected with no value type specified in iterable type array\.$#'
347-
count: 1
348-
path: ../../tests/system/DataConverter/DataConverterTest.php
349-
350-
-
351-
message: '#^Method CodeIgniter\\DataConverter\\DataConverterTest\:\:testConvertDataToDB\(\) has parameter \$phpData with no value type specified in iterable type array\.$#'
352-
count: 1
353-
path: ../../tests/system/DataConverter/DataConverterTest.php
354-
355-
-
356-
message: '#^Method CodeIgniter\\DataConverter\\DataConverterTest\:\:testConvertDataToDB\(\) has parameter \$types with no value type specified in iterable type array\.$#'
357-
count: 1
358-
path: ../../tests/system/DataConverter/DataConverterTest.php
359-
360300
-
361301
message: '#^Method CodeIgniter\\Database\\BaseConnectionTest\:\:provideProtectIdentifiers\(\) return type has no value type specified in iterable type iterable\.$#'
362302
count: 1

0 commit comments

Comments
 (0)