File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff 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 );
Original file line number Diff line number Diff 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 ' ));
You can’t perform that action at this time.
0 commit comments