Skip to content

Commit 2998d07

Browse files
phpstan-botclaude
andcommitted
Add regression test for #6120
Closes phpstan/phpstan#6120 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0ca1890 commit 2998d07

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php declare(strict_types = 1); // lint >= 8.0
2+
3+
namespace Bug6120;
4+
5+
use Generator;
6+
use function PHPStan\Testing\assertType;
7+
8+
class HelloWorld
9+
{
10+
/**
11+
* @var Generator<int, string> $gen
12+
*/
13+
private ?Generator $gen = null;
14+
15+
public function setGenerator(Generator $gen): void {
16+
$this->gen = $gen;
17+
}
18+
19+
public function sayHello(): void
20+
{
21+
while ($v = $this->gen?->current()) {
22+
assertType('Generator<int, string, mixed, mixed>', $this->gen);
23+
echo $v;
24+
$this->gen->next();
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)