Skip to content

Commit 36dc4a4

Browse files
committed
Added regression test
1 parent 1b17eaf commit 36dc4a4

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

tests/PHPStan/Rules/Comparison/IfConstantConditionRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,10 @@ public function testBug4912(): void
173173
$this->analyse([__DIR__ . '/data/bug-4912.php'], []);
174174
}
175175

176+
public function testBug4864(): void
177+
{
178+
$this->treatPhpDocTypesAsCertain = true;
179+
$this->analyse([__DIR__ . '/data/bug-4864.php'], []);
180+
}
181+
176182
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace Bug4864;
4+
5+
class Example
6+
{
7+
/** @var mixed */
8+
private $value;
9+
private bool $isHandled;
10+
11+
public function fetchValue(callable $f): void
12+
{
13+
$this->isHandled = false;
14+
$this->value = null;
15+
16+
(function () {
17+
$this->isHandled = true;
18+
$this->value = 'value';
19+
})();
20+
21+
if ($this->isHandled) {
22+
$f($this->value);
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)