christophwurst/nextcloud-coding-standard

Nextcloud 编码标准用于 php cs fixer

v1.3.1 2024-09-19 09:07 UTC

README

Nextcloud 编码标准用于 php cs fixer

安装

将包添加到您的开发依赖项

composer require --dev nextcloud/coding-standard

并创建一个类似于 .php-cs-fixer.dist.php 的文件

<?php

declare(strict_types=1);

require_once './vendor/autoload.php';

use Nextcloud\CodingStandard\Config;

$config = new Config();
$config
	->getFinder()
	->ignoreVCSIgnored(true)
	->notPath('build')
	->notPath('l10n')
	->notPath('src')
	->notPath('vendor')
	->in(__DIR__);
return $config;

要运行修复程序,您首先需要 安装它。然后,您可以通过运行 php-cs-fixer fix 来应用所有自动化修复。

为了方便,您可以将其添加到 composer.jsonscripts 部分

{
    "scripts": {
        "cs:check": "php-cs-fixer fix --dry-run --diff",
        "cs:fix": "php-cs-fixer fix"
    }
}

注意:不要忘记在构建脚本中排除 .php-cs-fixer.dist.php.php-cs-fixer.cache

从 v0.x 升级到 v1.0

在 v1.0 中,php-cs-fixer 已从 v2 升级到 v3。您可能需要稍微调整您的应用程序

  • .php_cs.dist 重命名为 .php-cs-fixer.dist.php
  • .php-cs-fixer.cache 添加到您的忽略文件中