Static analysis
Gacela ships configs for PHPStan and Psalm that suppress false positives from dynamic resolution via #[ServiceMap] attributes and the magic getFacade() / getFactory() / getConfig() dispatch, as well as related AbstractConfig type mismatches.
PHPStan
Include in your phpstan.neon:
includes:
- vendor/gacela-project/gacela/phpstan-gacela.neonBeyond the suppressions, phpstan-gacela.neon enforces Gacela naming conventions (Facade, Factory, Provider, Config) and improves generic type support via @extends on the abstract classes, so the concrete Facade / Factory / Config / Provider of a module get accurate return types across getFactory(), getConfig() and getProvidedDependency().
Psalm
<?xml version="1.0"?>
<psalm
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns="https://getpsalm.org/schema/config"
>
<projectFiles>
<directory name="src"/>
</projectFiles>
<xi:include href="vendor/gacela-project/gacela/psalm-gacela.xml"/>
<issueHandlers>
<InvalidArgument>
<errorLevel type="suppress">
<directory name="src" />
</errorLevel>
</InvalidArgument>
</issueHandlers>
</psalm>The InvalidArgument suppression is required — Gacela resolves concrete types at runtime that Psalm can't infer statically. Suppress inline if you prefer narrower scope:
/** @psalm-suppress InvalidArgument */
return new YourService($this->getConfig());Troubleshooting
- PHPStan can't find the file — verify the include path resolves relative to your
phpstan.neon. - Psalm ignores the include — ensure
xmlns:xi="http://www.w3.org/2001/XInclude"is declared, thenvendor/bin/psalm --clear-cache.