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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anonymous function should have native return typehint "Closure(mixed): bool". #5164

Closed
keksa opened this issue Jun 11, 2021 · 2 comments
Closed

Comments

@keksa
Copy link

keksa commented Jun 11, 2021

Bug report

There is no such thing as native return typehint "Closure(mixed): bool" 馃檪

Code snippet that reproduces the problem

https://phpstan.org/r/b5bc0d6c-c014-4c96-b9fb-18f39e26b865

<?php declare(strict_types = 1);

class HelloWorld
{
    public function sayHello(): void
    {
        $isInstanceOf = static function (string $class) {
            return static function ($item) use ($class): bool {
                return $item instanceof $class;
            };
        };
    }
}

Expected output

The error message should say native return typehint "Closure" or something like that, not native return typehint "Closure(mixed): bool", got confused for a bit.

Did PHPStan help you today? Did it make you happy in any way?

Absolutely, found a piece code that never could have worked and was in the codebase for years.

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@476520d

@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 Jul 13, 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

No branches or pull requests

2 participants