feat(analyzer): add Magento 2 analyzer plugins#1251
Open
peterjaap wants to merge 4 commits intocarthage-software:mainfrom
Open
feat(analyzer): add Magento 2 analyzer plugins#1251peterjaap wants to merge 4 commits intocarthage-software:mainfrom
peterjaap wants to merge 4 commits intocarthage-software:mainfrom
Conversation
Add analyzer plugins for Magento 2 best practices: - use_service_contracts: flags direct repository implementation usage - collection_via_factory: flags direct collection instantiation - use_resource_model_directly: flags direct resource model save/load - no_set_template_in_block: flags setTemplate() in Block constructors - collection_mock_subclass: flags test mocks extending AbstractDb - ObjectManager return type provider for get()/create() Adds 5 IssueCode variants and test cases for all plugins. Inspired by phpstan-magento (https://github.com/bitExpert/phpstan-magento). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6 tasks
azjezz
reviewed
Feb 28, 2026
Replace Magento-specific issue codes with existing generic ones (DeprecatedMethod, InvalidArgument) and regenerate code.rs via the regen script instead of manual edits.
… any class Avoids invoking the return type provider on every get()/create() call across the codebase by using exact class targeting.
Contributor
Author
|
@azjezz done! |
Contributor
Author
|
@azjezz no conflicts anymore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 What Does This PR Do?
Add analyzer plugins for Magento 2 best practices:
Adds 5 IssueCode variants and test cases for all plugins.
Inspired by phpstan-magento (https://github.com/bitExpert/phpstan-magento).
🔍 Context & Motivation
We would like to move away from phpcs and PhpStan, and adding these rules to Mago allows us to do this.
🛠️ Summary of Changes
Feature: Added Magento 2 rules to analyzers
📂 Affected Areas
🔗 Related Issues or PRs
Related to #177
📝 Notes for Reviewers
I added some analyzers;
Enabled like this;
Ran the analyzer on a test file;
With output;