Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Infection Static Analysis Plugin

Infection Static Analysis Plugin Laravel Package

roave/infection-static-analysis-plugin

Adds a wrapper around infection/infection that runs Psalm on generated mutants. Mutations that would cause type errors are marked killed, improving mutation score. Run vendor/bin/roave-infection-static-analysis-plugin; supports Infection args plus --psalm-config.

View on GitHub
Deep Wiki
Context7

:white_check_mark: :dragon_face: Static analysis on top of mutation testing - prevents escaped mutants from being invalid according to static analysis

Frequently asked questions about Infection Static Analysis Plugin
How does this plugin improve mutation testing in Laravel projects?
The plugin runs Psalm static analysis on mutants generated by Infection. Mutants causing type errors (e.g., breaking return type hints) are marked as 'killed,' which artificially inflates your mutation score by eliminating false positives. This is especially useful in Laravel’s type-heavy codebase (e.g., Laravel 8+ with PHP 8.0+).
Can I use this with Laravel’s default PHPUnit setup?
Yes, the plugin works seamlessly with Laravel’s PHPUnit integration since it’s a wrapper around Infection. Just replace `vendor/bin/infection` with `vendor/bin/roave-infection-static-analysis-plugin` in your test scripts or CI pipelines.
What Laravel versions does this plugin support?
The plugin itself has no Laravel-specific dependencies, but it requires PHPUnit and Infection, which work with Laravel 5.8+. For best results, use Laravel 8+ with PHP 8.0+ and Psalm/PHPStan for stricter type checking.
How do I configure Psalm for this plugin?
Use the `--psalm-config` flag to point to your Psalm config file (e.g., `config/psalm.xml`). If you don’t have one, generate a default with `vendor/bin/psalm --init`. Laravel projects using `spatie/laravel-psalm` can reuse that config.
Will this break my existing Infection tests?
No, the plugin replaces Infection’s binary but preserves all its arguments. Your existing test suite will run the same way, but mutants violating type rules will now be killed automatically. Always test in a staging environment first.
Is this compatible with Pest or other testing frameworks?
Yes, since the plugin works at the Infection level, it’s compatible with Pest (which uses PHPUnit under the hood). Just ensure Pest’s PHPUnit configuration aligns with your Psalm setup.
How much slower is this compared to regular Infection?
Expect 2–5x slower execution due to Psalm’s static analysis. For large Laravel apps (e.g., with Forge/Sail plugins), consider running it in CI only or targeting specific directories with `--only-tests`. Parallel execution isn’t supported yet.
What if Psalm flags false positives in Laravel’s dynamic code?
Use `@psalm-suppress` annotations or exclude problematic paths in your Psalm config. Laravel’s dynamic method calls (e.g., `app()->make()`) often trigger false positives—adjust your config to match your project’s tolerance for type strictness.
Can I use PHPStan instead of Psalm with this plugin?
No, the plugin currently only supports Psalm. However, the architecture suggests future support for PHPStan or other tools. Check the GitHub repo for updates or consider contributing a PHPStan adapter.
How do I integrate this into GitHub Actions for Laravel?
Add a step to your workflow to replace `infection` with the plugin, e.g., `vendor/bin/roave-infection-static-analysis-plugin --psalm-config=config/psalm.xml`. Gate it as a required check or run it nightly. Monitor CI timeouts for large codebases.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata