Search by

hypervel / phpstan

albertchtbinaryfire

Framework-aware PHPStan type inference and rules for Hypervel applications and packages.

Package info

github.com/hypervel/phpstan

Issues

Type:phpstan-extension

pkg:composer/hypervel/phpstan

Statistics

Installs: 2

Dependents: 1

Suggesters: 0

Stars: 0

0.4.x-dev 2026-12-03 13:29 UTC

This package is auto-updated.

Last update: 2026-12-03 13:48:45 UTC


README

Documentation: https://hypervel.org/docs/static-analysis

Differences From Larastan

  • Package-owned diagnostic identifiers use the hypervel.* prefix instead of larastan.* (and rules.modelAppends). PHPStan's own identifiers are unchanged.
  • Several checks are enabled by default, and Hypervel adds coroutine, worker-lifetime and authoring-policy checks. See the configuration defaults.
  • There is no Octane compatibility rule or checkOctaneCompatibility setting; Hypervel's worker-lifetime checks replace it. There is no deferred service provider rule, because Hypervel has no deferred providers.
  • Container ArrayAccess return types are not provided, because the Hypervel container does not support ArrayAccess.
  • A value typed as an interface does not gain methods or macros from its implementations. Upstream resolves an undefined method or a macro on a contract against its container binding, and on the auth user contracts against the configured auth models. Explicit resolution, such as app(Repository::class) or the factory returned by response(), is typed from the booted application's binding instead.
  • Without a guard name, Auth::guard() and auth()->guard() may return any configured guard, because shouldUse() changes the default guard per request. A guard whose type cannot be read from its driver keeps the declared Guard type rather than StatefulGuard.
  • The request-scope auth rules offer no automatic fix, because the request's user resolver can return a different user than the Auth facade or auth() helper.
  • Collections keep Laravel's covariant value type, so a Collection<int, User> is accepted where a Collection<int, Model> is expected. Upstream's stubs make it invariant. With bleeding edge, PHPStan does not widen a covariant value type it has already inferred, so a call such as collect([1, 2, 3])->push(4) is reported. See Collection Types.
  • now(), today() and the Date facade return CarbonInterface, as declared, rather than the date class configured when analysis runs. Code that needs a specific class should convert the value, for example with toImmutable().
  • Configuration value types apply to reads through the config() helper, the Config facade and application-container calls such as app('config'). A repository received as a parameter or property, or created with new Repository($items), keeps its declared return types. Upstream applies the application's configuration types to get() on any Repository instance. See Configuration and Services.
  • Request input getters return the types the input can hold. A keyed query(), post() or cookie() value can be a string, number, boolean, array or Stringable, a keyed server() or route() value is mixed, and header() can return null even with a default. Whole query, post, cookie and file arrays have array-key keys, because a query string or JSON list body can use integer keys. Upstream's narrower types do not cover these values. FormRequest::validated() and safe($keys) return array<array-key, mixed> for the same reason.
  • Storage::disk() and FilesystemManager::disk() are typed per disk from the booted configuration, such as ClientPooledFilesystem for a pooled S3 disk, instead of always FilesystemAdapter. Calls the Storage facade forwards to the default disk use that disk's methods. Storage::cloud() is not supported.
  • Connection-bound phpredis methods such as client() and auth() are reported when called through Redis::connection() or the manager, because the pooled proxy rejects them. Call them on a held connection from Redis::withConnection().
  • A builder method called through a relation returns the relation only when it is declared to return static or $this, as a relation returns itself when the builder returns itself. Upstream does so for any builder result. static is treated as the fluent convention, not proof of identity, so a custom static method that returns a clone is still typed as the relation; declare $this where identity matters. Builder's own clone(), cloneWithout(), cloneWithoutBindings() and applyScopes() return the builder.
  • A @method scopeActive() tag does not add an active() scope, because Eloquent only calls scope methods that exist. Upstream adds one.
  • The model visibility rule makes only a private scope or accessor protected automatically. A public one may be called directly from other files, so it is reported without a fix.
  • The unnecessary collection call rule reports a call only when the query returns the same result, so last(), pop(), skip(), slice(), where(), contains(), find(), the aggregates and similar calls are not reported. See Query Results.
  • A dynamic where, such as whereEmail(), that names an unknown column is still reported as an undefined method, with the column in a tip. Unlike upstream, the call keeps the builder or relation type rather than becoming an error type.
  • Calls an Eloquent builder forwards to its query follow Builder::__call(). A query macro returns the builder, or the relation it was called through, instead of the macro's result. A passthru method such as dumpRawSql() returns the raw query, whose rows are not models. macro() and a static mixin() return null, and a forwarded query method cannot be called statically on a builder class. Upstream keeps the query macro's and passthru results, returns the builder from both registration methods, and allows those static calls. A local macro keeps its own $this, while Builder::macro() binds a global macro to the builder. Upstream binds both as the query's macro() declares.
  • A misspelled modifier on a schema column, index or foreign key definition, such as nulable(), is reported as an undefined method, because the grammars ignore attributes they do not know. Upstream accepts any method on them as a Fluent attribute. See Schema Modifiers.
  • relation-of gives a strict union when several relations may apply, so an eager-loading callback must accept each of them. Upstream gives a benevolent union.
  • A relation path is unknown when any model in a union lacks the relation, because a subclass or resolveRelationUsing() can supply it. builder-of and collection-of of an unknown model give Builder<*> and the base model collection. Upstream drops that model, or gives never.
  • A custom builder's or relation's override of a method such as get() keeps its declared collection type. Upstream replaces it with the model's collection class.
  • A job dispatched in a transaction is reported only when its queue connection is known not to wait for the commit, from the connection's after_commit and outbox settings and, for the database driver, the transaction's connection. A dispatch that calls beforeCommit(), or a job whose $afterCommit is false, is not reported. Upstream assumes Laravel's default, where connections dispatch immediately, and reports both. See Dispatching Jobs in Transactions.

Ported from: https://github.com/larastan/larastan