Skip to content

v4.15.1

Latest

Choose a tag to compare

@github-actions github-actions released this 17 Jul 16:24
6f0f450

This release improves Eloquent pluck() and builder type narrowing, plus primary-key and factory binding inference.

Features

  • Narrow single-argument pluck()->all() to list<TValue> (#1299)
 Task::all()->pluck('id')->all();
-// array<int, int> -- rejected by a list<int> return type
+// list<int> -- pluck() always reindexes sequentially
  • Fix pluck() and aggregate narrowing on custom subclasses, raw aliases, and schema-typed columns (#1288)
 /** @extends Builder<Task> */
 class TaskBuilder extends Builder {}

 $tasks->pluck('title');
-// Collection<array-key, mixed> -- LHS fallback only checked generic builders
+// Collection<int, string> -- resolved via @extends Builder<Task>
  • Auto-bind Factory<TModel> on bare factory subclasses (#1280)
 class TaskFactory extends Factory {}

 (new TaskFactory())->create();
-// Model -- TModel collapses to base Model with no @extends Factory<Task> binding
+// Task -- model resolved via Factory::modelName() at warm-up
  • Narrow Model::getKey() to the model's known primary-key type (#1279)
 class UuidModel extends Model { use HasUuids; }

 $model->getKey();
-// int|string -- always the stub's fallback
+// string -- narrowed from the model's known primary-key type

Fixes

  • Fix custom builder method forwarding on relations (#1267)
 // Order has a custom builder with `firstByMake(): ?self`
 $vehicle->orders()->firstByMake('Toyota');
-// mixed -- custom builder-only methods weren't resolved through the relation
+// ?Order -- forwarded through the relation via Psalm storage

Full Changelog: v4.15.0...v4.15.1