Skip to content

Match multiCase not checking spaces after comma #1369

@HMartusewiczVox

Description

@HMartusewiczVox

PSR says:

Image

But the following code raises no issue:

$x = match (1) {
    1,2,3 => 'asdas',
    default => 5
};

Demonstrated by:

[root@b8a7f7560dfb html]# ./vendor/bin/phpcs sniff_match.php 

FILE: /var/www/html/sniff_match.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 8 | ERROR | [x] Expected at least 1 space before "."; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

Time: 46ms; Memory: 4MB
[root@b8a7f7560dfb html]# cat sniff_match.php 
<?php

$x = match (1) {
    1,2,3 => 'asdas',
    default => 5
};

$a = '1'. '2';
[root@b8a7f7560dfb html]# ./vendor/bin/phpcs --version
PHP_CodeSniffer version 4.0.1 (stable) by Squiz and PHPCSStandards
[root@b8a7f7560dfb html]# php --version
PHP 8.3.30 (cli) (built: Jan 13 2026 22:36:55) (NTS gcc aarch64)
Copyright (c) The PHP Group
Zend Engine v4.3.30, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.30, Copyright (c), by Zend Technologies
    with Xdebug v3.5.0, Copyright (c) 2002-2025, by Derick Rethans

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions