Skip to content

Read migration columns from arrow function Schema::create() and Schema::table() callbacks - #2350

Merged
alies-dev merged 13 commits into
4.xfrom
2338-arrow-fn-migration-callbacks
Nov 18, 2026
Merged

alies-dev merged 13 commits into
4.xfrom
2338-arrow-fn-migration-callbacks

Conversation

@alies-dev

@alies-dev alies-dev commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Issue to Solve

SchemaAggregator only read Closure callbacks, so columns declared in Schema::create('tags', fn (Blueprint $table) => $table->string('name')) never reached the model schema and their properties were unknown.

Related

Fixes #2338

Depends on #2355 (Require Psalm 7.10), merged into this branch: Psalm 7.10.0 resolves class names in arrow function signatures (vimeo/psalm#14134).

Solution Description

  • Schema::create(), Schema::table() and Blueprint::after() accept arrow functions; the expression body is read as a one-statement closure body.
  • The callback's parameter type is checked through resolvedName, exactly like closures: an imported foreign Blueprint is declined, an aliased use ...\Blueprint as B is accepted, fully qualified names resolve as written.
  • Unit tests cover create/table/after, a static arrow function, no-param and foreign-class declines, aliased and fully qualified Blueprint.

Checklist

  • Tests cover the change (tests/Unit)

…llbacks

Schema::create(), Schema::table() and Blueprint::after() callbacks written as fn (Blueprint $table) => ... were ignored. Psalm's name resolver skips arrow function signatures, so the Blueprint parameter type check falls back to the written class name.

Fixes #2338
Psalm's SimpleNameResolver skips ArrowFunction signatures; the written-name fallback in isForeignParamType() is a workaround until vimeo/psalm#14134 lands.
…xactly

Pins the written-name fallback limits in a KnownLimitation test and documents them; see vimeo/psalm#14134.
@alies-dev alies-dev self-assigned this Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpsalm-plugin-laravel
Branchpr-2350
Testbedintel-v1
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
seconds (s)
(Result Δ%)
Upper Boundary
seconds (s)
(Limit %)
Peak MemoryBenchmark Result
megabytes (MB) x 1e3
(Result Δ%)
Upper Boundary
megabytes (MB) x 1e3
(Limit %)
monica📈 view plot
🚷 view threshold
43.26 s
(-1.45%)Baseline: 43.90 s
47.76 s
(90.58%)
📈 view plot
🚷 view threshold
1.16 MB x 1e3
(+0.17%)Baseline: 1.15 MB x 1e3
1.21 MB x 1e3
(95.40%)
🐰 View full continuous benchmarking report in Bencher

@alies-dev

Copy link
Copy Markdown
Collaborator Author

/psalm-delta all

@alies-dev alies-dev added the release:fix for PRs only (used by release-drafter) label Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

✅ Types: unchanged · Performance: unchanged

Apps: all → 23

