packagist psalm/plugin-laravel v4.22.1

2 hours ago

Psalm 7.9 compatibility. Plugin v4.22.0 can crash with a TypeError on Psalm 7.9 when analyzing a nullsafe property fetch through a higher-order collection proxy ($c->map?->name), so this release requires Psalm 7.9.

Requirements

  • Require vimeo/psalm ^7.9.0 (was ^7.7.0). Upgrade Psalm together with the plugin: composer update vimeo/psalm psalm/plugin-laravel (#2333)

Features

  • Type the closure parameter of eager-load constraints in with(), withOnly(), load() and loadMissing() (#1955)
 Customer::query()->with(['vehicles' => fn ($query) => $query->where('year', '>', 2020)]);
-// MissingClosureParamType, MixedMethodCall: $query was untyped
+// $query is typed as the constrained relation

Fixes

  • 🛡️ Propagate closure return taint through value(), rescue(), retry(), once(), with() and DB::transaction() (#2280)
 echo DB::transaction(fn () => (string) $request->input('name'));
-// no issue
+// TaintedHtml, TaintedTextWithQuotes
  • Type a custom caster's get() by its native return type when it has no docblock (#2294)
 // MoneyCast::get(...): Money, no docblock
 return $payment->amount->format();
-// MixedReturnStatement, PossiblyNullReference, MixedMethodCall
+// no issue
  • Report a wrong @return on template-bound groupBy() and keyBy() receivers (@template C of Collection<...>) as InvalidReturnStatement instead of accepting it (#2332)
  • Stop narrowing getKey() to int for the non-final Illuminate\Foundation\Auth\User receiver, which can use string keys (#2293)
 $key = $user->getKey();
 if (\is_string($key)) { ... }
-// TypeDoesNotContainType: Type int for $key is never string
+// no issue
  • Type __() and trans() calls with a mixed key as string (#2289)
 return '"' . __($row['message']) . '"';
-// PossiblyNullOperand, PossiblyInvalidOperand
+// only MixedArgument for the mixed key remains
  • Stop flagging custom Eloquent builder methods returning self as PossiblyUnusedReturnValue (#1449)
  • Narrow non-empty-string to non-falsy-string in Collection::filter() without a callback, since it removes "0" (#2335)

Full Changelog: v4.22.0...v4.22.1

Don't miss a new plugin-laravel release

NewReleases is sending notifications on new releases.