Skip to content

Incorrect behavior of ChangeSwitchToMatchRector #7782

@jnoordsij

Description

@jnoordsij

Bug Report

Subject Details
Rector version last dev-main
Installed as composer dependency

Minimal PHP Code Causing Issue

See https://getrector.com/demo/ab671fa0-5f74-4495-b6f6-e8918d8b5f1a

<?php

switch ($file['type']) {
    case StorageAttributes::TYPE_DIRECTORY:
        $root['folders'][] = $file;
        break;
    case StorageAttributes::TYPE_FILE:
        $root['files'][] = $file;
        break;
    default:
        $root['unknown'][] = $file;
}

Responsible rules

  • ChangeSwitchToMatchRector

Expected Behavior

Code should be skipped: assignment is applied to different variables (or more specifically: different array keys), so should not be converted to a match case.

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