Skip to content

Commit dbbb3f8

Browse files
committed
Add 2 more regression tests
1 parent 7fa7239 commit dbbb3f8

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

tests/PHPStan/Rules/Missing/MissingReturnRuleTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,22 @@ public function testBug9309(): void
325325
$this->analyse([__DIR__ . '/data/bug-9309.php'], []);
326326
}
327327

328+
public function testBug6807(): void
329+
{
330+
$this->checkExplicitMixedMissingReturn = true;
331+
$this->analyse([__DIR__ . '/data/bug-6807.php'], []);
332+
}
333+
328334
public function testBug8463(): void
329335
{
330336
$this->checkExplicitMixedMissingReturn = true;
331337
$this->analyse([__DIR__ . '/data/bug-8463.php'], []);
332338
}
333339

340+
public function testBug9374(): void
341+
{
342+
$this->checkExplicitMixedMissingReturn = true;
343+
$this->analyse([__DIR__ . '/data/bug-9374.php'], []);
344+
}
345+
334346
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug6807;
4+
5+
/** @return int */
6+
function test()
7+
{
8+
for ($attempts = 0; ; $attempts++)
9+
{
10+
if ($attempts > 5)
11+
throw new Exception();
12+
13+
if (rand() == 1)
14+
return 5;
15+
}
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug9374;
4+
5+
function bar(): string {
6+
for ($i = 0; ; ++$i)
7+
return "";
8+
}

0 commit comments

Comments
 (0)