-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed regression from commit 9665e16
- Loading branch information
1 parent
7e57ca0
commit c981d89
Showing
4 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Bug2850; | ||
|
||
use function PHPStan\Analyser\assertType; | ||
|
||
class Foo | ||
{ | ||
public function y(): void {} | ||
} | ||
|
||
class Bar | ||
{ | ||
/** @var Foo|null */ | ||
private $x; | ||
|
||
public function getFoo(): Foo | ||
{ | ||
if ($this->x === null) { | ||
$this->x = new Foo(); | ||
assertType(Foo::class, $this->x); | ||
$this->x->y(); | ||
assertType(Foo::class, $this->x); | ||
$this->y(); | ||
assertType(Foo::class . '|null', $this->x); | ||
} | ||
return $this->x; | ||
} | ||
|
||
public function y(): void | ||
{ | ||
$this->x = null; | ||
} | ||
} |