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

Fix infinite recursion for template intersection type accepts() #1450

Merged
merged 1 commit into from Jun 21, 2022

Conversation

rvanvelzen
Copy link
Contributor

Comment on lines -147 to -150
if ($acceptingType instanceof self || ($acceptingType instanceof UnionType && !$acceptingType instanceof TemplateUnionType)) {
return $acceptingType->accepts($this, $strictTypes);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing appears to break by removing this 🤷‍♂️

@ondrejmirtes ondrejmirtes merged commit e4a1b67 into phpstan:1.7.x Jun 21, 2022
@ondrejmirtes
Copy link
Member

Thank you! Removing code is always nice 😊

@rvanvelzen rvanvelzen deleted the bug-7500 branch June 21, 2022 07:51
@VincentLanglet
Copy link
Contributor

@rvanvelzen @ondrejmirtes Am I wrong or the testBug7500 shouldn't report any error ?

https://phpstan.org/r/29203f2e-5b6c-46bf-b91a-baf7d3839591 works fine
but https://phpstan.org/r/05a8098a-1a57-460c-8707-3027e65605da doesn't.

\PHPStan\dumpType($res[$position]);

is PositionEntityInterface&TgEntityInterface but since

/** @phpstan-var array<T> $res */
$res = [];

it should be T of PositionEntityInterface&TgEntityInterface IMHO.

Should I open an issue ?

@ondrejmirtes
Copy link
Member

@VincentLanglet Comments on closed PRs tend to get lost, please open a new bug report about this, thanks.

@VincentLanglet
Copy link
Contributor

Yes I did it @ondrejmirtes phpstan/phpstan#7511 with a simpler reproducer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants