Skip to content

Commit 325ae39

Browse files
phpstan-botclaude
andcommitted
Add regression tests for phpstan/phpstan#4090, #11218
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0ec5f54 commit 325ae39

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug11218;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class HelloWorld
8+
{
9+
10+
public function test(): void
11+
{
12+
for ($i = 1; $i <= 3; $i++) {
13+
if ($i === 1) {
14+
$test = 'value';
15+
}
16+
}
17+
18+
assertType("'value'", $test);
19+
}
20+
21+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug4090;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
class HelloWorld
8+
{
9+
10+
/**
11+
* @param string[] $items
12+
*/
13+
public function test(string $value, array $items): void
14+
{
15+
if (in_array($value, $items, true)) {
16+
assertType('non-empty-array<string>', $items);
17+
$first = current($items);
18+
assertType('string', $first);
19+
}
20+
}
21+
22+
}

0 commit comments

Comments
 (0)