Skip to content

Commit 9fab5c0

Browse files
phpstan-botclaude
andcommitted
Add later-invoked-callable test case for bug-11417
Adds a test with @param-later-invoked-callable to verify that property invalidation behavior is distinct from @param-immediately-invoked-callable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 59f45b5 commit 9fab5c0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/PHPStan/Rules/Comparison/data/bug-11417.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,35 @@ public function disc(): void
3838
$this->conn = null;
3939
}
4040
}
41+
42+
class WrapLater {
43+
/**
44+
* @param-later-invoked-callable $cb
45+
*/
46+
public static function run(callable $cb): void
47+
{
48+
$cb();
49+
}
50+
}
51+
52+
class HelloWorldLater
53+
{
54+
private ?string $conn = null;
55+
56+
public function getConn(): string
57+
{
58+
if (!is_null($this->conn)) {
59+
return $this->conn;
60+
}
61+
62+
WrapLater::run(function() {
63+
$this->conn = "conn";
64+
});
65+
66+
if (is_null($this->conn)) { // should be always true - later-invoked callable doesn't invalidate
67+
throw new \Exception("conn failed");
68+
}
69+
70+
return $this->conn;
71+
}
72+
}

0 commit comments

Comments
 (0)