phpyh/psalm-tester
Run and compare Psalm static analysis results across versions and configurations. Handy for CI, regression checks, and testing plugin or baseline changes, with simple CLI tooling to spot new issues or verify improvements quickly.
PsalmTester::assertNoErrors()).composer require + basic config (Psalm’s existing psalm.json remains untouched).php artisan psalm:test).app() helper introspection).src/ vs. app/ paths, Facade stubs)?--parallel flag for large codebases?NoUnresolvableTypeForParam) handled in assertions?--output-format=json for faster CI runs?PsalmTester in feature tests (e.g., it('has no Psalm errors', fn() => PsalmTester::assertNoErrors())).PsalmTester::run().Phase 1: Setup
composer require vimeo/psalm) and configure psalm.json for Laravel.phpyh/psalm-tester (composer require phpyh/psalm-tester).tests/PsalmBaseline.txt) for initial output.Phase 2: Test Integration
uses(PsalmTester::class)) to relevant test classes.public function test_no_psalm_errors_in_auth_controller() {
PsalmTester::assertNoErrors(app_path('Http/Controllers/AuthController.php'));
}
assertErrorsMatchBaseline() for controlled regressions.Phase 3: CI/CD
.github/workflows/psalm.yml):
- name: Psalm Static Analysis
run: vendor/bin/pest --test PsalmTester::run()
stubs/ and internal/ directories.Phase 4: Enforcement
app/Http/, then app/Console/).composer.json.psr-4). Older versions may need psalm.json tweaks.psalm-plugin-laravel, but baseline files may need updates.| Step | Priority | Effort | Dependencies |
|---|---|---|---|
| Install Psalm | High | Low | composer.json |
Configure psalm.json |
High | Medium | Laravel codebase |
Add psalm-tester |
Medium | Low | Psalm working |
| Write baseline tests | Medium | High | Test suite |
| CI Integration | High | Medium | GitHub Actions/GitLab |
| Enforce in PRs | Low | Low | CI pipeline |
PsalmTester::assertErrorsMatchBaseline() with semantic versioning for baselines.psalm-tester adds a layer of abstraction.PsalmTester::run()->getOutput() to inspect raw Psalm logs.roave/security-advisories (for security-focused checks) or custom scripts.vendor/, node_modules/ from analysis.psalm --init).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Psalm rule change | CI fails unexpectedly | Update baselines proactively |
| Flaky Psalm output | Intermittent test failures | Cache psalm dependencies |
| Large baseline drift | Maintenance burden | Use PsalmTester::assertNoErrors() for new code |
| CI timeouts | Builds fail due to slowness | Parallelize or cache Psalm runs |
| Laravel-specific false positives | Legitimate errors ignored | Tune ` |
How can I help you explore Laravel packages today?