phpinspectionsea icon indicating copy to clipboard operation
phpinspectionsea copied to clipboard

Incorrect recommendation for `compact` for array unpacking statements

Open asgraf opened this issue 9 months ago • 0 comments

Subject Details
Plugin Php Inspections (EA Extended)
Language level PHP 8.1

Example code:

$source_array = ['foo' => 1, 'bar' => 2, 'baz' => 3];
['foo' => $foo, 'bar' => $bar] = $source_array;

Current behavior:

Use compact(...) instead inspection appears Applying it breaks code by changing it to:

$source_array = ['foo' => 1, 'bar' => 2, 'baz' => 3];
compact('foo', 'bar') = $source_array;

Expected behavior:

Use compact(...) instead inspection should not appear for array unpacking statements

asgraf avatar Sep 28 '23 02:09 asgraf