packagist psalm/plugin-laravel v4.22.0

one hour ago

This release targets Psalm 7.7 and fixes factory count(), macros called through the Schema and DB facades, and keyBy()/groupBy() on template-bound collections.

Requirements

  • Require vimeo/psalm ^7.7.0 (#2312). Projects on Psalm 7.6 keep v4.21.1. Psalm 7.7 reports some issues differently, so a baseline may need a refresh: for example, the toArray() that make:resource generates now reports InvalidReturnType instead of MixedReturnTypeCoercion.

Fixes

  • Keep the factory class and its TModel from count(), times() and forEachSequence() on factories that override a Laravel Factory method (#2317)
 /** @template TModel of Model @extends Factory<TModel> */
 abstract class BaseFactory extends Factory { /* overrides state(), defines admin() */ }

 $this->count($n)->admin();
-// UndefinedMagicMethod: Magic method Illuminate\Database\Eloquent\Factories\Factory::admin does not exist
+// BaseFactory<TModel>&static
 $this->count($n)->create();
-// Collection<int, Model>|Model
+// Collection<int, TModel>|TModel
  • Stop reporting UnnecessaryVarAnnotation in Blade component views that render a nested <x-...> tag on Psalm 7.7 (#2312)
  • Resolve each call through a first-class callable Route::domain(...) to its own branch (#2312)
 $fn = $route->domain(...);
 $fn('api.example.com');
-// Route&static|null|string
+// Route&static
  • Resolve macros registered on Schema\Builder or Connection when called through the Schema or DB facade (#2282)
 Connection::macro('tableSize', fn (string $table): int => 0);
 DB::tableSize('users');
-// UndefinedMagicMethod
+// int
  • Keep a template-bound collection receiver when keyBy() or groupBy() is called with a column name (#2291)
 /** @template C of Collection<int, Row> @param C $rows @return C */
 function index(Collection $rows): Collection
 {
     return $rows->keyBy('foreign_id');
-    // InvalidReturnType, InvalidReturnStatement
+    // no issue
 }

Full Changelog: v4.21.1...v4.22.0

Don't miss a new plugin-laravel release

NewReleases is sending notifications on new releases.