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

Prevent resolving conditional types in callable param/return types #3405

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

rvanvelzen
Copy link
Contributor

Unresolvable conditional types should not be forcibly resolved in callable param/return types because they generally depend on calling that callable.

Fix phpstan/phpstan#11472.

Copy link
Member

@ondrejmirtes ondrejmirtes left a comment

Choose a reason for hiding this comment

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

I'm sorry about the Composer build failures here. I need to look into them. Probably has something to do with publishing the 2.0.x branch.

@@ -411,11 +411,21 @@ public static function containsTemplateType(Type $type): bool

public static function resolveLateResolvableTypes(Type $type, bool $resolveUnresolvableTypes = true): Type
{
return TypeTraverser::map($type, static function (Type $type, callable $traverse) use ($resolveUnresolvableTypes): Type {
while ($type instanceof LateResolvableType && ($resolveUnresolvableTypes || $type->isResolvable())) {
$ignoreResolveUnresolvableTypesLevel = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Just do @var int here :)

@ondrejmirtes ondrejmirtes merged commit c26886d into phpstan:1.12.x Sep 5, 2024
133 of 134 checks passed
@ondrejmirtes
Copy link
Member

Thank you!

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

Successfully merging this pull request may close these issues.

None yet

2 participants