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 positives locally but not in Playground #7077

dsuurlant opened this issue Apr 21, 2022 · 2 comments

False positives locally but not in Playground #7077

dsuurlant opened this issue Apr 21, 2022 · 2 comments


Copy link

Bug report

Locally we have a file that defines pure functions with a namespace specified at the top of the file. Some of these functions have the same name as PHP global functions and PHPStan gives a false positive on the function parameters. More importantly, we're unable to reproduce this with the PHPStan playground tool.

Note: we're using level 1.

Code snippet that reproduces the problem (no errors)

When we copy-paste the above code to a single file and analyse it locally (PHPStan 1.5.7, PHP 8.0.17) we get two false positives of "Function date_add invoked with 3 parameters, 2 required."

Removing the namespace from the online code snippet produces the same error that we get locally with namespace.

Expected output

PHPStan's local output should be the same as the online tool and functions defined in a namespace shouldn't be flagged as being in the global namespace.

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

Love using PHPStan to gradually improve our codebase one level at a time!

Copy link

Hi, I have good news - your code is okay, and this already works correctly in PHPStan 1.6.x-dev with bleedingEdge enabled (

PHPStan 1.6.0 release shouldn't be too far off.

The reason is that I'm progressively switching to 100 % static reflection (this paragraph will no longer be true:

A few minor versions down the line this should work correctly for everyone.

I added a regression test just to be sure this doesn't break in the future: phpstan/phpstan-src@6a611f0

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 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
None yet

No branches or pull requests

2 participants