Skip to content

Commit

Permalink
fix insert before
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Nov 8, 2024
1 parent 2d862a7 commit eaf8053
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/NodeManipulator/ClassInsertManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function addPropertyToClass(Class_ $class, string $name, ?Type $type): vo
*/
private function insertBefore(array $stmts, Stmt $stmt, int $key): array
{
array_splice($stmts, $key, 0, [$stmt]);
array_splice($stmts, max(0, $key - 1), 0, [$stmt]);

return $stmts;
}
Expand Down

0 comments on commit eaf8053

Please sign in to comment.