-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
phpstan/phpstan-src
#335Description
Bug report
I added a new test today and PHPStan never finishes when trying to analyze it. Posting a reproducer below.
Code snippet that reproduces the problem
As this is causing an infinite loop I can't get a phpstan.org link. But if you copypaste the code, it will happen.
<?php declare(strict_types = 1);
use DateTimeImmutable;
use Ds\Set;
use Iterator;
abstract class PHPStanBug
{
public function test(): void
{
/** @var Set<class-string> $set */
$set = new Set();
foreach ($this->a() as $item) {
$set->add(\get_class($item));
}
foreach ($this->b() as $item) {
$set->add(\get_class($item));
}
foreach ($this->c() as $item) {
$set->add($item);
}
$set->sort();
}
/**
* @return Iterator<object>
*/
abstract public function a(): Iterator;
/**
* @return Iterator<object>
*/
private function b(): Iterator
{
yield new DateTimeImmutable();
}
/**
* @return Iterator<class-string<object>>
*/
private function c(): Iterator
{
yield DateTimeImmutable::class;
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels