kraska/coding-standard

代码/项目质量保证的统一标准。

0.1.1 2021-07-04 18:00 UTC

This package is auto-updated.

Last update: 2024-09-05 00:30:34 UTC


README

统一标准确保所有我的php项目的代码/项目质量。

安装

$ composer require --dev kraska/coding-standard ergebnis/composer-normalize friendsofphp/php-cs-fixer phpstan/phpstan phpstan/phpstan-phpunit roave/security-advisories:dev-latest

设置

// php-cs-fixer.dist.php
<?php

declare(strict_types=1);

use Kraska\CodingStandard\PhpCsFixerRuleSetFactory;

$finder = PhpCsFixer\Finder::create()
    ->in(__DIR__);

return (new PhpCsFixer\Config())
    ->setRules(PhpCsFixerRuleSetFactory::create())
    ->setRiskyAllowed(true)
    ->setFinder($finder);
# phpstan.dist.neon
includes:
  - vendor/phpstan/phpstan-phpunit/extension.neon
parameters:
  level: 8
  paths:
    - ./
  excludePaths:
    - ./vendor/*
# .gitignore

### php-cs-fixer ###
.php-cs-fixer.cache

脚本

// composer.json
{
  "scripts": {
    "php:fix": [
      "composer normalize",
      "php vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --verbose"
    ],
    "php:lint": [
      "composer normalize --dry-run --diff",
      "php vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --verbose --dry-run --diff",
      "php vendor/bin/phpstan analyse --configuration=phpstan.dist.neon"
    ]
  }
}