Skip to content

Commit e656176

Browse files
committed
refactor: fix phpstan errors in I18n
1 parent 2cb29b7 commit e656176

7 files changed

Lines changed: 30 additions & 66 deletions

File tree

system/I18n/Time.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* @property-read string $quarter
3535
* @property-read string $second
3636
* @property-read int $timestamp
37+
* @property-read string $timezoneName
3738
* @property-read bool $utc
3839
* @property-read string $weekOfMonth
3940
* @property-read string $weekOfYear

system/I18n/TimeLegacy.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,23 @@
2323
* This is not immutable! Some methods are immutable,
2424
* but some methods can alter the state.
2525
*
26-
* @property int $age read-only
27-
* @property string $day read-only
28-
* @property string $dayOfWeek read-only
29-
* @property string $dayOfYear read-only
30-
* @property bool $dst read-only
31-
* @property string $hour read-only
32-
* @property bool $local read-only
33-
* @property string $minute read-only
34-
* @property string $month read-only
35-
* @property string $quarter read-only
36-
* @property string $second read-only
37-
* @property int $timestamp read-only
38-
* @property bool $utc read-only
39-
* @property string $weekOfMonth read-only
40-
* @property string $weekOfYear read-only
41-
* @property string $year read-only
26+
* @property int $age read-only
27+
* @property string $day read-only
28+
* @property string $dayOfWeek read-only
29+
* @property string $dayOfYear read-only
30+
* @property bool $dst read-only
31+
* @property string $hour read-only
32+
* @property bool $local read-only
33+
* @property string $minute read-only
34+
* @property string $month read-only
35+
* @property string $quarter read-only
36+
* @property string $second read-only
37+
* @property int $timestamp read-only
38+
* @property string $timezoneName read-only
39+
* @property bool $utc read-only
40+
* @property string $weekOfMonth read-only
41+
* @property string $weekOfYear read-only
42+
* @property string $year read-only
4243
*
4344
* @phpstan-consistent-constructor
4445
*

tests/system/I18n/TimeLegacyTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public function testMagicIssetFalse(): void
317317
{
318318
$time = TimeLegacy::parse('January 1, 2016');
319319

320-
$this->assertFalse(isset($time->foobar));
320+
$this->assertFalse(isset($time->foobar)); // @phpstan-ignore property.notFound
321321
}
322322

323323
public function testGetYear(): void
@@ -1128,7 +1128,7 @@ public function testGetter(): void
11281128
{
11291129
$time = TimeLegacy::parse('August 12, 2016 4:15:23pm');
11301130

1131-
$this->assertNull($time->weekOfWeek);
1131+
$this->assertNull($time->weekOfWeek); // @phpstan-ignore property.notFound
11321132
}
11331133

11341134
public function testUnserializeTimeObject(): void
@@ -1163,6 +1163,9 @@ public function testToStringDoesNotDependOnLocale(string $locale): void
11631163
$this->assertSame('2017-03-10 12:00:00', (string) $time);
11641164
}
11651165

1166+
/**
1167+
* @return iterable<int, array{0: string}>
1168+
*/
11661169
public static function provideToStringDoesNotDependOnLocale(): iterable
11671170
{
11681171
yield from [

tests/system/I18n/TimeTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ public function testMagicIssetFalse(): void
346346
{
347347
$time = Time::parse('January 1, 2016');
348348

349-
$this->assertFalse(isset($time->foobar));
349+
$this->assertFalse(isset($time->foobar)); // @phpstan-ignore property.notFound
350350
}
351351

352352
public function testGetYear(): void
@@ -1280,7 +1280,7 @@ public function testGetter(): void
12801280
{
12811281
$time = Time::parse('August 12, 2016 4:15:23pm');
12821282

1283-
$this->assertNull($time->weekOfWeek);
1283+
$this->assertNull($time->weekOfWeek); // @phpstan-ignore property.notFound
12841284
}
12851285

12861286
public function testUnserializeTimeObject(): void
@@ -1324,6 +1324,9 @@ public function testToStringDoesNotDependOnLocale(string $locale): void
13241324
$this->assertSame('2017-03-10 12:00:00', (string) $time);
13251325
}
13261326

1327+
/**
1328+
* @return iterable<int, array{0: string}>
1329+
*/
13271330
public static function provideToStringDoesNotDependOnLocale(): iterable
13281331
{
13291332
yield from [

utils/phpstan-baseline/loader.neon

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

33
includes:
44
- argument.type.neon
@@ -12,5 +12,4 @@ includes:
1212
- missingType.iterableValue.neon
1313
- missingType.parameter.neon
1414
- property.defaultValue.neon
15-
- property.notFound.neon
1615
- property.phpDocType.neon

utils/phpstan-baseline/missingType.iterableValue.neon

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

33
parameters:
44
ignoreErrors:
@@ -422,16 +422,6 @@ parameters:
422422
count: 1
423423
path: ../../tests/system/Database/Live/UpdateTest.php
424424

425-
-
426-
message: '#^Method CodeIgniter\\I18n\\TimeLegacyTest\:\:provideToStringDoesNotDependOnLocale\(\) return type has no value type specified in iterable type iterable\.$#'
427-
count: 1
428-
path: ../../tests/system/I18n/TimeLegacyTest.php
429-
430-
-
431-
message: '#^Method CodeIgniter\\I18n\\TimeTest\:\:provideToStringDoesNotDependOnLocale\(\) return type has no value type specified in iterable type iterable\.$#'
432-
count: 1
433-
path: ../../tests/system/I18n/TimeTest.php
434-
435425
-
436426
message: '#^Method CodeIgniter\\Models\\FindModelTest\:\:provideAggregateAndGroupBy\(\) return type has no value type specified in iterable type iterable\.$#'
437427
count: 1

utils/phpstan-baseline/property.notFound.neon

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)