packagist psalm/plugin-laravel v4.18.1
v4.18.1 Blade

2 hours ago

v4.18.1 moves to the stable Psalm 7.0 release and uses its template defaults to type Eloquent factories, dates and higher-order collection properties more precisely.

Requirements

  • Require stable Psalm 7.0
  • Default config: Psalm 7.0 no longer reports purity suggestions by default. To keep MissingPureAnnotation, MissingAbstractPureAnnotation, MissingImmutableAnnotation and MissingInterfaceImmutableAnnotation, set suggestPurityAnnotations="true" in psalm.xml (#2196)

Features

  • Infer the factory count from factory(), new and count() on the concrete factory class, so make() / create() return one model or a collection instead of both, and custom state methods stay callable after count() (#2192)
 User::factory()->create();
-// User|Collection<int, User>
+// User
 User::factory()->count(3)->admin()->create();
-// UndefinedMagicMethod: admin()
+// Collection<int, User>
  • Type property fetches through HigherOrderCollectionProxy, so $collection->map->id is a collection of the property type, not the property type itself (#2182)
 collect($questions)->map->id->all();
-// InvalidMethodCall: string has no method all()
+// array<int, string>
  • Type Eloquent date / datetime casts as the Date::use() class instead of always Illuminate\Support\Carbon (#2004)
 // AppServiceProvider: Date::use(CarbonImmutable::class);
 $post->published_at;
-// Illuminate\Support\Carbon
+// Carbon\CarbonImmutable
  • Type created_at / updated_at without a cast or @property as the configured date class, not the raw schema string|null (#2163)
 $notification->created_at?->toIso8601String();
-// InvalidMethodCall: string has no method toIso8601String()
+// string|null
  • Read Carbon $timestamp as int, and type diffForHumans() $syntax (and its from, since, to, until, fromNow, toNow, ago aliases) as the CarbonInterface::DIFF_* constants, so an out-of-range int is reported (#2165)
 'k:' . $date->timestamp;
-// PossiblyInvalidOperand: int|float|string
+// string
  • Adopt Psalm 7.0 template defaults: Scope is Scope<TModel = Model>, and belongsToMany() / morphToMany() / morphedByMany() return the 2-argument form. A bare extends Factory whose model the plugin cannot resolve now reports MissingTemplateParam (#2189)

Fixes

  • Fix Collection::first() staying TValue|null after an isEmpty() early return (#2170)
 if ($viewables->isEmpty()) {
     return;
 }
 $model = $viewables->first();
-// class-string<Model>|null
+// class-string<Model>
  • Fix a fatal crash when a scanned facade or model class has the same name as a use import in its own file; the class is skipped with a warning and Psalm reports the file as ParseError (#2190)
  • Start Blade issue locations at the first non-blank character of the line, so the reported column and highlight skip indentation (#2169)

Full Changelog: v4.18.0...v4.18.1

Don't miss a new plugin-laravel release

NewReleases is sending notifications on new releases.