Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Type/Php/DateFunctionReturnTypeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ public function buildReturnTypeFromFormat(string $formatString, bool $useMicrose
return $this->buildNumericRangeType(0, 1, false);
case 'u':
return $useMicrosec
? new IntersectionType([new StringType(), new AccessoryNonFalsyStringType(), new AccessoryNumericStringType()])
? new IntersectionType([new StringType(), new AccessoryNumericStringType()])
: new ConstantStringType('000000');
case 'v':
return $useMicrosec
? new IntersectionType([new StringType(), new AccessoryNonFalsyStringType(), new AccessoryNumericStringType()])
? new IntersectionType([new StringType(), new AccessoryNumericStringType()])
: new ConstantStringType('000');
}

Expand Down
8 changes: 4 additions & 4 deletions tests/PHPStan/Analyser/nsrt/bug-10893.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
use function PHPStan\Testing\assertType;

/**
* @param non-falsy-string&numeric-string $str
* @param numeric-string $str
*/
function hasMicroseconds(\DateTimeInterface $value, string $str): bool
{
assertType('non-falsy-string&numeric-string', $str);
assertType('numeric-string', $str);
assertType('int', (int)$str);
assertType('bool', (int)$str !== 0);

assertType('non-falsy-string&numeric-string', $value->format('u'));
assertType('numeric-string', $value->format('u'));
assertType('int', (int)$value->format('u'));
assertType('bool', (int)$value->format('u') !== 0);

assertType('non-falsy-string&numeric-string', $value->format('v'));
assertType('numeric-string', $value->format('v'));
assertType('int', (int)$value->format('v'));
assertType('bool', (int)$value->format('v') !== 0);

Expand Down
8 changes: 4 additions & 4 deletions tests/PHPStan/Analyser/nsrt/bug-6613.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

function (\DateTime $dt) {
assertType("'000000'", date('u'));
assertType('non-falsy-string&numeric-string', date_format($dt, 'u'));
assertType('non-falsy-string&numeric-string', $dt->format('u'));
assertType('numeric-string', date_format($dt, 'u'));
assertType('numeric-string', $dt->format('u'));

assertType("'000'", date('v'));
assertType('non-falsy-string&numeric-string', date_format($dt, 'v'));
assertType('non-falsy-string&numeric-string', $dt->format('v'));
assertType('numeric-string', date_format($dt, 'v'));
assertType('numeric-string', $dt->format('v'));
};
Loading