Skip to content

Commit 54cf6eb

Browse files
committed
Added regression test
1 parent 36dc4a4 commit 54cf6eb

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

tests/PHPStan/Rules/Comparison/IfConstantConditionRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,10 @@ public function testBug4864(): void
179179
$this->analyse([__DIR__ . '/data/bug-4864.php'], []);
180180
}
181181

182+
public function testBug8926(): void
183+
{
184+
$this->treatPhpDocTypesAsCertain = true;
185+
$this->analyse([__DIR__ . '/data/bug-8926.php'], []);
186+
}
187+
182188
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Bug8926;
4+
5+
class Foo {
6+
private bool $test;
7+
8+
/** @param int[] $arr */
9+
function success(array $arr) : void {
10+
$test = false;
11+
(function($arr) use(&$test) {
12+
$test = count($arr) == 1;
13+
})($arr);
14+
15+
if ($test) {
16+
echo "...\n";
17+
}
18+
}
19+
20+
/** @param int[] $arr */
21+
function error(array $arr) : void {
22+
$this->test = false;
23+
(function($arr) {
24+
$this->test = count($arr) == 1;
25+
})($arr);
26+
27+
28+
if ($this->test) {
29+
echo "...\n";
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)