hypervel / phpstan
Framework-aware PHPStan type inference and rules for Hypervel applications and packages.
Package info
Type:phpstan-extension
pkg:composer/hypervel/phpstan
0.4.x-dev
2026-12-03 13:29 UTC
Requires
- php: ^8.4
- composer-runtime-api: ^2.2
- hypervel/collections: ^0.4
- hypervel/console: ^0.4
- hypervel/container: ^0.4
- hypervel/contracts: ^0.4
- hypervel/database: ^0.4
- hypervel/filesystem: ^0.4
- hypervel/foundation: ^0.4
- hypervel/http: ^0.4
- hypervel/routing: ^0.4
- hypervel/schema-parser: ^0.4
- hypervel/support: ^0.4
- hypervel/translation: ^0.4
- hypervel/view: ^0.4
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan: ^2.3.6
- phpstan/phpstan-deprecation-rules: ^2.0.5
- symfony/console: ^8.1.10
- symfony/finder: ^8.1
- vlucas/phpdotenv: ^5.6.1
Requires (Dev)
None
Suggests
- hypervel/testbench: Required to analyze packages with a Testbench-booted application (^0.4).
Provides
None
Conflicts
None
Replaces
None
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 oflarastan.*(andrules.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
checkOctaneCompatibilitysetting; 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 byresponse(), is typed from the booted application's binding instead. - Without a guard name,
Auth::guard()andauth()->guard()may return any configured guard, becauseshouldUse()changes the default guard per request. A guard whose type cannot be read from its driver keeps the declaredGuardtype rather thanStatefulGuard. - The request-scope auth rules offer no automatic fix, because the request's user resolver can return a different user than the
Authfacade orauth()helper. - Collections keep Laravel's covariant value type, so a
Collection<int, User>is accepted where aCollection<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 ascollect([1, 2, 3])->push(4)is reported. See Collection Types. now(),today()and theDatefacade returnCarbonInterface, as declared, rather than the date class configured when analysis runs. Code that needs a specific class should convert the value, for example withtoImmutable().- Configuration value types apply to reads through the
config()helper, theConfigfacade and application-container calls such asapp('config'). A repository received as a parameter or property, or created withnew Repository($items), keeps its declared return types. Upstream applies the application's configuration types toget()on anyRepositoryinstance. See Configuration and Services. - Request input getters return the types the input can hold. A keyed
query(),post()orcookie()value can be a string, number, boolean, array orStringable, a keyedserver()orroute()value ismixed, andheader()can return null even with a default. Whole query, post, cookie and file arrays havearray-keykeys, because a query string or JSON list body can use integer keys. Upstream's narrower types do not cover these values.FormRequest::validated()andsafe($keys)returnarray<array-key, mixed>for the same reason. Storage::disk()andFilesystemManager::disk()are typed per disk from the booted configuration, such asClientPooledFilesystemfor a pooled S3 disk, instead of alwaysFilesystemAdapter. Calls theStoragefacade forwards to the default disk use that disk's methods.Storage::cloud()is not supported.- Connection-bound phpredis methods such as
client()andauth()are reported when called throughRedis::connection()or the manager, because the pooled proxy rejects them. Call them on a held connection fromRedis::withConnection(). - A builder method called through a relation returns the relation only when it is declared to return
staticor$this, as a relation returns itself when the builder returns itself. Upstream does so for any builder result.staticis treated as the fluent convention, not proof of identity, so a customstaticmethod that returns a clone is still typed as the relation; declare$thiswhere identity matters. Builder's ownclone(),cloneWithout(),cloneWithoutBindings()andapplyScopes()return the builder. - A
@method scopeActive()tag does not add anactive()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 asdumpRawSql()returns the raw query, whose rows are not models.macro()and a staticmixin()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, whileBuilder::macro()binds a global macro to the builder. Upstream binds both as the query'smacro()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 aFluentattribute. See Schema Modifiers. relation-ofgives 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-ofandcollection-ofof an unknown model giveBuilder<*>and the base model collection. Upstream drops that model, or givesnever. - 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_commitand outbox settings and, for the database driver, the transaction's connection. A dispatch that callsbeforeCommit(), or a job whose$afterCommitisfalse, 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