Skip to content

Commit 5d75058

Browse files
ondrejmirtesclaude
andcommitted
Add regression test(s) for collateral fix(es) #8360
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CGhnJQpUWRRpg6H5LuWJkA
1 parent 5457935 commit 5d75058

3 files changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug8360Nsrt;
4+
5+
use PHPStan\TrinaryLogic;
6+
use function PHPStan\Testing\assertVariableCertainty;
7+
8+
function logicalOr(bool $cond, bool $f): void
9+
{
10+
if ($cond || $f) {
11+
$x = 1;
12+
}
13+
14+
if ($cond && $f) {
15+
assertVariableCertainty(TrinaryLogic::createYes(), $x);
16+
echo $x;
17+
}
18+
}

‎tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1750,4 +1750,13 @@ public function testBug7706(): void
17501750
$this->analyse([__DIR__ . '/data/bug-7706.php'], []);
17511751
}
17521752

1753+
public function testBug8360(): void
1754+
{
1755+
$this->cliArgumentsVariablesRegistered = true;
1756+
$this->polluteScopeWithLoopInitialAssignments = false;
1757+
$this->checkMaybeUndefinedVariables = true;
1758+
$this->polluteScopeWithAlwaysIterableForeach = true;
1759+
$this->analyse([__DIR__ . '/data/bug-8360.php'], []);
1760+
}
1761+
17531762
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug8360;
4+
5+
function logicalOr(bool $cond, bool $f): void
6+
{
7+
if ($cond || $f) {
8+
$x = 1;
9+
}
10+
11+
if ($cond && $f) {
12+
echo $x;
13+
}
14+
}

0 commit comments

Comments
 (0)