App Wall (s) Memory (MB) Issues Weighted (types) Taint Coverage (%)
✅ monica 34.9 $\color{gray}{\textsf{+1.9\%}}$ 1 691 $\color{gray}{\textsf{-0.1\%}}$ 5 840 12 475 6 97.06
✅ pixelfed 25.2 $\color{gray}{\textsf{+2.7\%}}$ 1 432 $\color{gray}{\textsf{-0.1\%}}$ 20 187 36 844 59 86.02
✅ coolify 45.5 $\color{gray}{\textsf{+0.6\%}}$ 1 556 $\color{gray}{\textsf{+0.2\%}}$ 19 741 33 957 15 88.89
✅ bookstack 26.6 $\color{gray}{\textsf{+4.2\%}}$ 1 204 $\color{gray}{\textsf{-0.1\%}}$ 3 283 6 136 22 96.68
✅ solidtime 16.9 $\color{gray}{\textsf{-0.6\%}}$ 1 320 $\color{gray}{\textsf{-0.2\%}}$ 1 326 2 366 0 97.97
✅ laravel-socialite 7.4 $\color{gray}{\textsf{-0.3\%}}$ 661 365 859 0 89.54
✅ laravel-permission 15.3 $\color{gray}{\textsf{-0.2\%}}$ 813 426 724 0 88.68
✅ laravel-excel 16.8 $\color{gray}{\textsf{-0.5\%}}$ 863 $\color{gray}{\textsf{-0.1\%}}$ 904 2 150 0 94.29
✅ bagisto 46.8 $\color{gray}{\textsf{+2.7\%}}$ 1 983 $\color{gray}{\textsf{+0.7\%}}$ 17 261 32 104 1 83.67
✅ filament 36.4 $\color{gray}{\textsf{-0.5\%}}$ 1 697 $\color{gray}{\textsf{-0.1\%}}$ 12 026 28 160 878 95.19
✅ unit3d 38.1 $\color{gray}{\textsf{+1.2\%}}$ 1 263 5 672 12 022 5 96.65
✅ vito 15.3 $\color{gray}{\textsf{-0.7\%}}$ 1 055 $\color{gray}{\textsf{+0.1\%}}$ 2 525 3 612 55 96.42
✅ laravel-backup 10.8 $\color{gray}{\textsf{-1.9\%}}$ 815 407 811 0 95.53
✅ corcel 8.3 $\color{gray}{\textsf{+1.2\%}}$ 748 403 1 024 0 87.67
✅ spatie-dashboard 11.1 $\color{gray}{\textsf{-4.5\%}}$ 823 190 333 0 89.42
✅ tastyigniter 11.1 $\color{gray}{\textsf{-0.7\%}}$ 933 38 71 0 100.00
✅ unopim 50.3 $\color{gray}{\textsf{-2.7\%}}$ 2 200 20 367 32 893 56 85.85
✅ m3u-editor 89.6 $\color{gray}{\textsf{+0.5\%}}$ 2 198 $\color{gray}{\textsf{-0.1\%}}$ 22 412 38 206 30 93.41
✅ agent-fleet 89.7 $\color{gray}{\textsf{+1.5\%}}$ 2 559 $\color{gray}{\textsf{+0.5\%}}$ 27 914 51 589 131 93.86
✅ relaticle 48.4 $\color{gray}{\textsf{+1.1\%}}$ 3 816 $\color{gray}{\textsf{+0.2\%}}$ 2 548 4 843 14 98.09
✅ aureuserp 104.5 $\color{gray}{\textsf{+1.4\%}}$ 3 349 $\color{gray}{\textsf{-0.2\%}}$ 33 370 75 628 0 92.57
✅ kanka 72.6 $\color{gray}{\textsf{-0.1\%}}$ 2 451 $\color{gray}{\textsf{-0.2\%}}$ 17 247 33 995 7 94.02
✅ skuul 34.8 $\color{gray}{\textsf{-1.2\%}}$ 1 536 3 505 7 512 3 98.96
Total 856.2 $\color{gray}{\textsf{+0.6\%}}$ 36 964 217 957 418 314 1 282 –
How to read this table
  • Wall: head seconds. A badge is colored only for a move of at least 3 s and 10 %, as shared runners are noisy: slower is red, faster is green, anything smaller is gray.
  • Memory: peak RSS of the largest process in Psalm's process tree, workers included. Red above +5 %, green below −5 %, gray between. A dash means a side has no figure.
  • Issues: head count over all categories, then $\color{red}{\textsf{+added}}$ $\color{green}{\textsf{-removed}}$ against base, and $\color{orange}{\textsf{N changed}}$ for issues at the same place and type with a new message (not counted in added or removed).
  • Weighted (types): type issues weighted by error level (levels 1–8 as is, always-errors 10, strictness checks 1), order-dependent types excluded. Taint and dead-code issues are not weighed. A rise is not necessarily a regression.
  • Taint: head count of Tainted* issues, then $\color{orange}{\textsf{+added}}$ $\color{orange}{\textsf{-removed}}$ against base. Both are orange as either direction needs review: more can be new detection or false positives, fewer can be fixed false positives or lost detection.
  • Dead code: head count of unused-code issues, shown only when a run reported some (--find-dead-code). More is red, fewer is green.
  • Coverage: inferred type coverage. A badge appears only for a move of at least 0.005 points, smaller moves are parallel-analysis jitter.
  • Total: sum over the apps compared on both sides (coverage is not summed). Badge thresholds and the heading words apply per app, not to the total, so the Total row can be colored differently from the heading.
  • Colors: $\color{red}{\textsf{red}}$ worse or more issues, $\color{green}{\textsf{green}}$ better or fewer issues, $\color{orange}{\textsf{orange}}$ needs review, $\color{gray}{\textsf{gray}}$ noise.
  • Icons: ✅ both sides produced a report · ❌ head produced none while base did · 💥 not comparable (base crashed, both crashed, or not run). A crash on both sides is not caused by this PR.
  • Performance (heading): regressed if a head run crashed or a wall or memory badge is red, else improved if one is green, else unchanged. Types (heading): direction of the total weighted change. Taint and Dead code (heading): added and removed counts, present only when non-zero. Informational, never fails the PR.

head 4c2d04c · base 2505648 (merge-base) · workflow run

Informational only — never fails the PR. Pick apps with /psalm-delta <group|app> ..., add --find-dead-code-style flags (/psalm-delta help lists both). Reproduce locally: bash bin/ci/delta.sh --apps "<group|app|--flag> ..." <pr-branch>.

…backs

Psalm now resolves class names in arrow function signatures (vimeo/psalm#14134), so the written-name fallback and its known limitations are gone: an imported foreign Blueprint is declined and an aliased Blueprint is accepted, exactly like closures.
Psalm 7.10.0 ships vimeo/psalm#14134, which the arrow function Blueprint callback check relies on.
- Bump vimeo/psalm to ^7.10.0 in composer.json and the tests.yml install step.
- Psalm 7.10 narrows exhausted instanceof checks to never (vimeo/psalm#14048): widen the container resolutions of url, translator and view to mixed so the runtime guards stay honest, and drop the unreachable Model guard around ReflectionClass<Model>::newInstanceWithoutConstructor().
- Expect the InvalidArgument 7.10 reports for a numeric-string factory() count in FactoryCountInferenceTest.
Rector strips a plain @var mixed, which brought back the Psalm 7.10 TypeDoesNotContainType findings.
@alies-dev alies-dev mentioned this pull request Nov 18, 2026
1 task done
@alies-dev
alies-dev merged commit 0ff1258 into 4.x Nov 18, 2026
10 checks passed
@alies-dev
alies-dev deleted the 2338-arrow-fn-migration-callbacks branch November 18, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:fix for PRs only (used by release-drafter)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migration columns declared in an arrow-function callback are ignored

1 participant