Skip to content

Incorrect behavior of LongArrayToShortArrayRector #7741

@TeLiXj

Description

@TeLiXj

Bug Report

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

Minimal PHP Code Causing Issue

See https://getrector.com/demo/fe2978d5-c66a-4b39-a62b-ec005b71544d

<?php

final class DemoFile
{
    public function run()
    {
	$ok = array(
            'ok' => 'ok!',
            'KO' => 'KO!'
        );
    }
}

Responsible rules

  • LongArrayToShortArrayRector

Expected Behavior

The array was changed to a single line

$ok = ['ok' => 'ok!', "KO" => "KO!"];

instead of keeping the structure

$ok = [
        'ok' => 'ok!',
        'KO' => 'KO!'
];

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