-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Override variable certainty in global scope with
@var
- Loading branch information
1 parent
7ea7ce4
commit 44f9d08
Showing
3 changed files
with
53 additions
and
0 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
42 changes: 42 additions & 0 deletions
42
tests/PHPStan/Analyser/data/override-root-scope-variable.php
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,42 @@ | ||
<?php | ||
|
||
use PHPStan\TrinaryLogic; | ||
use function PHPStan\Analyser\assertVariableCertainty; | ||
|
||
assertVariableCertainty(TrinaryLogic::createMaybe(), $foo); | ||
|
||
/** @var Foo $foo */ | ||
|
||
assertVariableCertainty(TrinaryLogic::createYes(), $foo); | ||
|
||
function (): void { | ||
assertVariableCertainty(TrinaryLogic::createNo(), $foo); | ||
|
||
/** @var Foo $foo */ | ||
|
||
assertVariableCertainty(TrinaryLogic::createNo(), $foo); | ||
}; | ||
|
||
function (): void { | ||
if (rand(0, 1) === 0) { | ||
$foo = doFoo(); | ||
} | ||
|
||
assertVariableCertainty(TrinaryLogic::createMaybe(), $foo); | ||
|
||
/** @var Foo $foo */ | ||
|
||
assertVariableCertainty(TrinaryLogic::createMaybe(), $foo); | ||
}; | ||
|
||
assertVariableCertainty(TrinaryLogic::createMaybe(), $bar); | ||
assert($bar instanceof Foo); | ||
assertVariableCertainty(TrinaryLogic::createYes(), $bar); | ||
|
||
function (): void { | ||
assertVariableCertainty(TrinaryLogic::createNo(), $bar); | ||
|
||
assert($bar instanceof Foo); | ||
|
||
assertVariableCertainty(TrinaryLogic::createYes(), $bar); | ||
}; |