psalm/plugin-mockery
Adds Psalm static analysis support for the Mockery testing framework. Improves type inference and understanding of mocked objects and expectations in PHPUnit-style tests. Install via Composer and enable with psalm-plugin for better mock-related diagnostics.
Architecture fit: The plugin seamlessly extends Psalm's static analysis to handle Mockery's dynamic mock objects, resolving a critical gap in type inference for runtime-generated classes. It integrates natively with Psalm's plugin system without requiring custom tooling, making it ideal for projects using both tools. The design aligns with Psalm's extensibility model and Mockery's API patterns.
Integration feasibility: Straightforward via Composer and psalm-plugin enable command. Requires existing Psalm and Mockery usage—no production code changes needed. Compatibility must be validated against specific Psalm (v5-v7) and Mockery (v1+) versions. Projects without Psalm would need to adopt it first, but the plugin itself has no external dependencies beyond these core tools.
Technical risk: Low adoption (0 dependents, 10 stars) and future-dated release (2025-03-20) raise maintenance concerns. Limited community activity increases risk of unresolved bugs during Psalm/Mockery updates. Potential for false positives/negatives if edge cases aren't covered. Plugin stability depends on upstream changes to Psalm/Mockery.
Key questions: Is maintainership active despite low adoption metrics? How does it handle complex Mockery patterns like Mockery::on() matchers or constructor-arg mocks? Does it fully support all Mockery 1.x features used in our test suite? What's the rollback plan if CI fails during analysis?
Stack fit: Optimized for Laravel/PHP projects using Psalm for static analysis and Mockery for test doubles. Enhances type safety for test code without affecting production logic or other testing frameworks (PHPUnit, Pest). Works out-of-the-box with existing test suites—no framework-specific configuration needed.
Migration path: Minimal effort for existing Psalm/Mockery users: install dependency, enable plugin, and re-run Psalm. For new Psalm adopters: first configure Psalm baseline for production code, then add this plugin for test-specific type inference. No breaking changes expected in test logic.
Compatibility: Requires PHP 8.1+, Mockery ≥1.0, and Psalm v5-v7. Must align with project's current versions—check composer.json constraints (e.g., vimeo/psalm: "^5.0 || ^6 || ^7"). Avoid if using Psalm <5.0 or alternative mocking frameworks (PHPUnit native mocks, Prophecy).
Sequencing: 1) Verify current Psalm and Mockery versions meet requirements; 2) Install via Composer; 3) Enable plugin; 4) Run Psalm with
How can I help you explore Laravel packages today?