承接 smile/magento2-smilelab-phpcs 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

smile/magento2-smilelab-phpcs

最新稳定版本:4.0.0

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
{
    // ...
}

统计信息

  • 总下载量: 60.09k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 7
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2017-01-25