Skip to content

Commit 770316b

Browse files
phpstan-botclaude
andcommitted
Add static method call test cases for bug-14318
Cover the StaticCallHandler code path with regression tests using static method calls (self::maybeThrows()) alongside the existing instance method call tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 734e0b3 commit 770316b

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

tests/PHPStan/Rules/Variables/data/bug-14318.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,59 @@ public function maybeThrows6(int $s): void
5757
}
5858
}
5959
}
60+
61+
class HelloWorld7
62+
{
63+
public function test7(): void
64+
{
65+
global $pdo;
66+
67+
try {
68+
self::maybeThrows7($sql = "SELECT * FROM foo");
69+
$rs = $pdo->query($sql);
70+
if ($result = $rs->fetch(\PDO::FETCH_ASSOC)) {
71+
// do something
72+
}
73+
} catch (\PDOException $e) {
74+
var_dump($sql);
75+
}
76+
}
77+
78+
/**
79+
* @throws \RuntimeException
80+
*/
81+
public static function maybeThrows7(string $s): void
82+
{
83+
if (random_int(0, 1) === 1) {
84+
throw new \RuntimeException();
85+
}
86+
}
87+
}
88+
89+
class HelloWorld8
90+
{
91+
public function test8(): void
92+
{
93+
global $pdo;
94+
95+
try {
96+
self::maybeThrows8(strlen($sql = "SELECT * FROM foo"));
97+
$rs = $pdo->query($sql);
98+
if ($result = $rs->fetch(\PDO::FETCH_ASSOC)) {
99+
// do something
100+
}
101+
} catch (\PDOException $e) {
102+
var_dump($sql);
103+
}
104+
}
105+
106+
/**
107+
* @throws \RuntimeException
108+
*/
109+
public static function maybeThrows8(int $s): void
110+
{
111+
if (random_int(0, 1) === 1) {
112+
throw new \RuntimeException();
113+
}
114+
}
115+
}

0 commit comments

Comments
 (0)