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

False positive "Throwable in PHPDoc @throws tag but it's not thrown" with callback. #5043

Closed
VincentLanglet opened this issue May 19, 2021 · 2 comments

Comments

@VincentLanglet
Copy link
Contributor

Bug report

I'm getting a false positive:

Method AssuranceVie\Factory\PdfFactory::createTemporaryFiles() has Throwable in PHPDoc @throws tag but it's not thrown.

Code snippet that reproduces the problem

    /**
     * @param string[] $absolutePathsOrUrls
     *
     * @return File[]
     *
     * @throws \Throwable
     */
    private function createTemporaryFiles(array $absolutePathsOrUrls): array
    {
        return array_map(
            function (string $absolutePathOrUrl): File {
                $content = file_get_contents($absolutePathOrUrl);
                if (false === $content) {
                    throw new \Exception(sprintf('Cannot get content from %s.', $absolutePathOrUrl));
                }

                return new File($content);
            },
            $absolutePathsOrUrls
        );
    }

Expected output

No error, an exception can be thrown.

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

Yes, it helps me a lot.

@VincentLanglet
Copy link
Contributor Author

Seems like a duplicate of #5001

@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 Jun 20, 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

1 participant