Skip to content

Inconsistent by-ref arguments handling for standard functions, type erased to mixed sometimes #7231

@fluffycondor

Description

@fluffycondor

Bug report

PHPStan 1.6.8

If I pass an array to shuffle(), I get an array again, as one could expect. (And I didn't find any presence that shuffle treated in a special way in the PHPStan's source code, searched for shuffle across the project.)
https://phpstan.org/r/fcc029c7-a91e-4e98-8656-c21ed32e7480

If I pass an array to parse_str(), its type resets to mixed for some reason.
If I pass a float to similar_text(), its type resets to mixed too.
https://phpstan.org/r/83cf5048-7004-4588-8a52-451f75b215be

I think it can be safely assumed that standard PHP functions don't change by-ref arguments' type and it always will be the same as specified in a signature.

Code snippet that reproduces the problem

https://phpstan.org/r/83cf5048-7004-4588-8a52-451f75b215be

Expected output

By-ref arguments' type passed to standard functions shouldn't be erased to mixed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions