bitexpert / phpstan-magento
PHPStan Magento 扩展
Requires
- php: ^7.2.0 || ^8.1.0
- ext-dom: *
- laminas/laminas-code: ~3.3.0 || ~3.4.1 || ~3.5.1 || ^4.5 || ^4.10
- phpstan/phpstan: ~1.12.0
- symfony/finder: ^3.0 || ^4.0 || ^5.0 || ^6.0
Requires (Dev)
- captainhook/captainhook: ^5.10.9
- captainhook/plugin-composer: ^5.3.3
- league/commonmark: ^2.3.1
- madewithlove/license-checker: ^0.10.0 || ^1.4
- magento/framework: >=102.0.0
- mikey179/vfsstream: ^1.6.10
- nette/neon: ^3.3.3
- nikic/php-parser: ^4.13.2
- phpstan/extension-installer: ^1.1.0
- phpstan/phpstan-phpunit: ^1.1.1
- phpstan/phpstan-strict-rules: ^1.2.3
- phpunit/phpunit: ^9.5.20
- squizlabs/php_codesniffer: ^3.6.2
Conflicts
- magento/framework: <102.0.0
- dev-master
- v0.32.0
- v0.31.0
- v0.30.1
- v0.30.0
- v0.29.0
- v0.28.0
- v0.27.0
- v0.26.0
- v0.25.0
- v0.24.0
- v0.23.1
- v0.23.0
- v0.22.0
- v0.21.0
- v0.20.0
- v0.19.0
- v0.18.0
- v0.17.0
- v0.16.0
- v0.15.0
- v0.14.0
- v0.13.0
- v0.12.0
- v0.11.0
- v0.10.0
- v0.9.0
- v0.8.0
- v0.7.0
- v0.6.0
- v0.5.0
- v0.4.1
- v0.4.0
- v0.3.0
- v0.2.0
- v0.1.1
- v0.1.0
- dev-dependabot/composer/nikic/php-parser-tw-5.2.0
- dev-release/r0.32.0
- dev-release/r0.31.0
- dev-release/r0.30.0
- dev-release/r0.29.0
- dev-release/r0.28.0
- dev-release/r0.27.0
- dev-release/r0.26.0
- dev-release/r0.25.0
- dev-release/r0.24.0
- dev-release/r0.23.0
- dev-release/r0.22.0
- dev-release/r0.21.0
- dev-release/r0.20.0
- dev-release/r0.19.0
- dev-release/r0.18.0
- dev-release/r0.17.0
- dev-release/r0.16.0
- dev-release/r0.15.0
- dev-release/r0.14.0
- dev-release/r0.13.0
- dev-release/r0.12.0
- dev-release/r0.11.0
- dev-release/r0.10.0
- dev-release/r0.9.0
- dev-release/r0.8.0
- dev-release/r0.7.0
- dev-release/r0.6.0
- dev-release/r0.5.0
- dev-release/r0.4.0
- dev-release/r0.3.0
- dev-release/r0.2.0
- dev-release/r0.1.0
This package is auto-updated.
Last update: 2024-09-16 04:41:20 UTC
README
此软件包为 PHPStan 提供了一些附加功能,使其适用于 Magento 2 项目。您可以使用此 PHPStan 扩展用于 Magento 模块项目和 Magento 应用程序项目。
要求
PHP: PHP 7.2 或更高版本
Magento: Magento 2.3.0 或更高版本
PHPStan: PHPStan 1.12
如果您正在使用需要较旧版本 PHPStan 的 Magento 版本(例如 0.12.77),在安装此扩展之前需要手动升级。在您的 composer.json 中,将 PHPStan 版本更改为 ~1.12
并运行
composer update phpstan/phpstan --with-all-dependencies
此 PHPStan 扩展需要与 PHPStan 注册,以便正确加载扩展。最简单的方法是按照以下方式安装 phpstan/extension-installer
软件包
composer.phar require --dev phpstan/extension-installer
Composer 允许插件配置
如果您正在使用 Composer >= 2.2.0,您必须允许执行 composer 插件(查看 allow-plugins 部分),如下所示
- 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.cn/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
安装
安装 bitexpert/phpstan-magento
的首选方式是通过 Composer。您可以将 bitexpert/phpstan-magento
添加为开发依赖项,如下所示
composer.phar require --dev bitexpert/phpstan-magento
想要详细了解安装和配置过程?请阅读 M.academy 上的博客文章,关于使用 PHPStan 在 Magento 中进行静态分析。
PHPStan 配置
如果您在项目中还没有 PHPStan 配置文件 phpstan.neon
,请在与您的 composer.json
文件相邻的位置创建一个新空文件。
有关 PHPStan 允许您配置的选项,请参阅此处。
功能概述
此 PHPStan 扩展适用于 Magento 模块项目和 Magento 应用程序项目。
- 为工厂和代理类生成类
- 模拟类自动加载器
- TestFramework 自动加载器
- 类型提示
- TestFramework ObjectManager 类型提示
- ObjectManager 类型提示
- 魔术方法调用
- 扩展属性
- PHPStan 规则
- 服务契约
- 应直接使用资源模型
- 应通过工厂直接使用集合
- 不要在 Block 类中使用 setTemplate
有关详细概述,请检查功能文档此处。
贡献
请随时分叉并扩展现有功能或添加新功能,并将您的更改作为拉取请求发送!为了建立一致的代码质量,请为所有更改提供单元测试并修改文档。
想要贡献吗?
如果您觉得您有东西可以分享,那么我们非常愿意邀请您。请查看贡献指南,了解如何以及我们期望您做什么。
许可
PHPStan Magento 扩展在 MIT 许可下发布。