smile/magento2-smilelab-phpcs
Composer 安装命令:
composer require smile/magento2-smilelab-phpcs
包简介
PHPCS coding standard for Magento projects.
README 文档
README
Description
This coding standard is meant to be used on Magento projects and modules.
It uses the following rulesets:
Installation
To use this ruleset, require it in composer:
composer require --dev smile/magento2-smilelab-phpcs
Rulesets
Two rulesets are available:
SmileLab(Magento >=2.4.4)SmileLab-237-243(Magento >=2.3.7 <2.4.4)
Older versions of Magento (<2.4.4) require a separate ruleset, because they use an outdated version of the Magento coding standard.
Configuration
Create a configuration file namedphpcs.xml.dist at the root of your project.
Example for a Magento project:
<?xml version="1.0"?> <ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> <arg name="basepath" value="."/> <arg name="extensions" value="php,phtml"/> <arg name="colors"/> <arg value="p"/> <arg value="s"/> <rule ref="SmileLab"/> <file>app/code</file> <file>app/design</file> </ruleset>
Example for a community module:
<?xml version="1.0"?> <ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> <arg name="basepath" value="."/> <arg name="extensions" value="php,phtml"/> <arg name="colors"/> <arg value="p"/> <arg value="s"/> <config name="php_version" value="{{min_php_version}}"/> <rule ref="SmileLab"/> <file>.</file> <exclude-pattern>vendor/*</exclude-pattern> </ruleset>
Where {{min_php_version}} is the minimum compatible version of PHP required by your module.
For example, if the min version is PHP 7.4:
<config name="php_version" value="70400"/>
Usage
You can run phpcs with this command:
vendor/bin/phpcs --extensions=php,phtml
You can fix most of the errors found with:
vendor/bin/phpcbf --extensions=php,phtml
Guidelines
If your class overrides a method declared in a parent class, use @inheritdoc:
/** * @inheritdoc */ public function execute(InputInterface $input, OutputInterface $output): int { // ... }
smile/magento2-smilelab-phpcs 适用场景与选型建议
smile/magento2-smilelab-phpcs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 62.93k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2017 年 01 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 smile/magento2-smilelab-phpcs 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 smile/magento2-smilelab-phpcs 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 62.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 8
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: OSL-3.0
- 更新时间: 2017-01-25