A PHPStan extension that adds Magento 2-specific static analysis capabilities for both modules and applications.
bitexpert/phpstan-magento is a PHPStan extension specifically designed for Magento 2 projects. It enhances PHPStan's static analysis capabilities to understand Magento's unique architecture, including factory/proxy classes, magic methods, and extension attributes. This allows developers to catch errors and enforce best practices in Magento module and application codebases.
Magento 2 developers and teams who want to improve code quality through static analysis. It's particularly valuable for developers maintaining large Magento codebases or building custom modules where type safety and architectural consistency are important.
Developers choose this extension because it provides Magento-aware static analysis that standard PHPStan cannot offer. It understands Magento-specific patterns and conventions, reducing false positives and catching real issues that matter in the Magento ecosystem, ultimately leading to more robust and maintainable Magento applications.
Magento specific extension for PHPStan
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Correctly handles Magento's unique architecture like factory/proxy class generation and magic methods, reducing false positives that standard PHPStan would report, as detailed in the feature overview.
Includes custom PHPStan rules to enforce Magento coding standards, such as avoiding setTemplate in Block classes and using service contracts, helping maintain architectural consistency.
Adds accurate type hints for Magento's ObjectManager and TestFramework, improving code navigation and error detection in complex Magento code, as highlighted in the type hints feature.
Can be installed via Composer with the phpstan/extension-installer, simplifying setup for both module and application projects, as described in the installation section.
Requires Magento 2.3.0+ and PHPStan 2.0+, forcing manual upgrades for older setups and adding complexity, as noted in the requirements where users must change PHPStan versions in composer.json.
Focused solely on Magento, so it provides no benefits for non-Magento code in mixed projects, potentially requiring separate static analysis tools for other parts of the codebase.
Involves handling Composer plugins and allow-plugins configuration, which can be a hurdle for teams unfamiliar with these settings, as mentioned in the Composer Allow-Plugins section.