NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #642 most downloaded on Packagist
Psalm plugin for Laravel
Latest stable
v4.19.1
Last release 12 days ago
10 Nov 2026
Ships fairly regularly
a new release about every 9 days
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
8 years old
201 releases · first in 2019
Drag across the ruler to compare, or tap a release to open it.
Require Psalm 7.2 (#2236) @alies-dev
Http facade calls like PendingRequest calls (#2232) @alies-dev&static from Collection handlers only for a late static receiver (#2229) @alies-dev/psalm-delta (#2242) @alies-dev/psalm-delta and show why an app stopped (#2241) @alies-dev/psalm-delta harness (#2239) @alies-devFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.19.0...v4.19.1
Four runtime-failure checks on by default, typed Livewire views, and factory relation helpers.
Four runtime-failure checks on by default, typed Livewire views, and factory relation helpers.
MissingView, UnconfiguredFilesystemDisk, SerializedQueuedModel and UnknownModelAttribute now run by default: errors at errorLevel 1 to 4, info above (#2214)$this, public properties) (#2206)has{Relation}() / for{Relation}() on Eloquent factories (#2219) $user = User::factory()->hasLinks(2)->create();
-// UndefinedMagicMethod: Magic method Database\Factories\UserFactory::haslinks does not exist
+// $user is User
require 'bootstrap/app.php' in artisan and public/index.php as the booted Application (#2218)UndefinedModelRelation reporting relations defined on a model subclass (#2220)UnusedViewData false positives when a custom @include directive passes the whole scope (#2213)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.18.3...v4.19.0
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Patch release with two fixes: stubs now load when the plugin runs from psalm.phar, and Laravel 13.40's new $strict flag on request data casts is accep
Patch release with two fixes: stubs now load when the plugin runs from psalm.phar, and Laravel 13.40's new $strict flag on request data casts is accepted.
psalm.phar (Psalm 7 bundles the plugin there) (#2202)$strict parameter on str(), string(), boolean(), integer() and float() on Request, ValidatedInput (#2200)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.18.2...v4.18.3
Allow symfony/console 6.4 so Psalm 7 installs in Symfony 6.4 projects #2199
Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.18.1...v4.18.2
Full Changelog: v4.18.1...v4.18.2
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
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.
MissingPureAnnotation, MissingAbstractPureAnnotation, MissingImmutableAnnotation and MissingInterfaceImmutableAnnotation, set suggestPurityAnnotations="true" in psalm.xml (#2196)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>
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>
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
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
$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
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)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>
use import in its own file; the class is skipped with a warning and Psalm reports the file as ParseError (#2190)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.18.0...v4.18.1
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.
MissingPureAnnotation, MissingAbstractPureAnnotation, MissingImmutableAnnotation and MissingInterfaceImmutableAnnotation, set suggestPurityAnnotations="true" in psalm.xml (#2196)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>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>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\CarbonImmutablecreated_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$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
+// stringScope 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)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>use import in its own file; the class is skipped with a warning and Psalm reports the file as ParseError (#2190)Full Changelog: v4.18.0...v4.18.1
v4.18.0 brings Psalm to your Blade templates: broken references, wrong types and XSS taint in every *.blade.php, reported at the template's own file a
<img src="https://github.com/psalm/psalm-plugin-laravel/releases/download/v4.18.0/blade-hero.png" alt="Blade templates, finally checked: psalm/plugin-laravel 4.18">
v4.18.0 brings Psalm to your Blade templates: broken references, wrong types and XSS taint in every *.blade.php, reported at the template's own file and line. It also cuts a large share of Eloquent noise on PHP code.
Requires Laravel 12.27+ or 13.20+ and Psalm 7.0.0-rc16+ (details below).
Opt in with one line in psalm.xml (or per run with psalm-laravel analyze --blade):
<pluginClass class="Psalm\LaravelPlugin\Plugin">
<blade />
</pluginClass>
or alternatively using cli option --blade:
./vendor/bin/psalm-laravel --blade
Every template is analyzed as PHP under your own errorLevel, <issueHandlers>, {{-- @psalm-suppress --}} comments and baseline. A renamed enum case, a removed constant or a typo in a property name now fails the run instead of the page.
<img src="https://github.com/psalm/psalm-plugin-laravel/releases/download/v4.18.0/blade-typos.png" alt="A Blade template with a misspelled enum case and property, and the two Psalm errors pointing at template lines 9 and 10">
Psalm's taint analysis now crosses the view() boundary. Request input passed as view data and echoed raw with {!! !!} reports TaintedHtml at the template line, with the full path from the controller. {{ }} and @json() count as escaped. Taint also flows through class component properties, @include scope and anonymous components (#2036, #2046, #2047, #2106).
<img src="https://github.com/psalm/psalm-plugin-laravel/releases/download/v4.18.0/blade-taint.png" alt="A controller passes request input to a view; the template echoes it raw; Psalm reports TaintedHtml with the path from Request::input to the echo">
blade:annotate writes the view contracts for youvendor/bin/psalm-laravel blade:annotate reads the view() calls and include directives that render each template and writes the matching @var declarations (--dry-run prints the diff only). With declarations in place, view data is type checked as in PHP.
<img src="https://github.com/psalm/psalm-plugin-laravel/releases/download/v4.18.0/blade-annotate.png" alt="blade:annotate adds @var docblocks to two templates, typed from the view() calls" width="760">
Guide: docs/blade.md. Found a false positive in a template? Please open an issue with the template snippet.
<details> <summary>🌕 <b>All changes</b></summary>
conflict on laravel/framework (#1922, #1995, #2144, #2145)illuminate/* packages and orchestra/testbench-core: installing the plugin no longer pulls Laravel or Testbench into a project without Laravel. Analyzing a Laravel package (no bootstrap/app.php) needs orchestra/testbench in its dev dependencies, as in 4.17.4 (#2141, #2144)Checked without any @var:
route(), auth(), Str::), class components, @props defaultsUnregisteredRouteName, MissingView on @include, MissingTranslation{!! request('q') !!} reports TaintedHtml; {{ }} and @json() are escaped) and taint carried in from view() data, class component properties, @include scope and anonymous components (#2036, #2046, #2047, #2106) return view('search', ['q' => $request->input('q')]);
{{-- search.blade.php --}}
{!! $q !!}
+// TaintedHtml (was not reported)
With a @var declaration, the view data is type checked as in PHP. Mixed* issues are never reported in templates. A template that fails to compile is reported as BladeCompileError.
View data checks are experimental: MissingViewData, InvalidViewData and UnusedViewData compare view(), Mailable, MailMessage and @includeIsolated call sites with the template's declarations. They report at info by default; enable <experimental value="true" /> to try them as errors.
blade:annotate skips a declaration that a view composer, a first() lookup or a surrounding condition contradicts (#2122). Known limits, such as a cacheDir shared by concurrent runs, are listed in the guide (#2120). Shadow compilation and template suppressions handle more edge cases (#2121).
Apps using livewire/blaze: templates are compiled with Blaze switched off, so <x-...> tags are analyzed as standard Blade instead of Blaze's generated code (removes UnresolvableInclude, MissingParamType and PossiblyFalseArgument noise on every tag line), including when BLAZE_DEBUG is on (#2124, #2125).
psalm-laravel analyze --plugin-option=KEY=VALUE to override a plugin setting for one run (--plugin-option=experimental=true). The command line wins over psalm.xml (#1709)__invoke, middleware handle()/terminate(), queued job handle()/failed() and the queue hooks they declare. Removes UnusedMethod/UnusedProperty cascades behind invokable controllers, middleware and jobs (#1781)app(), make() and $app[...] over unions of string literals (#1802) app($flag ? CacheManager::class : DatabaseManager::class);
-// mixed
+// CacheManager|DatabaseManager
Manager::driver() as the union of create*Driver() return types when the driver name is not a literal, such as a config-driven default (#1743)withPivot() and withTimestamps() columns in BelongsToMany pivot shapes, using() custom pivots included (#1951, #1992, #2008, #2094)whereHas() and the other relation-query callbacks as the related model's builder, custom builders included (#1791, #2110) Customer::query()->whereHas('vehicles', fn ($q) => $q->whereElectric());
-// MixedMethodCall
+// $q is VehicleBuilder
Collection::tap(), pipe(), chunkWhile() and the whenEmpty() family (#1901, #2100)echo/print output is no longer an HTML sink. Removes large clusters of TaintedHtml and TaintedTextWithQuotes from console code (for example, echoed exception messages). Values stay tainted for SQL, shell and every other sink (#2068)Manager::driver() union above lets taint follow into the driver's methods, so SSRF sinks behind a manager now report (#1743)json_encode() with literal JSON_HEX_* flags, and Blade @json, as an HTML and quote escape (#1731, #1973)e(), decrypt(), encrypt() and the Collection lookup defaults (first(), get(), last(), pull(), value()), so one tainted call no longer taints every other call of the same helper (#1907, #2112)TaintedHeader for mail display names and subjects; address arguments stay sinks (#1960)parent::dispatch() (#1967)TaintedSql sinks for raw(), insertUsing(), insertOrIgnoreUsing() and rawValue() called on relations (#1739)Eloquent:
where{Column}(), as where() does. Column validation and the return type are unchanged. A null-related finding (PossiblyNullArgument) may move from the where call to the next strict use of the variable (#2113) Profile::whereUsername($user->username)->exists();
-// PossiblyNullArgument
where{Column}() calls from migration columns on models without @property docblocks, which removes most UndefinedMagicMethod and the Mixed* cascades on relation chains (on pixelfed, UndefinedMagicMethod 686 → 21) (#1934)Builder passthru methods (exists(), toSql(), insert(), raw()) on relations instead of mixed (#1739)Model::with() (#1689)@method tags (#1745)Request::user() on subclasses that override it (#1744)UnknownModelAttribute on builder and relation creation calls (create(), createMany(), forceCreateQuietly()) (#1953):columns suffixes that Laravel does not parse in UndefinedModelRelation (whereHas('posts:id', ...)) (#1949, #1984)MailMessage::text() and array MailMessage::view() in MissingView (#1692)new XFactory() and Model::factory() sound (#1968)foreignUuidFor()/foreignUlidFor() columns (#1691)MorphTo docblock types to Psalm, fixing false UndefinedClass on intersection related types (#1941)Collections and support:
Collection, Eloquent\Collection and paginator return types to the runtime: random($n), max()/min(), renumbered keys, flatMap() keys, sum(), pad()/zip(), flip(), findOrFail([...]), modelKeys() (#1898, #1915, #1922)prepend()/unshift()/add()/splice()/getOrPut() writes, and resolve closure defaults of getOrPut() and Cookie::queued() to the closure result (#1891, #2114)filter()/reject() results from a class-typed callback parameter (#1913, #1916)$default, named callbacks and same-class generics in when()/unless() return types (#1983)keyBy() keys for int-backed enum columns and resolve mixed groupBy()/keyBy() keys to array-key (#1906, #2006)Collections and make paginator stubs covariant in TValue (#1883, #1904)Cache::flexible(), Cache::sear(), Cookie::queued(), Context::scope() and Schema introspection through their facades (#1741, #1956)old() read as mixed (#2029)class_basename() (no more ArgumentTypeCoercion), and stop MissingTemplateParam on Factory::resolveFactoryName() at errorLevel 1 (#2155)Facades and aliases:
config('app.aliases') and AliasLoader aliases with class_alias() instead of an extends stub, so an alias is the target class: enum cases (Alias::Case), \Eloquent as a Model, and attribute aliases resolve. Classes that only the old stubs extended may now report ClassMustBeFinal (#2133)UndefinedMagicMethod on package facades whose root forwards calls through __call (World::countries()). Declared root methods keep their exact types; facades with their own @method tags stay sealed (#2138, #2139)Integrations:
Tools\Request again ($request->get('x') reports UndefinedMagicMethod); the 1.x stubs had dropped its method sealing (#2119)</details>
Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.17.4...v4.18.0
fix(deps): require orchestra/testbench-core only for development, and conflict on laravel/framework by @danog in https://github.com/psalm/psalm-plugin
Analyzing a Laravel package (no bootstrap/app.php) now needs orchestra/testbench in the package's dev dependencies.
Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.17.3...v4.17.4
fix(deps): stop requiring the illuminate/* packages, and require Psalm 7.0.0-rc16 by @danog in https://github.com/psalm/psalm-plugin-laravel/pull/2143
Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.17.1...v4.17.3
A small maintance release before a huge one.
A small maintance release before a huge one.
v4.17.1 is v4.17.0 made compatible with Psalm 7.0.0-rc10, which it now requires. No new features. Upgrade Psalm and the plugin together:
composer update psalm/plugin-laravel:^4.17.1 -W --dev
Expect more taint findings after the upgrade, whichever plugin version you run. Psalm rc10 follows taint through more steps, so sources the plugin already declared (decrypt(), Session::pull(), HTTP client responses) now reach sinks that beta23 never connected.
vimeo/psalm ^7.0.0-rc10 and psalm/psalm-plugin-api ^0.4.1InvalidDocblock issues that Psalm rc reports from the plugin's own IndexDefinition and Application stubs in every project. Application::getProviders() is now typed array<class-string<ServiceProvider>, ServiceProvider> (#1868)blank(), filled(), transform(), throw_if() and throw_unless() precise on Psalm rc6+, which removes false RedundantConditionGivenDocblockType reports such as if (blank($search)) (#1965) $search = str($search)->trim();
if (blank($search)) { /* ... */ }
-// RedundantConditionGivenDocblockType: Operand of type true is always truthy
getCollection() a Support\Collection for non-model values on Psalm rc6+ (#1966)StreamableAgentResponse::$citations, added in recent laravel/ai 0.11.x releases…the plugin when a vendor file raised a load-time deprecation
Two opt-in rules that catch typos in route names and filesystem disks, plus sharper inference for Eloquent relations, aggregate attributes, when()/unless() callbacks, and Collection::filter(). How to enable them in your psalm.xml:
<pluginClass class="Psalm\LaravelPlugin\Plugin">
<findMissingViews value="true" />
<findUnregisteredRouteNames value="true" />
</pluginClass>
or enable experimental features:
<pluginClass class="Psalm\LaravelPlugin\Plugin">
<experimental value="true" />
</pluginClass>
UnregisteredRouteName rule for route names missing from the booted app's route table: route(), to_route(), URL::route()/signedRoute()/temporarySignedRoute(), Redirect::route(), redirect()->route(), url()->route(). Enable with <findUnregisteredRouteNames value="true" /> or <experimental value="true" /> (#1573) return redirect()->route('users.shwo', $user);
+// UnregisteredRouteName: Route name 'users.shwo' is not registered
UnconfiguredFilesystemDisk rule for Storage::disk() names absent from filesystems.disks, with a closest-name suggestion. Enable with <findUnconfiguredFilesystemDisks value="true" /> or <experimental value="true" />. \Storage::disk() now also narrows to FilesystemAdapter like the facade (#1571) Storage::disk('publik')->put($path, $contents);
+// UnconfiguredFilesystemDisk: Disk 'publik' is not configured in filesystems.disks, did you mean 'public'?
when()/unless() callback parameters from the condition value: when() passes the truthy value, unless() the falsy one, and a Closure condition passes its return type (#1645) /** @var ?int $limit */
$query->when($limit, function (Builder $q, string $limit) { /* ... */ });
-// no issue: the callback parameter was never checked
+// InvalidArgument: when expects callable(Builder<...>, int):mixed|null, but Closure(Builder, string):void provided
return $this->allRevisions()->where(...)) (#1646) // HasPaymentSlips trait: public function paymentSlips(): MorphMany { return $this->morphMany(PaymentSlip::class, 'owner'); }
$member->paymentSlips();
-// MorphMany<Model, Model>
+// MorphMany<PaymentSlip, Member>
Collection::filter(callable) like where(callable), and recognize is_subclass_of(), is_a(), is_scalar(), is_iterable(), is_resource() and null checks (!is_null($x), $x !== null) in both (#1651) $items->filter(fn (Countable $x): bool => $x instanceof Stringable);
-// Collection<int, Countable>
+// Collection<int, Countable&Stringable>
$classes->filter(fn (string $c): bool => is_subclass_of($c, Job::class));
-// Collection<int, string>
+// Collection<int, class-string<Job>>
{relation}_count / {relation}_exists as nullable unless withCount()/withExists()/loadCount()/loadExists() is proven on that model (or the relation is in $withCount), and type withMin/withMax/withSum/withAvg attributes from the related column's type (#1628) $post->comments_count ?? $post->loadCount('comments')->comments_count;
-// RedundantCondition: comments_count was always int
+// no issue: int|null until a count is proven loaded
Model as @psalm-consistent-constructor, so new $class() on a class-string<Model> is no longer UnsafeInstantiation. A model overriding __construct with an incompatible signature is now reported, since Eloquent's own new static($attributes) already breaks on it (#1626) /** @param class-string<Model> $class */
function make(string $class): Model { return new $class(); }
-// UnsafeInstantiation
+// no issue
Collection in BelongsToMany::sync(), syncWithoutDetaching(), syncWithPivotValues() and their Laravel 13 *OrFail() variants (#1644) $user->roles()->sync($roles->pluck('id'));
-// InvalidArgument / ImplicitToStringCast
+// no issue
$this as the declaring model for relation calls inside non-final models, so return $this->rel()->where(...) no longer reports MoreSpecificReturnType / LessSpecificReturnStatement (#1629, #1632)SoftDeletes methods per receiver model on a generic custom builder shared by a parent and child model, instead of whichever model was scanned last (#1638)@psalm-mutation-free from Request::input(), which lazily decodes JSON: a FormRequest overriding input() is no longer flagged (#1627)$request->input(...), Artisan::command(...), Job::dispatch(...)) with zend.assertions=1 (#1659)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.16.6...v4.17.0
v4.16.6 restores vendor methods on stubbed Laravel classes that silently resolved to mixed, and tightens docblock types for console, events, facades,
v4.16.6 restores vendor methods on stubbed Laravel classes that silently resolved to mixed, and tightens docblock types for console, events, facades, mail, and relations.
mixed when nothing in the project named that class before the plugin's stubs loaded. Psalm then skipped the class's vendor file, so with __call (Macroable) every method the stub did not declare became mixed with no issue reported. Affected classes included Events\Dispatcher, Http\Client\PendingRequest, Http\Client\Response, FormRequest, Pipeline, and several facades (#1616, #1618) app('events')->hasListeners('order.shipped');
-// mixed
+// bool
Artisan::all() and Console\Kernel::all() (contract and concrete) as array<array-key, Command> instead of array (#1612) $commands = Artisan::all();
-// array<array-key, mixed>
+// array<array-key, Symfony\Component\Console\Command\Command>
DB::getQueryLog() entries and Schema::getColumnListing() with the shapes Connection and Schema\Builder already document, instead of the facades' plain array (#1612) $log = DB::getQueryLog();
-// array<array-key, mixed>
+// list<array{query: string, bindings: array<array-key, mixed>, time: float|null, readWriteType?: string|null}>
until(), dispatch() with $halt = true) on Events\Dispatcher, its contract, and the Event facade as mixed: it returns the first non-null listener response, not array|null (#1612)MailMessage properties ($view nullable; $from, $replyTo, $attachments, $rawAttachments with the shapes MailChannel accepts), MailMessage::render() as HtmlString|string, and Notification::$id as string|null (#1612)Collection of related models in BelongsToMany::saveMany() and saveManyQuietly(), and keep its type on return (#1612)Reflector::getParameterClassNames() as list<string>, Route::methods() as array<string>, accept null in Migrator::usingConnection(), and mark UrlGenerator's resolver, formatter, and forced root/scheme properties nullable (#1612)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.16.5...v4.16.6
v4.16.5 moves the Psalm 7 floor to 7.0.0-beta23.
v4.16.5 moves the Psalm 7 floor to 7.0.0-beta23.
vimeo/psalm ^7.0.0-beta23 and psalm/psalm-plugin-api ^0.3.0. Psalm 7.0.0-beta23 pins psalm/psalm-plugin-api 0.3.0, so v4.16.4 could not be installed next to it (#1606)ResponseFactory::make() call is no longer hidden by an attachment download elsewhere in the project (#1606, via vimeo/psalm#12037)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.16.4...v4.16.5
v4.16.4 moves the Psalm 7 floor to 7.0.0-beta22, adds a header-injection sink for response headers, and fixes facade and Pipeline inference gaps.
v4.16.4 moves the Psalm 7 floor to 7.0.0-beta22, adds a header-injection sink for response headers, and fixes facade and Pipeline inference gaps.
vimeo/psalm ^7.0.0-beta22 and psalm/psalm-plugin-api ^0.2.0. Psalm 7.0.0-beta21 renamed the internal taint node factory, so older betas no longer work with this release (#1455, #1456, #1587)TaintedHeader: the $headers argument of ResponseFactory::make() (direct, contract, and facade forms), the three-argument response() helper, and new Response() is now a header sink. The attachment exemption still applies only to the TaintedHtml content finding (#1575) $title = $request->input('team');
return response()->make($csv, 200, [
'Content-Disposition' => "attachment; filename=\"{$title}.csv\"",
]);
-// before: no issue
+// now: TaintedHeader: Detected tainted header
alies-dev/psalm-plugin-pest instead of psalm/plugin-phpunit in psalm-laravel init when the project requires pestphp/pest (#1596)App::environment() to bool when called with environment names and to string without arguments, instead of the facade's unconditional string|bool (#1453) $isProd = App::environment(['production', 'staging']);
-// string|bool
+// bool
Pipeline::through() and Pipeline::pipe(), matching Laravel's Pipeline::carry() (#1590) $pipeline->through(new AuthenticateMiddleware());
-// InvalidArgument: Argument 1 of Pipeline::through expects array<Closure|callable|string>|Closure|callable|string, but AuthenticateMiddleware provided
+// accepted, returns Pipeline&static
Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.16.1...v4.16.4
v4.16.1 refines the v4.16.0 laravel/ai and MissingView work: exempts annotated prompt guards from TaintedLlmPrompt, extends MissingView to mailables,
v4.16.1 refines the v4.16.0 laravel/ai and MissingView work: exempts annotated prompt guards from TaintedLlmPrompt, extends MissingView to mailables, and fixes a Redis facade regression.
laravel/ai middleware guards annotated with @psalm-taint-escape llm_prompt from TaintedLlmPrompt, so a blocking prompt-injection guard (e.g. promptphp/intercept) silences the finding at its dispatched handle()/__invoke() method (#1441)final class PromptInjectionGuard
{
/** @psalm-taint-escape llm_prompt */
public function handle(AgentRequest $request, Closure $next) { /* ... */ }
}
// agent's middleware() resolves to [PromptInjectionGuard::class]
// TaintedLlmPrompt no longer fires on prompts passing through it
Mailables\Content constructors and extend MissingView to Mailable::view()/markdown()/text() and view Factory::composer()/creator() (#1431, #1432) new Content(view: 'emials.welcome');
-// before: no issue
+// now: MissingView: View 'emials.welcome' not found in any of the registered view paths
Redis::pipeline()/transaction() callback results as list<mixed> instead of reporting UndefinedMagicMethod (#1427) Redis::pipeline(fn ($pipe) => $pipe->get('key'));
-// before: UndefinedMagicMethod: Magic method Illuminate\Support\Facades\Redis::pipeline does not exist
+// now: list<mixed>
handle(), and controller-action return values as framework-consumed, fixing spurious PossiblyUnusedReturnValue under --find-unused-code (#1434)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.16.0...v4.16.1
v4.16.0 adds taint-analysis support for the `laravel/ai` package: prompt-injection detection plus tracking of LLM output into SQL, shell, and HTML sin
v4.16.0 adds taint-analysis support for the laravel/ai package: prompt-injection detection plus tracking of LLM output into SQL, shell, and HTML sinks. It also extends MissingView to every view-name-bearing API and ships several new type-narrowing features.
The plugin now understands laravel/ai (>=0.11.0 <1.0.0, #937). The integration loads only when Composer reports the package installed; apps without it get no extra stubs or handlers. TaintedLlmPrompt is enabled automatically at its normal error level; <findPromptInjection value="false" /> turns off prompt-input findings while keeping model-output findings.
Untrusted data (request input, HTTP responses, tool arguments, retrieved documents) reaching an LLM prompt is reported:
final class SupportAgent
{
use \Laravel\Ai\Promptable;
}
(new SupportAgent())->prompt($request->input('question'));
// 🔴 TaintedLlmPrompt: Detected tainted LLM prompt
LLM output is treated as a taint source, so it is followed into the existing SQL, shell, file, and HTML sinks:
function run(\Laravel\Ai\Responses\AgentResponse $response): void {
DB::select($response->text);
}
// 🔴 TaintedSql: raw model output interpolated into a query
MissingView beyond view() and Factory::make() to Factory::first()/renderWhen()/renderEach(), response()->view(), Route::view(), MailMessage::view()/markdown(), and assertViewIs() (#1407) Route::view('/welcome', 'welcom');
// 🔴 MissingView: View 'welcom' not found in any of the registered view paths
Arr::get() value type from known array shapes, including dot-notation keys and $default handling (#1402) /** @param array{a: int} $data */
$value = Arr::get($data, 'a');
-// before: mixed
+// now: int
Manager::driver() to its create*Driver() return type, including the no-argument default-driver form (#1410) final class ShippingManager extends Manager
{
public function getDefaultDriver(): string { return 'ups'; }
public function createUpsDriver(): Shipper { return new UpsShipper(); }
}
$manager->driver('ups'); // Shipper
-$manager->driver(); // was: mixed
+$manager->driver(); // now: Shipper
getCollection() to a model's custom Eloquent collection (#1408) #[CollectedBy(WorkOrderCollection::class)]
class WorkOrder extends Model {}
WorkOrder::query()->paginate()->getCollection();
-// before: Eloquent\Collection<int, WorkOrder>
+// now: WorkOrderCollection<int, WorkOrder>
TaintedHtml for response()->make() bodies explicitly served as attachments (#1348) response()->make($csv, 200, ['Content-Disposition' => 'attachment; filename="export.csv"']);
-// before: TaintedHtml
+// now: no issue — the response is a download, not rendered HTML
new Illuminate\Http\Response(...), and safe literal Content-Type values; HTML, XML, SVG, and script types stay reported (#1417)PersonalAccessToken binding for models using HasApiTokens without an explicit @use annotation, fixing spurious MissingTemplateParam (#1425)HasFactory bindings from newFactory(), static $factory, and #[UseFactory] without suppressing unrelated MissingTemplateParam diagnostics on the model (#1423)handle() methods, Eloquent relations) so --find-unused-code stops flagging them as dead (#1422)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.15.7...v4.16.0
Taint accuracy for named arguments, plus three Eloquent and Collection narrowings.
Taint accuracy for named arguments, plus three Eloquent and Collection narrowings.
// sinkNamed(string $path = 'safe', string $label = 'x'), file sink on $path
sinkNamed(label: (string) $request->input('page'));
-// TaintedFile (before): the taint landed on $path, which never saw the request
+// no issue: the argument is attributed to $label
AbstractPaginator::getCollection() and AbstractCursorPaginator::getCollection() to Eloquent\Collection when the paginator holds models (#1397). The 33 methods that exist only on the Eloquent collection (load*, find, fresh, modelKeys, toQuery, ...) are now reachable. $users = User::paginate();
$users->getCollection()->load('posts');
-// UndefinedMethod (before): Support\Collection<int, User> has no load()
+// now resolves: Eloquent\Collection<int, User>
select() stubs for Collection, LazyCollection, and Eloquent\Collection (#1399), including the select(null) branch and the variadic form. $rows = collect([['a' => 1, 'b' => 2]])->select('a');
-// Collection<array-key, mixed>&static (before); select('a', 'b') reported TooManyArguments
+// Collection<array-key, array<array-key, mixed>>
Auth::guard() and Auth::shouldUse() when the guard name is a string-backed enum case (#1405). Previously any non-literal argument dropped all narrowing back to the bare contract. Auth::guard(Guards::Admin)->user();
-// Illuminate\Contracts\Auth\Guard (before)
+// now resolves through SessionGuard to the configured user model
<experimental value="true" /> now also enables findSerializedQueuedModels, unless the project sets that flag explicitly (#1400). experimental is the early-access switch for rules that are off by default and on their way to becoming default.Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.15.6...v4.15.7
Two new inference sources for Eloquent-backed code, one new opt-in queue-safety rule, and three false-positive fixes across migrations, model attribut
Two new inference sources for Eloquent-backed code, one new opt-in queue-safety rule, and three false-positive fixes across migrations, model attribute helpers, and pipelines.
SerializedQueuedModel rule for ShouldQueue classes that hold an Eloquent model without reaching Illuminate\Queue\SerializesModels, where the whole model is written into the queue payload instead of a ModelIdentifier (#1385). Enable with <findSerializedQueuedModels value="true" />. Detection resolves the flattened __serialize() / __sleep() rather than matching the trait name, so framework bases that already pull the trait in (Illuminate\Foundation\Queue\Queueable, Illuminate\Notifications\Notification) and classes that hand-write their own serialization stay silent. final class ReconcileLedger implements ShouldQueue
{
public function __construct(private Customer $customer) {}
- // silent: the entire Customer row is written into the queue payload
+ // SerializedQueuedModel: $customer will be serialized whole into the queue payload
}
Arr::pluck() value and key types from the element model's @property annotations, matching what Collection::pluck() and Builder::pluck() already do (#1383). /** @param list<Customer> $rows */ // Customer has @property string $id
-Arr::pluck($rows, 'id'); // array<array-key, mixed>
+Arr::pluck($rows, 'id'); // list<string>
$schema = Schema::connection(...) in migrations, so columns declared through a variable-held builder (#1382).Model::getAppends() and Model::getMutatedAttributes() to list<string>, so callers no longer have to re-assert the element type (#1381).Pipeline::then() from its destination closure instead of leaving it mixed (#1376).Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.15.5...v4.15.6
Taint precision and Eloquent type narrowing. Two taint fixes remove a duplicate finding and close a missed SQL injection, and four type fixes sharpen
Taint precision and Eloquent type narrowing. Two taint fixes remove a duplicate finding and close a missed SQL injection, and four type fixes sharpen inference on facades, collections, and the query builder.
@method tags, so templated facade methods resolve their real return type (#1370) $value = Cache::remember('key', 60, fn (): User => User::first());
-// mixed — the generated @method tag outranked the plugin's stub
+// User
groupBy() and keyBy() keys for model columns instead of widening to array-key (#1369) $byId = User::all()->keyBy('id');
-// Collection<array-key, User>
+// Collection<int, User>
chunkById() callback like chunk(), so the chunk is a templated collection rather than mixed (#1373) Article::query()->chunkById(100, function ($chunk) { ... });
-// $chunk: mixed
+// $chunk: Collection<int, Article>
$fetchUsing argument on DB::select(), DB::selectResultSets(), DB::cursor(), and their Connection counterparts, while keeping the three-argument signature an error on Laravel 12 (#1374) DB::cursor('select * from users', [], true, [PDO::FETCH_ASSOC]);
-// TooManyArguments — the stub declared three parameters
+// accepted on Laravel 13; still TooManyArguments on Laravel 12
Row types follow the fetch mode, so a custom $fetchUsing no longer claims stdClass:
$rows = DB::cursor('select 1'); // Generator<int, stdClass>
$assoc = DB::cursor('select 1', [], true, [PDO::FETCH_ASSOC]);
-// Generator<int, stdClass>
+// Generator<int, mixed>
TaintedInclude only, not also TaintedFile (#1358). A view name selects which template executes; it cannot reach an arbitrary path, because the view finder rewrites . to / and appends a fixed extensionWhereColumnTaintHandler's removal bridge on the AST node itself rather than spl_object_id, closing a missed SQL injection (#1366). Psalm frees foreign ASTs mid-file, so a reissued object handle could hit a stale record and strip sql taint from an unrelated expressionFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.15.4...v4.15.5
Extends taint reporting to the call forms Laravel applications actually write — facade statics, response() on its contract, and view() names — and cle
Extends taint reporting to the call forms Laravel applications actually write — facade statics, response() on its contract, and view() names — and clears the false positives that surfaced alongside it.
response() contract methods, and view() names (#1318). A facade's surface is @method pseudo-methods resolved through __callStatic, whose parameters have no docblock to carry a sink, so the static form was silent while the chained form fired. Redirect::to($request->input('next'));
-// silent: the facade pseudo-parameter carried no sink
+// TaintedHeader: Detected tainted header
$with and $withCount (#1321). Supports dotted paths, column selectors, and the $withCount alias grammar; defers when an intermediate related model cannot be resolved. class Post extends Model
{
protected $with = ['auther'];
- // silent: eager-load defaults were never validated
+ // UndefinedModelRelation: relation 'auther' is not defined on Post
}
@psalm-taint-escape on closure validation rules (#1352), in inline validate() arrays, in FormRequest rules(), and when the closure is the field's whole rule. Previously the only way to assert a rule made a value safe was to extract it into a dedicated Rule class. $request->validate([
'path' => ['required', /** @psalm-taint-escape file */ static fn ($attr, $value, $fail) => /* ... */],
]);
-// TaintedFile: a closure body is opaque, so no rule could assert safety
+// clean
TaintedSql false positives on where() array values for nullable, template-bounded, and intersection builder receivers (#1338, #1350). Values in the map form are PDO-bound, but a receiver typed Builder|null, @template T of Builder, or T&Builder declined the strip. /** @param Builder|null $query */
$query->where(['status' => $request->input('status')]);
-// TaintedSql: Detected tainted SQL
+// clean
TaintedFile on uploaded-file extensions (#1324, #1325). getClientOriginalExtension() is the tail after the final dot of a normalized basename and cannot introduce a path segment, and clientExtension() returns a value from Symfony's MIME registry rather than raw client input. All other taint kinds, including include, are unchanged. Storage::putFileAs('uploads', $file, Str::ulid() . '.' . $file->getClientOriginalExtension());
-// TaintedFile: Detected tainted file handling
+// clean
Suppress cross-class taint flow through the Dispatchable traits (#1334). Psalm conflated taint nodes from the shared trait bodies, so an argument dispatched to one job appeared to reach an unrelated job's constructor sink. Genuine Bus and Event taint is still reported.
Fingerprint the migration schema cache on file contents instead of modification times (#1346). A git clone stamps every file with the checkout time, so the fingerprint changed on every CI run and the cache never hit even when the restored schema was still valid.
Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.15.3...v4.15.4
Taint precision for where() array forms and redirect responses.
Taint precision for where() array forms and redirect responses.
TaintedSql false positives on where([[...]]) nested-condition arrays: a static receiver spelling (Model::where(...)) skipped the strip entirely, and the inner condition value was scalar-gated so any mixed-typed request value (the common case) kept the sink. Also closes a false negative where a Model subclass with its own concrete where() override had its real sink stripped (#1314). $term = (string) $request->input('term');
-User::where([['name', '=', $term]])->get();
-// TaintedSql (false positive) -- static receiver wasn't recognized as PDO-bound
User::where([['code', '=', $request->keyword]])->first();
-// TaintedSql (false positive) -- mixed-typed value failed the scalar gate
+// clean -- both forms are PDO-bound, matching the instance-receiver behavior
TaintedSSRF incorrectly firing alongside TaintedHeader on redirect() and the Redirector/ResponseFactory redirect family. A redirect sets a Location header for the browser to follow; the server makes no outbound request, so it's an open-redirect/header-injection sink, not SSRF (#1315).-return redirect($request->url());
-// TaintedSSRF + TaintedHeader (SSRF was mislabelled)
+return redirect($request->url());
+// TaintedHeader only
Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.15.2...v4.15.3
Taint-analysis precision for the query where() family. Resolves the TaintedSql inconsistency from #1300 (the same safe query reported or stayed silent
Taint-analysis precision for the query where() family. Resolves the TaintedSql inconsistency from #1300 (the same safe query reported or stayed silent depending on how it was written), and closes two SQL source/sink gaps.
Request::__get() as user input, so $request->term carries taint like $request->input('term') (#1305). DB::table('t')->whereRaw((string) $request->input('term')); // TaintedSql
-DB::table('t')->whereRaw((string) $request->term); // silent
+DB::table('t')->whereRaw((string) $request->term); // TaintedSql
whereColumn() / orWhereColumn() on all three identifier positions, which the grammar emits raw (#1308).-$builder->whereColumn((string) $request->input('c'), '=', 'other'); // silent
+$builder->whereColumn((string) $request->input('c'), '=', 'other'); // TaintedSql
where() sql-taint strip on a Laravel builder receiver, so a non-builder where(array $parts) that interpolates raw SQL keeps its report (#1311).where() array forms raising a false TaintedSql on PDO-bound value positions; the strip now walks the array literal element-wise and keeps the sink only on raw-identifier positions (#1302, fixes #1300). $term = (string) $request->input('term');
-Model::where([['name', 'LIKE', "%{$term}%"]]); // TaintedSql (false positive)
+Model::where([['name', 'LIKE', "%{$term}%"]]); // clean — value is PDO-bound
whereLike-family $value param to mixed, matching where() and the PDO-bound runtime, so idiomatic calls stop reporting false positives (#1312).-Model::whereLike('name', $request->query('q')); // PossiblyInvalidArgument
+Model::whereLike('name', $request->query('q')); // clean
Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.15.1...v4.15.2
This release improves Eloquent pluck() and builder type narrowing, plus primary-key and factory binding inference.
This release improves Eloquent pluck() and builder type narrowing, plus primary-key and factory binding inference.
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
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>
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
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
// 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: https://github.com/psalm/psalm-plugin-laravel/compare/v4.15.0...v4.15.1
v4.15.0 ships the 2nd biggest architectural change in the plugin's history: ModelMetadataRegistry, a single per-model metadata store that replaces the
v4.15.0 ships the 2nd biggest architectural change in the plugin's history: ModelMetadataRegistry, a single per-model metadata store that replaces the ad-hoc reflection and private caches every Eloquent handler used to maintain on its own. This release builds three new model-correctness diagnostics on top of it, validating attributes and relationships on your models, plus a more precise serialization inference — and it's the foundation a lot more diagnostics are planned to build on next.
UnknownModelAttribute and UndefinedModelRelation report at info by default. Opt into error with <experimental value="true" />.UnresolvableAppendedModelAttribute reports at error by default: a $appends entry with no matching accessor or cast now fails analysis. Downgrade it with a standard issueHandlers entry if that doesn't fit your codebase yet.attributesToArray() / toArray() now infer a precise array shape. Always active, no config needed.ModelMetadataRegistry, a per-model metadata store warmed once during AfterCodebasePopulated and shared read-only across every Eloquent handler (#1081, #1201)experimental psalm.xml config flag to promote experimental features for early adopters (#1248)UnknownModelAttribute: flags a create()/fill()/update() key with no backing column, cast, accessor, $appends entry, or @property (#1167) Model::create(['nmae' => 'value']);
-// silently drops the typo, sets nothing
+// UnknownModelAttribute: 'nmae' matches no column, cast, accessor, $appends entry, or @property
UnresolvableAppendedModelAttribute: flags a $appends entry with no accessor or cast to actually produce it (#1169)UndefinedModelRelation: validates relation names passed to with()/load()/has()/whereHas() against the resolved model (#1181) Customer::with('vehicles.typoOnVehicle');
-// no warning, silently ignored at runtime
+// UndefinedModelRelation: Relation 'typoOnVehicle' is not defined on App\Models\Vehicle
attributesToArray()/toArray(), honoring casts, hidden, and appended attributes (#1168, #1184)whereDate two-argument overload (#1247)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.14.12...v4.15.0
Narrow several producer and validation return types to their concrete implementations, plus fixes for Cache::driver()->flexible() and monorepo init sc
Narrow several producer and validation return types to their concrete implementations, plus fixes for Cache::driver()->flexible() and monorepo init scanning.
Password::broker(), view()/trans(), and query builder pagination results to their concrete Laravel implementation (#1240) Password::broker()->createToken($user);
-// UndefinedInterfaceMethod (before): createToken() only exists on the concrete broker
+// now resolves: typed as Auth\Passwords\PasswordBroker
view('welcome')->fragment('x');
-// UndefinedInterfaceMethod (before): fragment() only exists on Illuminate\View\View
+// now resolves: typed as View\View
integer()/boolean() accessors and rule-bound integer fields from validation rules (#1239, #1237)UndefinedInterfaceMethod false positive on Cache::driver()->flexible() (#1233)<projectFiles> in psalm-laravel init on Composer monorepos (#1235)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.14.11...v4.14.12
Collection type inference for arbitrary inputs, and partial Laravel boots now surface instead of failing silently.
Collection type inference for arbitrary inputs, and partial Laravel boots now surface instead of failing silently.
This release bumps min supported Laravel minor versions:
collect(), Collection::make(), and LazyCollection::make() return types for arbitrary inputs, not just arrays (#1225) collect('hello');
-// InvalidArgument (before): string wasn't Arrayable|iterable|null
+// now infers: Collection<0, 'hello'>
collect(BackedSuit::Hearts);
-// InvalidArgument (before): enum cases weren't accepted either
+// now infers: Collection<0, BackedSuit>
collect(null);
-// before: Collection<array-key, mixed> (unbound fallback)
+// now infers: Collection<never, never>
bootstrap() failures: a partial Laravel boot now emits a warning by default, and fails the run under failOnInternalError (#1226)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.14.10...v4.14.11
A patch release that removes three false positives around query builders and taint analysis, and fixes a psalm-laravel init misconfiguration on monore
A patch release that removes three false positives around query builders and taint analysis, and fixes a psalm-laravel init misconfiguration on monorepos.
TaintedSql on where() calls that pass a column-to-value map (where(['name' => $value])) (#1221)UndefinedMagicMethod on custom Eloquent builder subclass methods called after a fluent chain (#1219)UndefinedMagicMethod on IndexDefinition modifiers in database migrations (#1220)psalm-laravel init on monorepos: no longer puts packages/ into <ignoreFiles>, which silently disabled analysis of package sources (#1214)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.14.9...v4.14.10
This release improves custom Eloquent builder inference and narrows several stub return types.
This release improves custom Eloquent builder inference and narrows several stub return types.
newQuery(), newQueryWithoutScopes(), etc. (#1207)getCasts() and getTouchedRelations() return types (#1205)Request::route()/Request::file() default value handling (#1205)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.14.8...v4.14.9
Patch release fixing Psalm execution on Windows.
Patch release fixing Psalm execution on Windows.
proc_open(): CreateProcess failed warning on Windows by executing psalm through the current PHP binary instead of relying on the shebang (#1189) @HenkPoleyFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.14.7...v4.14.8
Fixes caching issue, that makes Psalm complaining about CastsAttributes.
Fixes caching issue, that makes Psalm complaining about CastsAttributes.
CastsAttributes: Restore user_defined on cast contracts on warm cache (#1188)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.14.6...v4.14.7
Narrow sum/avg/min/max return types on relations and collections instead of widening to mixed
sum/avg/min/max return types on relations and collections instead of widening to mixed (#1183)UndefinedMethod on forwarded Query\Builder methods in custom builder subclasses (#1145)migrator resolution when the app bootstraps partially, avoiding a crash during analysis (#1175)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.14.5...v4.14.6
This patch sharpens conditional return types for several Laravel helpers and guards against two crash paths during partial app bootstrap.
This patch sharpens conditional return types for several Laravel helpers and guards against two crash paths during partial app bootstrap.
Pagination::fragment(), Arr::random(), and Lottery::choose() (#1176)Route::domain() so it narrows $this vs string (#1174)Paginator::through() to the updated template after the callback (#1173)migrator resolution so analysis no longer crashes when the app bootstraps partially (#1175)psalm-laravel analyze through to psalm CLI (#1158)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.14.4...v4.14.5
This patch sharpens type inference across collections, the console, and the Date facade.
This patch sharpens type inference across collections, the console, and the Date facade.
Command::hasArgument()/hasOption() to literal bool, and fix hasOption() shortcut/negation semantics (#1161)Date facade static calls (#1157)literal() helper (#1160)config()->collection() to Collection<key, value> (#1159)random() return type on Enumerable and LazyCollection (#1152)null option shortcut in Command::getOptions() (#1166)Model::loadCount() constraint closure as Builder (#1164)null values in the __() $replace parameter (#1151)SessionGuard::hashPasswordForCookie() on Laravel 11 (#1146)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.14.2...v4.14.4
Patch release: fewer false positives on Laravel's Application contract and uploaded files, plus a simpler (but more powerful and secure) generated CI
Patch release: fewer false positives on Laravel's Application contract and uploaded files, plus a simpler (but more powerful and secure) generated CI workflow added via psalm-laravel add ci.
Application methods (isProduction(), isLocal(), path(), ...) when the receiver is typed on the Contracts\Foundation\Application interface, eliminating false UndefinedInterfaceMethod on app(), ServiceProvider::$app, and Command::$laravel (#1141)TaintedFile / TaintedSSRF on UploadedFile reads: its only string coercion is the server-controlled temp path, while the user-controlled accessors (contents, client name, MIME type) stay tainted (#1136)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.14.1...v4.14.2
Patch release focused on Eloquent and query builder type accuracy, plus follow-up fixes to console closures and facade method resolution.
Patch release focused on Eloquent and query builder type accuracy, plus follow-up fixes to console closures and facade method resolution.
$this in Artisan::command() closures so command callbacks resolve $this to the command instance (#1122 #1127)UndefinedMethod on app('encrypter') method calls (#1128)UndefinedMethod on guard methods reached via auth() narrowing (#1121)tap() form as HigherOrderTapProxy<T> (#1112)orderBy() direction ('ASC'/'DESC') on Laravel <13.8 (#1111)Query\Builder::orderBy() direction as asc/desc literals plus SortDirection (#1104)Expression as the $sql argument to Query\Builder::whereRaw() (#1106)Filesystem::hash() return as non-empty-string|false (#1109)find() (#1105)firstOrNew/updateOrCreate closure values on Laravel 13.5+ (#1102)Connection::cursor() rows as stdClass instead of mixed (#1100)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.14.0...v4.14.1
v4.14.0 spans Eloquent type inference and security: three new security detectors, relationship and filesystem narrowing, paginator fixes, and an opt-i
v4.14.0 spans Eloquent type inference and security: three new security detectors, relationship and filesystem narrowing, paginator fixes, and an opt-in query-builder best-practice rule.
html_url taint kind for URL-context XSS distinct from e() (#1014)ImplicitQueryBuilderCall rule for direct model query and scope calls. It requires writing User::query()->where(...) instead of User::where(...) (#1068)MissingTemplateParam on in-body belongsToMany()/morphToMany() pivot chains (#1090)mixed collapse when chaining off relation methods, by replacing $this with static in generic templates and using @template-covariant for relationships (#1055)Storage::disk() to FilesystemAdapter so temporaryUrl() and url() resolve (#1093)FilesystemAdapter listing methods to list<string> (#1094)FormRequest magic property reads ($request->field calls) (#1022)app(Foo::class) as Foo when the booted app cannot resolve it (Laravel packages) (#1076)UndefinedMethod on $app->when()->needs() chains (#1077)when()/unless() callback return types (#997)paginate() and preserve the related-model template through relations (#1082)PossiblyUnusedMethod on Eloquent trait boot/initialize hooks (#1080)^12.4 (#1089)/psalm-delta workflow to benchmark the plugin over real apps and libraries (#1079, #1086, #1084)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.13.2...v4.14.0
Add PublicModelScope and PublicModelAccessor rules for public model scopes and accessors (#1056) @alies-dev
PublicModelScope and PublicModelAccessor rules for public model scopes and accessors (#1056) @alies-devScopes and Eloquent:
Builder<Model> from $class::query() (#1073) @alies-dev->orWhere->scope()) (#1066) @alies-devOther:
App::make() facade calls to the resolved class (#1072) @alies-devFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.13.1...v4.13.2
Fix trait-hosted #[Scope] detection and scope-vs-QueryBuilder params precedence (#1046) @alies-dev
#[Scope] detection and scope-vs-QueryBuilder params precedence (#1046) @alies-devInvalidArgument on addGlobalScope closures with bare Builder params (#1045) @alies-devFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.13.0...v4.13.1
A comprehensive overhaul of Eloquent query-scope analysis: instance scope calls on the base Builder, self/static scope parameters, direct-vs-forwarded
A comprehensive overhaul of Eloquent query-scope analysis: instance scope calls on the base Builder, self/static scope parameters, direct-vs-forwarded dispatch, and variadic / name-collision handling.
Builder to Builder<Model> instead of mixed, type-checking arguments against the scope's declared params (#1032)self/static scope parameters to the model on custom builders, removing false InvalidArgument and Model&static over-narrowing (#1033)?Builder, variadic, and non-variable first arguments resolve correctly (#1041)Eloquent\Builder method such as find() (#1042)$query explicitly to keep the real method signature, with no left-shifted arguments (#1035)$query to use the real return type instead of a fabricated Builder<Model> (#1036)self parameters to resolve to the composing class, so a sibling subclass is accepted instead of rejected with a false InvalidArgument (#1043)InvalidArgument message for a bad scope argument now names the composing parent (e.g. AbstractDocument) instead of the queried child (e.g. Contract) (#1031, #1043). No migration needed; the diagnostic is simply more accurate.Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.12.4...v4.13.0
<!-- Release notes generated using configuration in .github/release.yml at master -->
<!-- Release notes generated using configuration in .github/release.yml at master -->
The same as v4.12.3 (that was initially tagged on a wrong branch)
md5() / sha1() (CWE-328) by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/1012Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.12.2...v4.12.4
Resolve custom CastsAttributes / Castable casts to real types (#1020) @alies-dev
CastsAttributes / Castable casts to real types (#1020) @alies-devCollection::where() return types (#1019) @alies-devFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.12.1...v4.12.2
Narrow $this->input() return type inside FormRequest by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/1017
$this->input() return type inside FormRequest by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/1017Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.12.0...v4.12.1
Narrow config() and Repository::get() return types (#1006) — opt-out by a new resolveConfigReturnTypes config key @alies-dev
config() and Repository::get() return types (#1006) — opt-out by a new resolveConfigReturnTypes config key @alies-devJs::from() and Js::encode() taint per call-site (reduce false-positive reports) (#1010) @alies-devRequest::query() and Request::post() return types (#1009) @alies-devFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.11.0...v4.12.0
Resolve dynamic where{Column} on Model direct calls (#1001) @alies-dev
where{Column} on Model direct calls (#1001) @alies-devBuilder aggregate (avg(), max(), sum(), etc) returns using a known column type (#1005) @alies-devwhere{Column} arguments on Eloquent relations (#939) @alies-devwhere{Column} method calls (#980) @alies-devpluck($value, $key) key type and cover relation chains (#968) @alies-devModel::only() return shape from literal keys (#933) @alies-devSET columns to literal union in ModelPropertyHandler (#932) @alies-devMacroable return type info from docblock Psalm storage (#989) @alies-dev: static return types (#987) @alies-devdiagnose subcommand for runtime introspection (#959) @alies-devdiagnose command and enhance config created by the init command (#971) @alies-devpsalm-laravel init command @alies-devModel::factory()->create() collapse on bare HasFactory (#964) @alies-devauth($name) return to concrete guard class (#981) @alies-devStorage::disk() return to Cloud for cloud-driver disks (#982) @alies-devRoute::middleware facade and RouteRegistrar (#986) @alies-devRequest::file() via source-level conditional return (#935) @alies-devPossiblyUnusedMethod):
PossiblyUnusedMethod for legacy scopeXxx() Eloquent methods (#999) @alies-devPossiblyUnusedMethod for #[Scope]-attributed Eloquent methods (#998) @alies-devconfig_path() at the project root under Testbench fallback (#949) @alies-devFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.10.2...v4.11.0
Tighter Request::validated() narrowing, sharper Collection chain inference, and two false-positive fixes in testing + factory flows.
Tighter Request::validated() narrowing, sharper Collection chain inference, and two false-positive fixes in testing + factory flows.
list<T> from Collection::values()->all() chain by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/921Rules\Enum and Rules\In object forms in validated() by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/911PropertyNotSetInConstructor on Laravel testing lifecycle properties by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/916Factory::hasAttached rejects Eloquent\Collection from count()->create() by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/915Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.10.1...v4.10.2
<!-- Release notes generated using configuration in .github/release.yml at master -->
<!-- Release notes generated using configuration in .github/release.yml at master -->
Route::macro, Http::macro, Collection::macro, etc) by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/905Collection::random() with Laravel's actual signature by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/904Factory by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/906Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.10.0...v4.10.1
<!-- Release notes generated using configuration in .github/release.yml at master -->
<!-- Release notes generated using configuration in .github/release.yml at master -->
Factory count/times chains by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/878Model::query() flattening static for plain models by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/890.stubphp to .phpstub by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/891Arg helper to dedupe per-call-arg type/node access in handlers by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/892Builder template-arg invariants by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/893@throws annotations on synthesised macro pseudo-methods by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/900 (currently blocked by Psalm)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.9.3...v4.10.0
<!-- Release notes generated using configuration in .github/release.yml at master -->
<!-- Release notes generated using configuration in .github/release.yml at master -->
BelongsToMany/MorphToMany by @alies-dev in #883Rule::in(...) fluent builder to literal-string union by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/877Route::middleware() chain inference on Psalm dev-master by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/889psalm-laravel init command by @alies-dev in #881:
Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.9.2...v4.9.3
Better Eloquent Relationship type inferring:
using/as chain mutations on belongsToMany / morphToMany by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/868NoEnvOutsideConfig by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/859PossiblyUnusedMethod:
PossiblyUnusedMethod reports for FormRequest hooks by @andrew-demb in https://github.com/psalm/psalm-plugin-laravel/pull/863PossiblyUnusedMethod suppression to common Laravel hook methods: Command, Migration, Seeder, Mailable, Notification, ServiceProvider by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/866Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.9.1...v4.9.2
Fix Psalm crash on AuthManager::__call-forwarded methods (eg auth()->authenticate()) (#856) @alies-dev
AuthManager::__call-forwarded methods (eg auth()->authenticate()) (#856) @alies-devFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.9.0...v4.9.1
This release is focused respecting validation rules when to mark input as safe.
This release is focused respecting validation rules when to mark input as safe.
FormRequest input() / string() / str() accessors (#821) @alies-dev@psalm-taint-escape on custom Rule classes (#826) @alies-devscopes() chaining on builder contracts (#846) @alies-devfirstOr() callback template across argument positions (#851) @alies-devvendor/bin/psalm-laravel CLI with init subcommand for first-time plugin setup (#786) @alies-devpsalm-laravel add subcommand to scaffold a GitHub Actions security-analysis workflow (#814) @alies-devCollection, Session, RedirectResponse, LazyCollection, MessageBag, ServiceProvider(#809, #832) @alies-devCollection::make / LazyCollection::make / collect() for scalar inputs (#783) @alies-devInvalidArgument on arrow-function closures in the Builder::where family (#784) @alies-devonly / except / collect / old to the correct traits (#825) @alies-devimplements / extends in 4 stubs that were wiping reflected metadata (#835, #836) @alies-devStatsHandler to report plugin-level counts under psalm --stats (#817) @alies-devThis release focuses on fixing minor issues (plugin gaps) found on real projects.
This release focuses on fixing minor issues (plugin gaps) found on real projects.
AuthManager instance calls, not just the Auth facade (#773) @alies-devStringable-accepting stubs to reduce ImplicitToStringCast false positives (#775) @alies-devfilled() to narrow ?string to non-empty-string (#762) @alies-devModel subclasses (e.g. Laravel Scout) (#769) @alies-devNoEnvOutsideConfig from firing inside analysed project's config/ (#767) @alies-devFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.8.3...v4.8.4
Fix false-positive DocblockTypeContradiction on filled()/blank() guards with nullable strings (#753) @alies-dev
DocblockTypeContradiction on filled()/blank() guards with nullable strings (#753) @alies-devapp(static::class, ...) and class-string<Foo> arguments (#754) @alies-devFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.8.2...v4.8.3
Prevent plugin crashing on invalid Facade aliases by @alies-dev in https://github.com/psalm/psalm-plugin-laravel/pull/746
IssueUrlGenerator (#747) @alies-dev--SKIPIF-- support to PsalmTest via getSkipReason() (#742) @alies-devalies-dev/psalm-tester) @alies-devFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.8.1...v4.8.2
Use E_USER_DEPRECATED output type for deprecation warnings
compact output mode to save tokens (available from Psalm v7.0.beta-18)E_USER_DEPRECATED output type for deprecation warningsFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.8.0...v4.8.1
This release adds psalm-security-analysis AI skill installable via Laravel Boost. You can install it by re-running boost:update (or boost:install on f
This release adds psalm-security-analysis AI skill installable via Laravel Boost. You can install it by re-running boost:update (or boost:install on fresh installations).
This allows your agent find and fix security issues found by Psalm taint analysis.
<img width="1126" height="848" alt="image" src="https://github.com/user-attachments/assets/97caf072-c970-4601-9cf7-9427717d3b10" />
psalm-security-analysis skill for AI agents (#672) @alies-devHigherOrderCollectionProxy method call chains (#724) @alies-devConfig::array() and Config::collection() default argument type (#736) @alies-dev@psalm-taint-sink file methods to Filesystem/FilesystemAdapter stubs (#739) @alies-devPossiblyUnusedMethod false positives for Eloquent legacy accessor/mutator methods (#732) @alies-devSimplify migration: Add Psalter plugin for upgrading relation PHPDoc annotations (#735) @alies-dev
Migration of PHPDoc from v3.x version to v4.7+ for relationship definitions is easy now:
./vendor/bin/psalter --plugin=vendor/psalm/plugin-laravel/tools/psalter/UpgradeRelationAnnotations.php
Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.7.0...v4.8.0
This release focuses on Eloquent Builder type coverage — new aggregate accessor resolution (withCount/withExists/withSum/withMin/withMax/withAvg), Sof
This release focuses on Eloquent Builder type coverage — new aggregate accessor resolution (withCount/withExists/withSum/withMin/withMax/withAvg), SoftDeletes on Builder instances, where{Column} dynamic methods on builder and relations, and several stub fixes that restore correct pivot types.
where{Column} method resolution on relation chains (#714)withCount/withExists/withSum/withMin/withMax/withAvg aggregate accessor properties on Eloquent models (#715)SoftDeletes methods resolving on base Builder instances (#727)BelongsToMany/MorphToMany stubs to declare 4 template params, restoring pivot types in return values (#716)Carbon for now() and today() helpers (#725)dispatch() arguments against job/event constructor signature (#726)Auth::guard() return type to the concrete guard class (#711)Collection::whereNotNull() to remove null from TValue (#713)env() return type based on the default value argument (#712)collect() with no args to return Collection<never, never> (#722)@property-read stubs for higher-order collection proxies (#720)Str::replace() (#719)Conditionable::when()/unless() and Tappable::tap() to fix mixed return on fluent chains (#710)Collection::empty() and Collection::sum() return types (#683)@psalm-this-out to paginator setCollection() (#688)@psalm-taint-escape sql to parameterized Builder methods (#691)TaintedHtml sinks from Blade view data (#690)Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.6.2...v4.7.0
🛡️ Add @psalm-taint-source input for Http\Client\Response methods (#676) @alies-dev
@psalm-taint-source input for Http\Client\Response methods (#676) @alies-devCollection::sum() return type from mixed to int|float (#680) @alies-devCollection::empty() stub with static<never, never> return type (#679) @alies-devFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.6.1...v4.6.2
Model models variadic arguments: support for static (__callStatic) Model calls (#663) @alies-dev
__callStatic) Model calls (#663) @alies-devRelation method calls (#661) @alies-devFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.6.0...v4.6.1
Deep relationship type resolution, Custom query builders, Custom Collections, and smarter validation shapes (thanks to @MDG11).
Deep relationship type resolution, Custom query builders, Custom Collections, and smarter validation shapes (thanks to @MDG11).
#[UseEloquentBuilder] attribute and newEloquentBuilder() override (#621) @alies-devSoftDeletes trait methods on custom query builders (#632) @alies-devMethodForwardingHandler for Relation method forwarding (#642) @alies-devmorphTo property type from docblock generic annotations (#652) @alies-dev#[CollectedBy] attribute for custom Eloquent collections (#623) @alies-devCollection::flatten() and collapse() return types to preserve TValue (#619) @alies-devModel::increment()/decrement() as public in stub (#618) @alies-devModelMakeDiscouraged when model has custom make() method (#616) @alies-dev@psalm-flow for Collection get()/first()/pull()/value() default parameter taint propagation (#650) @alies-devFull Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.5.0...v4.6.0
Three new opt-in rules, expanded taint coverage, and fewer false positives across the board (focus on __() and trans()).
Three new opt-in rules, expanded taint coverage, and fewer false positives across the board (focus on __() and trans()).
MissingView: Detect missing Blade view files in view() and View::make() calls (#579) @alies-devModelMakeDiscouraged: Detect undefined translation keys in __() and trans() calls (#595) @alies-devMissingTranslation: Warn against Model::make() in favor of new Model() @alies-dev__() and trans() return type to string|array (was mixed) (#592) @alies-dev__() return to string when the translation key is known to exist @alies-devMissingTemplateParam on HasFactory trait (#517) @alies-devModel (#498) @alies-devimplements clauses to 15 stubs (#615) @alies-devmorphTo stub to bypass $this issue in generics @alies-devmorphToMany/morphedByMany signatures @alies-dev@return static to Stringable stub methods @alies-dev@psalm-taint-source input for Route parameter methods (#608) @alies-deveval/executeRaw (Lua injection) @alies-devCookieJar methods @alies-dev$path/$domain sinks to Cookie::expire() and forget() @alies-devStr::of(), str(), and Stringable @alies-devHash::make() and bcrypt() as @psalm-taint-escape system_secret @alies-devTested against 10 real-world Laravel apps (bagisto, coolify, monica, pixelfed, solidtime, unit3d, vito, and others). Combined results vs v4.4.0:
| Metric | v4.4.0 | v4.5.0 | Delta |
|---|---|---|---|
| Total issues | 84,503 | 76,123 | -9.9% |
| Plugin-caused false positives | 5,115 | 4,155 | -18.8% |
| Security findings (taint) | 83 | 84 | +1 |
Full Changelog: https://github.com/psalm/psalm-plugin-laravel/compare/v4.4.0...v4.5.0
One column per quarter.