定制 aretche/php-code-quality 二次开发

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

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

aretche/php-code-quality

Composer 安装命令:

composer require aretche/php-code-quality

包简介

Code Quality scripts that can be run via Composer in Symfony projects. (forked from karriere/code-quality)

README 文档

README

Build Status Code Style

Code Quality for PHP packages

This package provides code quality scripts that can be run via Composer.

The scripts also work on continous integration (CI) servers like Jenkins.

Used packages

FriendsOfPHP/PHP-CS-Fixer

Currently used for fixing the code.
Fixes all files in src directory according Symfony coding guidelines.

This package is not used for checking (linting), because PHP_Codesniffer prints a more readable output.

squizlabs/PHP_CodeSniffer

Currently used for checking (linting) the code.
Sniffs all files in src directory.

This package could also be used for fixing, but PHP-CS-Fixer does it better.

phpmd/phpmd

Used for mess detection.
Runs the defined ruleset (config/phpmd.xml) on all files in src directory.

phpstan/phpstan

Used for static analysis.
Perform static analysis on all files in src directory.

phpunit/phpunit

Used for testing the code.
Must be configured with a phpunit.xml file in your root folder.

lchrusciel/api-test-case

Based on PHPUnit and used for testing API methods.

phpspec/phpspec

Used for testing (SpecBDD) the code.
Must be configured with a phpspec.yml file in your root folder.

We are using the leanphp/phpspec-code-coverage extension for generating coverage reports.
This extension requires a phpspec-coverage.yml file in your root folder and Xdebug enabled.

Installation

Run composer require --dev aretche/php-code-quality to install this package.

After installing, insert the desired scripts to your composer.json.

{
    "scripts": {
        "lint": "Karriere\\CodeQuality\\CodeStyleChecker::run",
        "fix": "Karriere\\CodeQuality\\CodeStyleFixer::run",
        "md": "Karriere\\CodeQuality\\MessDetector::run",
        "static": "Karriere\\CodeQuality\\StaticAnalyzer::run",
        "unit-test": "Karriere\\CodeQuality\\UnitTest::run",
        "unit-coverage": "Karriere\\CodeQuality\\UnitCoverage::run",
        "check-coverage": "Karriere\\CodeQuality\\CloverCoverageCheck::run",
        "spec-test": "Karriere\\CodeQuality\\SpecificationTest::run",
        "spec-coverage": "Karriere\\CodeQuality\\CodeCoverage::run"
    }
}

Usage

You can run a script like this: composer {script} -- {options}.

If you are using Git-Shell on Windows (or Git-Shell in Intellij Terminal on Windows), call scripts like this: composer.bat {script}. Otherwise colors will not work.

You can disable TTY by adding the --notty flag (needed for Jenkins).
On Windows platform it's disabled automatically.

composer {script} -- --env=jenkins --notty

Scripts

lint

Usage:
  lint [--] [options]

Options:
      --env    Specifiy the environment. Possible values:
               'local': prints output on command-line.
               'jenkins': generates a checkstyle report file.
      --fail   Exit with 1 if linting fails.
      --notty  Disable TTY.

static

Usage:
  static [--] [options]

Options:
      --env    Specifiy the environment. Possible values:
               'local': prints output on command-line.
               'jenkins': generates a json report file (phpstan.json).
      --notty  Disable TTY.

md

Usage:
  md [--] [options]

Options:
      --env    Specifiy the environment. Possible values:
               'local': prints output on command-line.
               'jenkins': generates a xml report file (phpmd.xml).
      --notty  Disable TTY.

fix

Usage:
  fix [--] [options]

Options:
      --dry-run  Show changes to be applyed. 
      --notty    Disable TTY.

unit-test

Usage:
  unit-test [--] [options]

Options:
      --fail     Exit with 1 if tests fail.
      --notty    Disable TTY.
   -v --verbose  Increase the verbosity of messages.

unit-coverage

Usage:
  unit-coverage [--] [options]

Options:
      --env    Specifiy the environment. Possible values:
               'local': generate html report in coverage directory.
               'jenkins': generates clover.xml coverage report in root directory.
      --notty  Disable TTY.

check-coverage

Usage:
  check-coverage [--] [options]

Options:
      --min-coverage    Specify minimal coverage level. Possible
                        values: 0, 25, 50, 100 (default)    
      --fail            Exit with 1 on insufficient coverage.
      --notty           Disable TTY.

spec-test

Usage:
  spec-test [--] [options]

Options:
      --fail     Exit with 1 if tests fail.
      --notty    Disable TTY.
   -v --verbose  Increase the verbosity of messages.

spec-coverage

Usage:
  spec-coverage [--] [options]

Options:
      --env    Specifiy the environment. Possible values:
               'local': prints output on command-line.
               'jenkins': generates a JUnit report file.
      --notty  Disable TTY.

Using custom matchers

This package integrates karriere/phpspec-matchers. In order to use the custom matchers defined in this package, please include the extension configuration in your phpspec.yml.

FAQ

Why do I have to provide two phpspec configuration files?

The code-coverage-extension slows down the phpspec tests, so we excluded it from the normal configuration file. Keep tests fast!

How do I increase the verbosity of the test-script output?

Run composer test -- -v.

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2019-02-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固