Skip to content

Commit 23515db

Browse files
committed
address feedback
1 parent 2acf585 commit 23515db

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Type/Php/DateFunctionReturnTypeHelper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ public function buildReturnTypeFromFormat(string $formatString, bool $useMicrose
7676
return $this->buildNumericRangeType(0, 1, false);
7777
case 'u':
7878
return $useMicrosec
79-
? new IntersectionType([new StringType(), new AccessoryNumericStringType()])
79+
? new IntersectionType([new StringType(), new AccessoryNonFalsyStringType(), new AccessoryNumericStringType()])
8080
: new ConstantStringType('000000');
81+
case 'v':
82+
return $useMicrosec
83+
? new IntersectionType([new StringType(), new AccessoryNonFalsyStringType(), new AccessoryNumericStringType()])
84+
: new ConstantStringType('000');
8185
}
8286

8387
$date = date($formatString);

tests/PHPStan/Analyser/nsrt/bug-6613.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ function (\DateTime $dt) {
88
assertType("'000000'", date('u'));
99
assertType('numeric-string', date_format($dt, 'u'));
1010
assertType('numeric-string', $dt->format('u'));
11+
12+
assertType("'000'", date('v'));
13+
assertType('numeric-string', date_format($dt, 'v'));
14+
assertType('numeric-string', $dt->format('v'));
1115
};

0 commit comments

Comments
 (0)