bitexpert/phpstan-magento
Composer 安装命令:
composer require bitexpert/phpstan-magento
包简介
PHPStan Magento Extension
README 文档
README
This package provides some additional features for PHPStan to make it work for Magento 2 projects. You can use this PHPStan extension for both Magento module projects and Magento application projects.
Requirements
PHP: PHP 7.2 or higher
Magento: Magento 2.3.0 or higher
PHPStan: PHPStan 2.0 or higher
If you are using a Magento version that requires an older version of PHPStan (e.g. 0.12.77), you need to manually upgrade it before
installing this extension. In your composer.json Change the PHPStan version to ~2.0 and run:
composer update phpstan/phpstan --with-all-dependencies
This PHPStan extension needs to be registered with PHPStan so that the extension gets loaded properly. The easiest way to do this is
to install the phpstan/extension-installer package as follows:
composer.phar require --dev phpstan/extension-installer
Composer Allow-Plugins configuration
If you're using Composer >= 2.2.0 you have to allow the execution of composer plugins (see allow-plugins section) as follows:
- Installing phpstan/extension-installer (1.1.0): Extracting archive
phpstan/extension-installer contains a Composer plugin which is currently not in your allow-plugins config. See https://getcomposer.org/allow-plugins
Do you trust "phpstan/extension-installer" to execute code and wish to enable it now? (writes "allow-plugins" to composer.json) [y,n,d,?] y
Installation
The preferred way of installing bitexpert/phpstan-magento is through Composer.
You can add bitexpert/phpstan-magento as a dev dependency, as follows:
composer.phar require --dev bitexpert/phpstan-magento
Want a full walk-through of the installation & configuration process? Read the blog post at M.academy about Static Analysis in Magento with PHPStan.
PHPStan configuration
If you have not already a PHPStan configuration file phpstan.neon in your project, create a new empty file next to your composer.json file.
See here what options PHPStan allows you to configure.
Feature overview
This PHPStan extension works for both Magento module projects and Magento application projects.
- Class generator for factory & proxy classes
- Mocked classes autoloader
- TestFramework autoloader
- Type hints
- TestFramework ObjectManager type hints
- ObjectManager type hints
- Magic method calls
- Extension attributes
- PHPStan rules
- Service contracts
- Resource Models should be used directly
- Collections should be used directly via factory
- Do not use setTemplate in Block classes
For a detailed overview, check the feature documentation here.
Contribute
Please feel free to fork and extend existing or add new features and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and adapt the documentation.
Want To Contribute?
If you feel that you have something to share, then we’d love to have you. Check out the contributing guide to find out how, as well as what we expect from you.
License
PHPStan Magento Extension is released under the MIT License.
bitexpert/phpstan-magento 适用场景与选型建议
bitexpert/phpstan-magento 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.56M 次下载、GitHub Stars 达 147, 最近一次更新时间为 2019 年 03 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bitexpert/phpstan-magento 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bitexpert/phpstan-magento 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.56M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 148
- 点击次数: 20
- 依赖项目数: 88
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-23