Skip to content

Destructuring syntax (list() and []) #119

Description

@j-willette

I want to report a case that does not seem to be explicitly covered by PSR-12.
It concerns variable destructuring using the list() and [] syntaxes.

I have this code:

[$val1,$val2] = explode(',', $string);
list($val1,$val2) = explode(',', $string);

And I do not get any error when running the command:

phpcs --standard=PSR12 my-file.php

In my opinion, there should be a space required after the comma following $val1, as in function calls or arrays.

Correction:

[$val1, $val2] = explode(',', $string);
list($val1, $val2) = explode(',', $string);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions