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.
Enhancing Code Quality & Test Coverage:
Build vs. Buy Decision:
Roadmap Priorities:
infection/infection to reduce maintenance overhead (long-term dependency risk).Use Cases:
infection/infection) and static analysis (Psalm/PHPStan).array_values → array return type mutations).infection/infection to a specific version (avoid breaking changes).*"This tool closes a critical gap in our PHP code quality pipeline. Today, mutation testing catches bugs by introducing small code changes—but it often misses type violations that static analyzers like Psalm flag. By integrating these two processes, we’ll:
- Catch more bugs earlier, reducing production incidents tied to type errors.
- Improve test reliability by eliminating false positives from escaped mutants.
- Future-proof our tech stack with stricter typing, a key differentiator for maintainability. The tradeoff? A ~2–3x slowdown in mutation tests (mitigated by running only in CI). For high-risk modules, this is a no-brainer."*
Ask for:
*"We’re adding a plugin to Infection that runs Psalm on mutated code. Why?
- Problem: Mutation tests often ‘escape’ type violations (e.g., returning
arrayinstead oflist<T>), inflating our mutation score artificially.- Solution: This tool kills mutants that break type contracts, so we write fewer redundant tests and catch real bugs faster.
- How it works:
- Replace
vendor/bin/infectionwithvendor/bin/roave-infection-static-analysis-plugin.- Point it to your
psalm.xmlconfig (or default to Psalm’s rules).- Mutants violating types are auto-killed.
- Tradeoffs:
- Slower (~2–3x) than vanilla Infection (but only runs in CI).
- Requires pinning
infection/infectionto a specific version (temporary).- Next steps: Let’s test this in the
paymentsmodule first—it’s type-heavy and bug-prone."*
Ask for:
How can I help you explore Laravel packages today?