vimeo/psalm
Psalm is a PHP static analysis tool that finds type errors, dead code, and risky patterns before runtime. Add it to your CI to improve code quality, enforce stricter typing, and catch bugs early in applications and libraries.
Illuminate\Support, Illuminate/Database) are auto-generated or manually configurable.psalm --init generates config) integrates with GitHub Actions, GitLab CI, or CircleCI.--workers flag for monorepos.phpstorm.php config (included in Laravel IDE Helper packages).php-pact or intelephense plugins.__get, __set) or dynamic properties as errors. Mitigation: Configure psalm.xml to ignore specific files/classes.@psalm-suppress or custom stubs.psalm.xml, psalm-discover.xml for multi-project setups). Risk: Misconfiguration leads to noisy output or missed issues.@psalm-pure) require manual review.--no-cache sparingly, leverage incremental analysis.@psalm-pure), which may require backward-compatible migration for existing codebases.psalm:fix or manual review)?ERROR, WARNING)?vimeo/psalm), requiring no framework-specific changes.php-cs-fixer via pre-commit hooks.--init to generate psalm.xml, then adjust config (e.g., ignore vendor/, storage/).--level=1 (errors only), then expand to warnings.--alter for safe fixes (e.g., adding @var annotations).psalm-plugin.HasFactory usage).| Component | Compatibility | Mitigation |
|---|---|---|
| Laravel Core | Works with stub files (auto-generated or manual). | Use psalm-plugin to extend stubs for new Laravel versions. |
| Eloquent | Supports query builder but may misanalyze dynamic methods (e.g., __call). |
Configure psalm.xml to ignore or suppress specific classes. |
| Blade Templates | No native support; treated as plain PHP. | Use @psalm-suppress for template files or analyze .php files only. |
| Service Container | May flag dynamic resolution as unsafe. | Add @psalm-suppress MixedArgument or custom stubs for Container. |
| Event System | Listeners may trigger taint analysis false positives. | Explicitly mark event handlers with @psalm-pure if stateless. |
composer.json.psalm.xml and adjust for Laravel’s structure:
<projectFiles>
<directory name="app" />
<directory name="src" />
<exclude-name>*.blade.php</exclude-name>
</projectFiles>
ERROR only).psalm --init to generate a baseline.--stats to identify high-error-density files..github/workflows/psalm.yml:
- name: Psalm
run: vendor/bin/psalm --no-cache --output-format=github
ERROR level).--workers=4.--alter --issues=MissingReturnType).TaintedLlmPrompt for API inputs).psalm.xml may become outdated as Laravel evolves.psalm.xml.v8.1, psalm.xml.v10) and template files for new projects.psalm-plugin or CI scripts.How can I help you explore Laravel packages today?