forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-11328.php
More file actions
33 lines (25 loc) · 717 Bytes
/
bug-11328.php
File metadata and controls
33 lines (25 loc) · 717 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php // lint >= 8.1
declare(strict_types = 1);
namespace Bug11328;
use function PHPStan\Testing\assertType;
enum Status: string {
case Live = 's1';
case Expired = 's2';
}
/** @param Status[] $statuses */
function check(array $statuses): void {
$fromDeadline = null;
$toDeadline = null;
if (in_array(Status::Live, $statuses, true)) {
$fromDeadline = (new \DateTimeImmutable())->setTime(23, 59, 59);
}
assertType('DateTimeImmutable|null', $fromDeadline);
if (in_array(Status::Expired, $statuses, true)) {
assertType('DateTimeImmutable|null', $fromDeadline);
if ($fromDeadline === null) {
$toDeadline = (new \DateTimeImmutable())->setTime(0, 0, 0);
} else {
$fromDeadline = null;
}
}
}