Skip to content

Commit 156b1ea

Browse files
phpstan-botclaude
andcommitted
Add regression test for #10040
Closes phpstan/phpstan#10040 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 02719b1 commit 156b1ea

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php declare(strict_types = 1); // lint >= 8.0
2+
3+
namespace Bug10040;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class A
8+
{
9+
public string|null $foo;
10+
}
11+
12+
/**
13+
* @phpstan-assert-if-true !null $a->foo
14+
*/
15+
function assertStringNotNull(A $a): bool
16+
{
17+
return true;
18+
}
19+
20+
$a1 = new A();
21+
if(assertStringNotNull($a1)){
22+
assertType('string', $a1->foo);
23+
}
24+
25+
$a2 = new A();
26+
$stringIsNotNull = assertStringNotNull($a2);
27+
if($stringIsNotNull){
28+
assertType('string', $a2->foo);
29+
}
30+
31+
$a3 = new A();
32+
if($stringIsNotNull = assertStringNotNull($a3)){
33+
assertType('string', $a3->foo);
34+
}

0 commit comments

Comments
 (0)