Download the PHP package happenv-com/laravel-true-modular-phpstan without Composer
On this page you can find all versions of the php package happenv-com/laravel-true-modular-phpstan. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download happenv-com/laravel-true-modular-phpstan
More information about happenv-com/laravel-true-modular-phpstan
Files in happenv-com/laravel-true-modular-phpstan
Package laravel-true-modular-phpstan
Short Description PHPStan extensions for laravel-true-modular: dynamic Eloquent relation resolution and module boundary enforcement.
License MIT
Informations about the package laravel-true-modular-phpstan
PHPStan for Laravel True Modular
PHPStan extensions for laravel-true-modular modular monoliths. Ships two independent, zero-config extensions:
| Extension | What it does |
|---|---|
| Dynamic Relation Resolver | Teaches PHPStan about Eloquent relations registered at runtime via Model::resolveRelationUsing() (e.g. relations one module adds to another module's model). Such relations are normally invisible to static analysis — this extension makes $model->relation and $model->relation() fully typed. |
| Module Boundary Enforcer | Fails analysis when a module references a class from another module that is not declared in its composer.json require. Also detects circular dependencies between modules. |
Requires PHP 8.3+, PHPStan 2.x and laravel-true-modular (Laravel 12/13). It reuses
the framework's own module discovery, so it understands your modules out of the box —
no PHPStan parameters to set.
Installation
The package is a phpstan-extension. If you use
phpstan/extension-installer
(recommended), both extensions are registered automatically — nothing else to do:
Make sure the plugin is allowed in your root composer.json:
Manual registration (without extension-installer)
Include the bundled config in your phpstan.neon:
Or cherry-pick a single extension:
Larastan recommended. The Dynamic Relation Resolver reflects your Eloquent models, so install
larastan/larastanfor accurate results. Withextension-installerit is wired up automatically.
Zero configuration
Neither extension needs any parameters in phpstan.neon. The Module Boundary
Enforcer discovers modules through laravel-true-modular's own ModuleRegistry,
which means it automatically honours:
- the configured module composer type (
Application::moduleComposerType(), defaulttrue-module), and - the configured modules directory (
Application::modulesDirectory(), defaultapp-modules).
A "module" is any package under that directory whose composer.json declares the
module type. Allowed cross-module dependencies are read straight from each module's
composer.json require section — exactly the same source of truth the framework
uses to order service providers at runtime. There is no vendor prefix or path to
configure.
If no modules are found (e.g. the directory does not exist), both rules silently do nothing, so installing the package never breaks an unrelated build.
What it reports
Dynamic Relation Resolver
Once installed it automatically types any relation registered through Laravel's relation resolver, for example:
To-one relations (hasOne, belongsTo, morphOne, hasOneThrough) are typed as
Related|null; to-many relations as Collection<int, Related>.
Module Boundary Enforcer
For every module the enforcer reads its composer.json and treats its require
entries that resolve to other known modules as the allowed cross-module
dependencies. A module may always reference its own classes and any class from a
package that is not a module (vendor libraries, the host application, …).
Violations look like:
Both use statements and inline references (new, static calls, instanceof,
extends/implements, catch, class constants) are checked.
Circular dependencies are reported once at the end of analysis:
Error identifiers
You can ignore findings by identifier in phpstan.neon:
| Identifier | Meaning |
|---|---|
trueModular.moduleBoundary |
Disallowed cross-module reference |
trueModular.circularDependency |
Cycle between modules |
Example phpstan.neon
That's the whole configuration — point PHPStan at your modules and run it.
Development
The test suite covers both extensions:
- Dynamic relations — boots an in-memory Eloquent connection, registers
relations via
Model::resolveRelationUsing(), and asserts the resolver exposes them with the correct method/property types. - Module boundary — uses PHPStan's
RuleTestCaseagainst fixture modules undertests/Fixturesto assert allowed/disallowed cross-module references and circular dependency detection.
License
MIT
All versions of laravel-true-modular-phpstan with dependencies
happenv-com/laravel-true-modular Version ^1.0
illuminate/database Version ^12.0 || ^13.0
phpstan/phpstan Version ^2.0