Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop #3866

Closed
enumag opened this issue Sep 14, 2020 · 5 comments · Fixed by phpstan/phpstan-src#335
Closed

Infinite loop #3866

enumag opened this issue Sep 14, 2020 · 5 comments · Fixed by phpstan/phpstan-src#335

Comments

@enumag
Copy link
Contributor

enumag commented Sep 14, 2020

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;
	}
}
@mergeable
Copy link

mergeable bot commented Sep 14, 2020

This bug report is missing a link to reproduction on phpstan.org.
It will most likely be closed after manual review.

@enumag
Copy link
Contributor Author

enumag commented Sep 22, 2020

@ondrejmirtes Do you have an idea what might be wrong here?

@ondrejmirtes
Copy link
Member

Nope, someone equipped with Xdebug needs to figure that out.

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src#335

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants