Skip to content

array_first Can't use temporary expression in write context #9601

@EdmondDantes

Description

@EdmondDantes

Bug Report

Subject Details
Rector version Rector 2.3.1
        if ($this->lastInsertedId !== null && $result[\array_key_first($result)] === null) {
            $result[\array_key_first($result)]  = $this->lastInsertedId;
        }
// ===> 
        if ($this->lastInsertedId !== null && array_first($result) === null) {
            array_first($result)  = $this->lastInsertedId;
        }

The expression array_first($result) cannot appear on the left-hand side.

Minimal PHP Code Causing Issue

Expected Behaviour

$result[\array_key_first($result)]  = $this->lastInsertedId;

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