File tree Expand file tree Collapse file tree 4 files changed +70
-0
lines changed
Expand file tree Collapse file tree 4 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug10482 ;
4+
5+ use function PHPStan \Testing \assertType ;
6+
7+ class Test
8+ {
9+ public ?int $ id ;
10+ }
11+
12+ $ test = new Test ();
13+ if (rand (0 , 1 )) {
14+ $ test = null ;
15+ }
16+
17+ $ testId = $ test ?->id;
18+ if (null !== $ testId ) {
19+ assertType ('Bug10482\Test ' , $ test );
20+ }
21+
22+ if ($ testId ) {
23+ assertType ('Bug10482\Test ' , $ test );
24+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Bug13709 ;
4+
5+ use function PHPStan \Testing \assertType ;
6+
7+ function doFOo (string $ shortName ): void
8+ {
9+ $ pos = strpos ($ shortName , '\\' );
10+ if ($ pos === false ) {
11+ return ;
12+ }
13+
14+ assertType ('non-falsy-string ' , $ shortName );
15+ }
16+
17+
Original file line number Diff line number Diff line change @@ -3891,4 +3891,13 @@ public function testBug9820(): void
38913891 ]);
38923892 }
38933893
3894+ #[RequiresPhp('>= 8.1 ' )]
3895+ public function testBug6120 (): void
3896+ {
3897+ $ this ->checkThisOnly = false ;
3898+ $ this ->checkNullables = true ;
3899+ $ this ->checkUnionTypes = true ;
3900+ $ this ->analyse ([__DIR__ . '/data/bug-6120.php ' ], []);
3901+ }
3902+
38943903}
Original file line number Diff line number Diff line change 1+ <?php // lint >= 8.0
2+
3+ declare (strict_types=1 );
4+
5+ namespace Bug6120 ;
6+
7+ class Clazz
8+ {
9+
10+ public int $ foo = 0 ;
11+
12+ public function bar (?Clazz $ clazz ): void
13+ {
14+ $ result = $ clazz ?->foo;
15+ if ($ result !== null ) {
16+ $ clazz ->bar (null );
17+ }
18+ }
19+
20+ }
You can’t perform that action at this time.
0 commit comments