定制 vishwac09/extended-php-guidelines 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

vishwac09/extended-php-guidelines

最新稳定版本:1.0.0

Composer 安装命令:

composer require vishwac09/extended-php-guidelines

包简介

Provides set of additional coding/style guidelines to sniff PHP code.

README 文档

README

Apart from the PSR-1, PSR-2, PSR-12 and the Drupal standard's, we follow few more to achieve consistency of code project wide.

I work mostly on Drupal projects, so normally use the Drupal Coding standard to sniff the custom code for any violations. This PHP library is a type of PHP-CodeSniffer standard which checks PHP code against the below list.

List

  1. Order of imports - Group Drupal/Symfony imports and third party libraries added via composer separately.
  2. Avoid Switch case - PHP >= 8.0 provides match() {} expression, can be replaced in place of switch() case:.
  3. Avoid Static Class references - Cannot be injected.
  4. Order of member functions - Order member function in ascending order, improves readability.

Usage

Create a project, and add this packages as DEV dependancy.

Installation

Add via composer as local dependencies

composer require --dev dealerdirect/phpcodesniffer-composer-installer
composer require --dev vishwac09/extended-php-guidelines

OR

Add via composer as global dependencies

composer require global --dev dealerdirect/phpcodesniffer-composer-installer
composer require global --dev vishwac09/extended-php-guidelines

Add via GIT

git clone git@github.com:vishwac09/extended-php-guidelines.git

add the standard to phpcs

phpcs --config-set installed_paths /path/to/extended-php-guidelines/EPG

Run

Check if the new stanadard is configures with phpcs.

phpcs -i

Sniff code for the above violation.

phpcs --standard=EPG --colors file1.php, file2.inc

Example

FILE: /Users/hp/Documents/temp.php
------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 5 WARNINGS AFFECTING 5 LINES
------------------------------------------------------------------------------------------------------
  1 | WARNING | Group Drupal/Symfony imports and third party libraries added via composer separately.
 26 | WARNING | Member functions of class must be defined in ascending order
 28 | WARNING | Do not use static class references.
 40 | WARNING | Member functions of interface must be defined in ascending order
 50 | WARNING | Do not use switch expression. With PHP >= 8.0 use the new match expression
    |         | (https://www.php.net/manual/en/control-structures.match.php).
------------------------------------------------------------------------------------------------------

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2022-11-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固