Skip to content

Commit ecf4353

Browse files
SplotyCodeondrejmirtes
authored andcommitted
Add missing idate identifiers
1 parent 439efe7 commit ecf4353

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Type/Php/IdateFunctionReturnTypeHelper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,16 @@ public function getTypeFromFormatType(Type $formatType): ?Type
2929

3030
public function buildReturnTypeFromFormat(string $formatString): Type
3131
{
32-
// see https://www.php.net/idate
32+
// see https://www.php.net/idate and https://www.php.net/manual/de/datetime.format
3333
switch ($formatString) {
3434
case 'd':
35+
case 'j':
3536
return IntegerRangeType::fromInterval(1, 31);
3637
case 'h':
38+
case 'g':
3739
return IntegerRangeType::fromInterval(1, 12);
3840
case 'H':
41+
case 'G':
3942
return IntegerRangeType::fromInterval(0, 23);
4043
case 'i':
4144
return IntegerRangeType::fromInterval(0, 59);
@@ -44,6 +47,7 @@ public function buildReturnTypeFromFormat(string $formatString): Type
4447
case 'L':
4548
return IntegerRangeType::fromInterval(0, 1);
4649
case 'm':
50+
case 'n':
4751
return IntegerRangeType::fromInterval(1, 12);
4852
case 'N':
4953
return IntegerRangeType::fromInterval(1, 7);

tests/PHPStan/Analyser/nsrt/idate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class Foo
1313
*/
1414
public function doFoo(string $string, string $hour, string $format): void
1515
{
16+
assertType('int<1, 31>', idate('j'));
1617
assertType('int<1, 7>', idate('N'));
1718
assertType('int', idate('Y'));
1819
assertType('false', idate('wrong'));

0 commit comments

Comments
 (0)