Skip to content

False positives locally but not in Playground #7077

@dsuurlant

Description

@dsuurlant

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

https://phpstan.org/r/cccb1c0f-d54a-4c6a-899e-f69ecfb8d8a0 (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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions