|
4 | 4 |
|
5 | 5 | use PhpTypedValues\DateTime\DateTimeAtom; |
6 | 6 | use PhpTypedValues\DateTime\DateTimeRFC3339; |
| 7 | +use PhpTypedValues\DateTime\DateTimeRFC3339Extended; |
| 8 | +use PhpTypedValues\DateTime\DateTimeW3C; |
7 | 9 | use PhpTypedValues\DateTime\Timestamp\TimestampMilliseconds; |
8 | 10 | use PhpTypedValues\DateTime\Timestamp\TimestampSeconds; |
| 11 | +use PhpTypedValues\Undefined\Alias\Undefined; |
9 | 12 |
|
10 | 13 | /** |
11 | 14 | * DateTime. |
|
24 | 27 |
|
25 | 28 | $tsVo = TimestampMilliseconds::fromString('1735787045123'); |
26 | 29 | echo TimestampMilliseconds::fromDateTime($tsVo->value())->toString() . \PHP_EOL; |
| 30 | + |
| 31 | +// tryFromString usages to satisfy Psalm (ensure both success and failure branches are referenced) |
| 32 | +$a = DateTimeAtom::tryFromString('2025-01-02T03:04:05+00:00'); |
| 33 | +if (!($a instanceof Undefined)) { |
| 34 | + echo $a->toString() . \PHP_EOL; |
| 35 | +} |
| 36 | + |
| 37 | +$r = DateTimeRFC3339::tryFromString('2025-01-02T03:04:05+00:00'); |
| 38 | +if (!($r instanceof Undefined)) { |
| 39 | + echo $r->toString() . \PHP_EOL; |
| 40 | +} |
| 41 | + |
| 42 | +$re = DateTimeRFC3339Extended::tryFromString('2025-01-02T03:04:05.123456+00:00'); |
| 43 | +if (!($re instanceof Undefined)) { |
| 44 | + echo $re->toString() . \PHP_EOL; |
| 45 | +} |
| 46 | + |
| 47 | +$w = DateTimeW3C::tryFromString('2025-01-02T03:04:05+00:00'); |
| 48 | +if (!($w instanceof Undefined)) { |
| 49 | + echo $w->toString() . \PHP_EOL; |
| 50 | +} |
| 51 | + |
| 52 | +$ts = TimestampSeconds::tryFromString('1735787045'); |
| 53 | +if (!($ts instanceof Undefined)) { |
| 54 | + echo $ts->toString() . \PHP_EOL; |
| 55 | +} |
| 56 | + |
| 57 | +$tm = TimestampMilliseconds::tryFromString('1735787045123'); |
| 58 | +if (!($tm instanceof Undefined)) { |
| 59 | + echo $tm->toString() . \PHP_EOL; |
| 60 | +} |
0 commit comments