acquia/coding-standards 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

acquia/coding-standards

Composer 安装命令:

composer require --dev acquia/coding-standards

包简介

PHP_CodeSniffer rules (sniffs) for Acquia coding standards

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License Tests

Acquia Coding Standards for PHP is a collection of PHP_CodeSniffer rules (sniffs) for Acquia coding standards for PHP projects, including Drupal extensions.

Notice: We have renamed our master branch to main. If you depend on dev-master, you'll need to switch to dev-main or an actual version like ^3.0.

Rules

Acquia Coding Standards for PHP includes a selection of sniffs from the following rulesets:

Rulesets

Rules are split into rulesets according to the project framework and audience:

  • Projects targeting the Drupal community, e.g., Drupal modules, should adopt a Drupal ruleset. All others should adopt a (more generalized) PHP ruleset.
  • Public projects, e.g., open-source Drupal modules, should adopt a non-strict ruleset to facilitate external collaboration. All others should adopt a more opinionated internal ruleset.

There are four permutations of these guidelines, leading to four rulesets to choose from:

  • AcquiaDrupalMinimal is based on the Drupal coding standard and is intended for use on all public Drupal projects.
  • AcquiaDrupalStrict is based on AcquiaDrupal and adds the more opinionated DrupalPractice standard. It is intended for use on all internal Drupal projects.
  • AcquiaPHPMinimal is based on PSR-12 and is intended for use on all public non-Drupal projects.
  • AcquiaPHPStrict is based on AcquiaPHP and adds additional, more opinionated standards. It is intended for use on all internal, non-Drupal projects.

Installation & usage

  1. Add Acquia Coding Standards for PHP to your project via Composer:

    composer require --dev acquia/coding-standards

    If you want to add PHP cross-version compatibility checks, we suggest PHPCompatibility.

  2. Inform PHP CodeSniffer of the location of the standard and its dependencies:

    • It is strongly recommended that you use a Composer plugin to handle this for you, e.g., DealerDirect/phpcodesniffer-composer-installer:

      composer config extra.phpcodesniffer-search-depth 4
      composer require --dev dealerdirect/phpcodesniffer-composer-installer
    • Alternatively, add a script to your composer.json to handle it:

      {
          "scripts": {
              "post-install-cmd": "@install-coding-standards",
              "post-update-cmd" : "@install-coding-standards",
              "install-coding-standards": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/acquia/coding-standards/src/Standards,vendor/drupal/coder/coder_sniffer,vendor/slevomat/coding-standard"
          }
      }
  3. Check code for standards compliance:

    ./vendor/bin/phpcs --standard=AcquiaDrupalStrict --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml path/to/code

    Automatically fix any standards violations possible:

    ./vendor/bin/phpcbf --standard=AcquiaDrupalStrict --extensions=php,module,inc,install,test,profile,theme,css,info,txt,md,yml path/to/code

    The --extensions argument must match the chosen code standard. For AcquiaPHP, use --extensions=php,inc,test,css,txt,md,yml.

  4. Optionally create a default configuration file for your project so you don't have to provide the command-line arguments every time (i.e., below). Here's a working example: example/phpcs.xml.dist.

    ./vendor/bin/phpcs

    Modify phpcs.xml.dist to suit your project, especially to set the preferred code standard and matching extensions.

  5. Optionally add code checking to your Git pre-commit hook to prevent committing code with violations. Since client-side Git hooks are not copied when a repository is cloned, you might like to use an automated solution like BrainMaestro/composer-git-hooks to manage them, for example: example/composer.json.

  6. Optionally configure PHP Code Sniffer integration in PhpStorm or your IDE or code editor of choice. You can import example/PhpStormInspections.xml to set up default integration for new projects. When you open or create a new project for the first time, PhpStorm should automatically detect and set up PHPCS inspections based on these defaults. You will just need to uncheck the “installed standards paths” in the inspection settings for your project so that PhpStorm can find the Acquia Coding Standards.

Branches and supported release lines

The project currently maintains these long-lived branches:

  • main for releases in the active 4.x line.
  • develop for ongoing 4.x development. In Composer, this branch is aliased as 4.x-dev.
  • support/3 for long-term support releases in the 3.x line. In Composer, this branch is aliased as 3.x-dev.

See CONTRIBUTING.md for pull request targeting guidance and RELEASING.md for maintainer release steps.

Contribution

Contributions are welcome! See CONTRIBUTING.md.

License

Copyright (C) 2019 Acquia, Inc.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

acquia/coding-standards 适用场景与选型建议

acquia/coding-standards 是一款 基于 Shell 开发的 Composer 扩展包,目前已累计 4.96M 次下载、GitHub Stars 达 21, 最近一次更新时间为 2019 年 06 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「drupal」 「static analysis」 「standards」 「phpcs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 acquia/coding-standards 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 acquia/coding-standards 我们能提供哪些服务?
定制开发 / 二次开发

基于 acquia/coding-standards 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.96M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 23
  • 点击次数: 31
  • 依赖项目数: 25
  • 推荐数: 0

GitHub 信息

  • Stars: 21
  • Watchers: 10
  • Forks: 15
  • 开发语言: Shell

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2019-06-17