Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conditional expressions - do not take conclusions about identical var…
…iable in assignment
- Loading branch information
1 parent
dc77608
commit cde53d1
Showing
4 changed files
with
60 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
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,27 @@ | ||
<?php | ||
|
||
namespace Bug8621; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class HelloWorld | ||
{ | ||
/** | ||
* @param array<string> $data | ||
*/ | ||
public function rows (array $data): void | ||
{ | ||
$even = true; | ||
|
||
echo "<table>"; | ||
foreach ($data as $datum) | ||
{ | ||
$even = !$even; | ||
assertType('bool', $even); | ||
|
||
echo "<tr class='" . ($even ? 'even' :'odd') . "'>"; | ||
echo "<td>{$datum}</td></tr>"; | ||
} | ||
echo "</table>"; | ||
} | ||
} |
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 | ||
|
||
namespace Bug8625; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class HelloWorld | ||
{ | ||
public static function sayHello(): void | ||
{ | ||
$key = false; | ||
$loopArray = [1, 2, 3]; | ||
foreach ($loopArray as $i) { | ||
$key = $key === false; | ||
assertType('bool', $key); | ||
if ($key) { | ||
echo "i=$i key is true\n"; | ||
} else { | ||
echo "i=$i key is false\n"; | ||
} | ||
} | ||
} | ||
} |