psalm/psalm-plugin-api
Psalm plugin API providing interfaces and helpers to build and integrate custom plugins with the Psalm static analysis tool, enabling extensions such as new checks, type providers, and project-specific analysis behavior.
psalm/psalm-plugin-api provides a stable, versioned API for building Psalm plugins, making it a strong fit for teams using PHP static analysis (e.g., type checking, code quality enforcement) within a Laravel or broader PHP ecosystem.composer require vimeo/psalm + plugin API).Carbon instance")../vendor/bin/psalm or Laravel’s php artisan psalm (if using laravel-shift/psalm wrapper).php-cs-fixer) or GitHub Actions step.UserRepository method returns User[] (not mixed).psalm.config.php incrementally:
<?php
return [
'plugins' => [
'vendor/package/plugin', // Custom or published plugin
],
];
--no-cache or --init flags).- name: Run Psalm
run: vendor/bin/psalm --init --no-cache
$request->input()) as errors; suppress with @psalm-suppress.@psalm-suppress MixedReturnType for methods returning container-bound classes.Psalm\Plugin\PluginInterface; leverage Psalm\CodeLocation for precise error reporting.Illuminate\Database\Eloquent\Model subclasses use fillable arrays correctly.composer require vimeo/psalm).psalm.config.php with project-specific rules../vendor/bin/psalm --init.@psalm-suppress UndefinedClass).MixedReturnType, UndefinedClass).@psalm-* suppression annotations.psalm --log-errors=verbose to diagnose plugin issues.--init flag) to avoid full analysis on every run.psalm --parallel.vendor/, storage/) in psalm.config.php to reduce runtime.psalm/plugin-symfony) to reduce effort.psalm.config.php’s project_files to scope analysis to relevant directories.| Failure Scenario | Mitigation |
|---|---|
| Psalm plugin breaks CI pipeline | Start with --no-cache to avoid stale results; gradually enforce fixes. |
| False positives overwhelm devs | Use @psalm-suppress sparingly; document suppressed rules. |
| Plugin conflicts with Psalm update | Pin Psalm version in composer.json temporarily; backport fixes. |
| Slow analysis in large codebase | Exclude non-critical paths; invest in plugin optimization. |
| Lack of plugin adoption | Tie Psalm warnings to code reviews or onboarding tasks. |
null checks with --strict-types.Money class).How can I help you explore Laravel packages today?