Skip to content

argument #1 of extract() may be either by-ref or by-val #11759

@claudepache

Description

@claudepache

Bug report

Although the first parameter of extract() is marked as having to be passed by-ref, it also accepts by-val expressions. See php/doc-en#3676 (comment) for explanation.

As a consequence, the following code:

extract([ 'answer' => 42 ]);

is perfectly valid and phpstan should not generate the error Parameter #1 $array of function extract is passed by reference, so it expects variables only.

Code snippet that reproduces the problem

https://phpstan.org/r/2570bf4a-8bdd-42d0-8006-61dcd4d77eb8

Expected output

No error.

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

I particularly appreciate that phpstan allows me to progressively tighten and extend the checks in our legacy codebase (rule level; baseline)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions