Run Rector on your code to see what it can do for you:

 <?php
 
-        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;
         }
PHP snippet to change

Applied Rules:

Not a change you expect?

Config  rector.php
Rector version: 52350d - released at 2026-01-19 01:42