developion/coding-standards

1.1.3 2024-03-30 08:19 UTC

This package is auto-updated.

Last update: 2024-09-30 09:20:29 UTC


README

基于PSR12,一些有针对性的调整和修复器旨在实现代码的通用一致性。

要求

  • PHP 8.2+

安装

composer require --dev developion/coding-standards

ECS

ecs.php 添加到项目的根目录,并将内容设置为

use Developion\CodingStandards\SetList;

$config = require SetList::DEVELOPION;

return $config->withPaths([
		__DIR__ . '<PATH>',
		__FILE__,
	]);

__DIR__ . '<PATH>' 需要特别注意,因为它需要配置为指向需要检查的项目代码。如果需要,它可以根据需要重复多次。

PHP CS Fixer

.php-cs-fixer.php 添加到项目的根目录,并将内容设置为

use Developion\CodingStandards\SetList;
use PhpCsFixer\Finder;

$finder = (new Finder())
	->in([
		__DIR__ . '<PATH>',
	])
	->ignoreDotFiles(false)
	->ignoreVCSIgnored(true)
	->exclude([
		__DIR__ . '/vendor',
	])
;

$config = require SetList::PHP_CS_FIXER;

return $config($finder);

根据您的代码相应地调整 <PATH>

待办:添加 VS Code 配置