Skip to content

New sniff: change long list syntax to short list syntax #5

Description

@jrfnl
Sniff basics -
Fixable for PHP: 7.1+
Sniff type: Modernize
Fixer type: Safe

Short description

PHP 7.1 introduced a short list syntax.

Related PHPCompatibility sniff(s):

PHP manual references:

Example code:

Detect the following code pattern(s):

list($id1, $name1) = $data[0];

foreach ($data as list($id, $name)) {
    // logic here with $id and $name
}

And fix these to:

[$id1, $name1] = $data[0];

foreach ($data as [$id, $name]) {
    // logic here with $id and $name
}

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions