Skip to content

A match statement within an array produces Squiz.Arrays.ArrayDeclaration.NoKeySpecified #3502

Closed
@ivan-wolf

Description

@ivan-wolf

Description
The default option of the match statement will result in the following error:
No key specified for array entry; first entry specifies key

Code sample

[
    'foo' => match ($anything) {
        'foo' => 'bar',
        default => null,
    },
];

Expected behavior
Should not result in an error.

Versions:

  • OS: Ubuntu 20.04
  • PHP: 8.0
  • PHPCS: 3.6.2
  • Standard: Squiz

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions