2022-10-12 17:46:05 +00:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
|
|
|
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
|
2023-11-29 17:27:33 +00:00
|
|
|
use PhpCsFixer\Fixer\LanguageConstruct\FunctionToConstantFixer;
|
|
|
|
use PhpCsFixer\Fixer\Operator\OperatorLinebreakFixer;
|
2022-10-12 17:46:05 +00:00
|
|
|
use PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer;
|
|
|
|
use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer;
|
|
|
|
use PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer;
|
2023-01-25 21:33:15 +00:00
|
|
|
use SlevomatCodingStandard\Sniffs\Attributes\AttributeAndTargetSpacingSniff;
|
2022-10-12 17:46:05 +00:00
|
|
|
use SlevomatCodingStandard\Sniffs\Classes\ClassConstantVisibilitySniff;
|
|
|
|
use SlevomatCodingStandard\Sniffs\ControlStructures\NewWithoutParenthesesSniff;
|
|
|
|
use SlevomatCodingStandard\Sniffs\Namespaces\AlphabeticallySortedUsesSniff;
|
|
|
|
use SlevomatCodingStandard\Sniffs\Namespaces\DisallowGroupUseSniff;
|
|
|
|
use SlevomatCodingStandard\Sniffs\Namespaces\MultipleUsesPerLineSniff;
|
|
|
|
use SlevomatCodingStandard\Sniffs\Namespaces\NamespaceSpacingSniff;
|
|
|
|
use SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff;
|
|
|
|
use SlevomatCodingStandard\Sniffs\Namespaces\UseSpacingSniff;
|
|
|
|
use SlevomatCodingStandard\Sniffs\TypeHints\DeclareStrictTypesSniff;
|
|
|
|
use SlevomatCodingStandard\Sniffs\TypeHints\UnionTypeHintFormatSniff;
|
|
|
|
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
|
|
|
|
use Symplify\EasyCodingStandard\Config\ECSConfig;
|
|
|
|
|
2024-01-25 17:31:04 +00:00
|
|
|
return ECSConfig::configure()
|
|
|
|
->withPreparedSets(
|
|
|
|
arrays: true,
|
|
|
|
cleanCode: true,
|
|
|
|
comments: true,
|
|
|
|
controlStructures: true,
|
|
|
|
docblocks: true,
|
|
|
|
namespaces: true,
|
|
|
|
spaces: true,
|
|
|
|
strict: true,
|
|
|
|
symplify: true
|
|
|
|
)
|
|
|
|
->withPhpCsFixerSets(
|
|
|
|
perCS: true,
|
|
|
|
perCSRisky: true,
|
|
|
|
php83Migration: true,
|
|
|
|
php80MigrationRisky: true,
|
|
|
|
)
|
|
|
|
->withRules([
|
2022-10-12 17:46:05 +00:00
|
|
|
AlphabeticallySortedUsesSniff::class,
|
|
|
|
DisallowGroupUseSniff::class,
|
|
|
|
MultipleUsesPerLineSniff::class,
|
|
|
|
NamespaceSpacingSniff::class,
|
2023-11-29 17:27:33 +00:00
|
|
|
OperatorLinebreakFixer::class,
|
2024-01-25 17:31:04 +00:00
|
|
|
NoWhitespaceInBlankLineFixer::class,
|
|
|
|
NewWithoutParenthesesSniff::class,
|
|
|
|
])
|
|
|
|
->withConfiguredRule(ClassConstantVisibilitySniff::class, [
|
|
|
|
'fixable' => true,
|
|
|
|
])
|
|
|
|
->withConfiguredRule(
|
2022-10-12 17:46:05 +00:00
|
|
|
ReferenceUsedNamesOnlySniff::class,
|
|
|
|
[
|
|
|
|
'allowFallbackGlobalConstants' => false,
|
|
|
|
'allowFallbackGlobalFunctions' => false,
|
|
|
|
'allowFullyQualifiedGlobalClasses' => false,
|
|
|
|
'allowFullyQualifiedGlobalConstants' => false,
|
|
|
|
'allowFullyQualifiedGlobalFunctions' => false,
|
|
|
|
'allowFullyQualifiedNameForCollidingClasses' => true,
|
|
|
|
'allowFullyQualifiedNameForCollidingConstants' => true,
|
|
|
|
'allowFullyQualifiedNameForCollidingFunctions' => true,
|
|
|
|
'searchAnnotations' => true,
|
|
|
|
]
|
2024-01-25 17:31:04 +00:00
|
|
|
)
|
2022-10-12 17:46:05 +00:00
|
|
|
|
|
|
|
// define newlines between use statements
|
2024-01-25 17:31:04 +00:00
|
|
|
->withConfiguredRule(
|
|
|
|
UseSpacingSniff::class,
|
|
|
|
[
|
|
|
|
'linesCountAfterLastUse' => 1,
|
|
|
|
'linesCountBeforeFirstUse' => 1,
|
|
|
|
'linesCountBetweenUseTypes' => 1,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
->withConfiguredRule(
|
2022-10-12 17:46:05 +00:00
|
|
|
DeclareStrictTypesSniff::class,
|
|
|
|
[
|
|
|
|
'declareOnFirstLine' => true,
|
|
|
|
'spacesCountAroundEqualsSign' => 0,
|
|
|
|
]
|
2024-01-25 17:31:04 +00:00
|
|
|
)
|
|
|
|
->withConfiguredRule(
|
|
|
|
UnionTypeHintFormatSniff::class,
|
|
|
|
[
|
|
|
|
'nullPosition' => 'last',
|
|
|
|
'shortNullable' => 'no',
|
|
|
|
'withSpaces' => 'no',
|
|
|
|
]
|
|
|
|
)
|
|
|
|
->withConfiguredRule(
|
|
|
|
LineLengthFixer::class,
|
|
|
|
[
|
|
|
|
LineLengthFixer::INLINE_SHORT_LINES => false,
|
|
|
|
]
|
|
|
|
)
|
|
|
|
->withConfiguredRule(
|
2022-10-12 17:46:05 +00:00
|
|
|
NoExtraBlankLinesFixer::class,
|
|
|
|
[
|
|
|
|
'tokens' => ['square_brace_block', 'return', 'extra'],
|
|
|
|
]
|
2024-01-25 17:31:04 +00:00
|
|
|
)
|
|
|
|
->withConfiguredRule(AttributeAndTargetSpacingSniff::class, [
|
2023-01-25 21:33:15 +00:00
|
|
|
'linesCount' => 0,
|
2024-01-25 17:31:04 +00:00
|
|
|
])
|
|
|
|
->withSkip([
|
|
|
|
BlankLineAfterOpeningTagFixer::class,
|
|
|
|
OrderedImportsFixer::class,
|
|
|
|
FunctionToConstantFixer::class,
|
2023-01-25 21:33:15 +00:00
|
|
|
]);
|