File tree Expand file tree Collapse file tree 3 files changed +62
-0
lines changed
tests/PHPStan/Rules/Methods Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -3588,6 +3588,26 @@ public function testBug13171(): void
35883588 ]);
35893589 }
35903590
3591+ public function testBug10719 (): void
3592+ {
3593+ $ this ->checkThisOnly = false ;
3594+ $ this ->checkNullables = true ;
3595+ $ this ->checkUnionTypes = true ;
3596+ $ this ->checkExplicitMixed = true ;
3597+
3598+ $ this ->analyse ([__DIR__ . '/data/bug-10719.php ' ], []);
3599+ }
3600+
3601+ public function testBug9141 (): void
3602+ {
3603+ $ this ->checkThisOnly = false ;
3604+ $ this ->checkNullables = true ;
3605+ $ this ->checkUnionTypes = true ;
3606+ $ this ->checkExplicitMixed = true ;
3607+
3608+ $ this ->analyse ([__DIR__ . '/data/bug-9141.php ' ], []);
3609+ }
3610+
35913611 public function testBug3396 (): void
35923612 {
35933613 $ this ->checkThisOnly = false ;
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Bug10719 ;
4+
5+ use DateTime ;
6+
7+ $ dt1 = null ;
8+ $ dt2 = new DateTime ();
9+
10+ if (rand (0 , 1 )) {
11+ $ dt1 = (clone $ dt2 )->setTimestamp ($ dt2 ->getTimestamp () + 1000 );
12+ }
13+
14+ if ($ dt1 > $ dt2 ) {
15+ echo $ dt1 ->getTimestamp ();
16+ }
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace Bug9141 ;
4+
5+ use DateTimeImmutable ;
6+
7+ class HelloWorld
8+ {
9+
10+ private ?DateTimeImmutable $ startTime ;
11+
12+ public function __construct () {
13+ $ this ->startTime = new DateTimeImmutable ();
14+ }
15+
16+ public function getStartTime (): ?DateTimeImmutable
17+ {
18+ return $ this ->startTime ;
19+ }
20+
21+ }
22+
23+ $ helloWorld = new HelloWorld ();
24+ if ($ helloWorld ->getStartTime () > new DateTimeImmutable ()) {
25+ echo sprintf ('%s ' , $ helloWorld ->getStartTime ()->format ('d.m.y. ' ));
26+ }
You can’t perform that action at this time.
0 commit comments