Skip to content

Reference parameter not considered as variable mutation #4004

@sstok

Description

@sstok

Bug report

Code snippet that reproduces the problem

https://phpstan.org/r/d14466f0-f81e-4594-8ba9-8d87badb70f6

            $original = "I just wanna tell you how I'm feeling\nGotta make you understand";
            $encrypted = '';
            $decrypted = '';

            if (! @\openssl_public_encrypt($original, $encrypted, $pupKey, OPENSSL_PKCS1_OAEP_PADDING)) {
                throw new Exception('Unable to encrypt data, invalid key provided?');
            }

The openssl_public_encrypt() function sets $decrypted, but PHPStan reports the condition is always true
as it doesn't take-in the fact the the $decrypted variable is mutated as argument.

Removing $decrypted = ''; fixes the issue.

Expected output

No errors!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions