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, thetoArray()thatmake:resourcegenerates now reportsInvalidReturnTypeinstead ofMixedReturnTypeCoercion.
Fixes
- Keep the factory class and its
TModelfromcount(),times()andforEachSequence()on factories that override a LaravelFactorymethod (#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
UnnecessaryVarAnnotationin 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\BuilderorConnectionwhen called through theSchemaorDBfacade (#2282)
Connection::macro('tableSize', fn (string $table): int => 0);
DB::tableSize('users');
-// UndefinedMagicMethod
+// int- Keep a template-bound collection receiver when
keyBy()orgroupBy()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