Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Final scope from
Continue_
points should not be used for `while (tr…
…ue)`
- Loading branch information
Showing
3 changed files
with
60 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\Analyser; | ||
|
||
use PHPStan\Testing\TypeInferenceTestCase; | ||
|
||
class Bug10980Test extends TypeInferenceTestCase | ||
{ | ||
|
||
public function dataFileAsserts(): iterable | ||
{ | ||
yield from self::gatherAssertTypes(__DIR__ . '/data/bug-10980.php'); | ||
} | ||
|
||
/** | ||
* @dataProvider dataFileAsserts | ||
* @param mixed ...$args | ||
*/ | ||
public function testFileAsserts( | ||
string $assertType, | ||
string $file, | ||
...$args, | ||
): void | ||
{ | ||
$this->assertFileAsserts($assertType, $file, ...$args); | ||
} | ||
|
||
} |
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,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bug10980; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class A {} | ||
|
||
class B extends A {} | ||
|
||
function a(): A {} | ||
|
||
while (true) { | ||
$type = a(); | ||
if (!$type instanceof B) { | ||
continue; | ||
} | ||
break; | ||
} | ||
|
||
assertType('Bug10980\B', $type); |