Skip to content

[13.x] Fix getMigrationBatches return type annotation - #59876

Merged
taylorotwell merged 1 commit into
laravel:13.xfrom
mahfuz-rahman007:fix/migration-batches-return-type
Apr 27, 2026
Merged

taylorotwell merged 1 commit into
laravel:13.xfrom
mahfuz-rahman007:fix/migration-batches-return-type

Conversation

@mahfuz-rahman007

@mahfuz-rahman007 mahfuz-rahman007 commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the @return type annotation for getMigrationBatches() in both MigrationRepositoryInterface and DatabaseMigrationRepository.

Context

The method calls pluck('batch', 'migration')->all(), which returns an associative array keyed by migration name (string) with batch number (int) as the value.

The current annotation array<int, string>[] is incorrect in two ways:

  1. The keys and values are swapped — migration names are the keys (string), batch numbers are the values (int)
  2. The trailing [] is extraneous — the return is a flat associative array, not an array of arrays

Changes

File Before After
MigrationRepositoryInterface.php @return array<int, string>[] @return array<string, int>
DatabaseMigrationRepository.php @return array<int, string>[] @return array<string, int>

Impact

PHPDoc-only change. No behavioral change. This improves static analysis accuracy (PHPStan/Psalm) and IDE type inference.

The `pluck('batch', 'migration')->all()` call returns an associative
array keyed by migration name (string) with batch number (int) as the
value. The current annotation `array<int, string>[]` has the keys and
values swapped and an extraneous trailing `[]`.
@taylorotwell
taylorotwell merged commit 715952e into laravel:13.x Apr 27, 2026
53 checks passed
jonagoldman pushed a commit to deplox/laravel-framework that referenced this pull request Apr 30, 2026
The `pluck('batch', 'migration')->all()` call returns an associative
array keyed by migration name (string) with batch number (int) as the
value. The current annotation `array<int, string>[]` has the keys and
values swapped and an extraneous trailing `[]`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants