Skip to content

Commit fcb8fe5

Browse files
committed
test instance-method calls and function calls
1 parent 47d3754 commit fcb8fe5

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeFunctionCallRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,4 +1179,10 @@ public function testBug14177(): void
11791179
$this->analyse([__DIR__ . '/data/bug-14177.php'], []);
11801180
}
11811181

1182+
public function testBug13566(): void
1183+
{
1184+
$this->treatPhpDocTypesAsCertain = true;
1185+
$this->analyse([__DIR__ . '/data/bug-13566.php'], []);
1186+
}
1187+
11821188
}

tests/PHPStan/Rules/Comparison/ImpossibleCheckTypeMethodCallRuleTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,12 @@ public function testBug12087b(): void
290290
]);
291291
}
292292

293+
public function testBug13566(): void
294+
{
295+
$this->treatPhpDocTypesAsCertain = true;
296+
$this->analyse([__DIR__ . '/data/bug-13566.php'], []);
297+
}
298+
293299
public static function getAdditionalConfigFiles(): array
294300
{
295301
return [

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,45 @@ public function test(): void
105105

106106
}
107107
}
108+
109+
110+
111+
class ReturnsWithInstanceMethod
112+
{
113+
/** @return ($exit is true ? never-return : void) */
114+
public function notFound(bool $exit = true): void
115+
{
116+
header('HTTP/1.1 404 Not Found', true, 404);
117+
118+
if ($exit) {
119+
echo '404 Not Found';
120+
exit;
121+
}
122+
}
123+
124+
125+
public function test(): void
126+
{
127+
// send 404 header
128+
$this->notFound(false);
129+
130+
}
131+
}
132+
133+
/** @return ($exit is true ? never-return : void) */
134+
function notFound(bool $exit = true): void
135+
{
136+
header('HTTP/1.1 404 Not Found', true, 404);
137+
138+
if ($exit) {
139+
echo '404 Not Found';
140+
exit;
141+
}
142+
}
143+
144+
function test(): void
145+
{
146+
// send 404 header
147+
notFound(false);
148+
149+
}

0 commit comments

Comments
 (0)