|
| 1 | +<?php declare(strict_types=1); |
| 2 | + |
| 3 | +use PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff; |
| 4 | +use PhpCsFixer\Fixer\Basic\NonPrintableCharacterFixer; |
| 5 | +use PhpCsFixer\Fixer\CastNotation\ModernizeTypesCastingFixer; |
| 6 | +use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer; |
| 7 | +use PhpCsFixer\Fixer\ClassNotation\SelfAccessorFixer; |
| 8 | +use PhpCsFixer\Fixer\ConstantNotation\NativeConstantInvocationFixer; |
| 9 | +use PhpCsFixer\Fixer\FunctionNotation\FopenFlagsFixer; |
| 10 | +use PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer; |
| 11 | +use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer; |
| 12 | +use PhpCsFixer\Fixer\FunctionNotation\NullableTypeDeclarationForDefaultNullValueFixer; |
| 13 | +use PhpCsFixer\Fixer\FunctionNotation\SingleLineThrowFixer; |
| 14 | +use PhpCsFixer\Fixer\FunctionNotation\VoidReturnFixer; |
| 15 | +use PhpCsFixer\Fixer\LanguageConstruct\ExplicitIndirectVariableFixer; |
| 16 | +use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer; |
| 17 | +use PhpCsFixer\Fixer\Operator\ConcatSpaceFixer; |
| 18 | +use PhpCsFixer\Fixer\Operator\OperatorLinebreakFixer; |
| 19 | +use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer; |
| 20 | +use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer; |
| 21 | +use PhpCsFixer\Fixer\Phpdoc\PhpdocAlignFixer; |
| 22 | +use PhpCsFixer\Fixer\Phpdoc\PhpdocAnnotationWithoutDotFixer; |
| 23 | +use PhpCsFixer\Fixer\Phpdoc\PhpdocIndentFixer; |
| 24 | +use PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer; |
| 25 | +use PhpCsFixer\Fixer\Phpdoc\PhpdocNoPackageFixer; |
| 26 | +use PhpCsFixer\Fixer\Phpdoc\PhpdocOrderFixer; |
| 27 | +use PhpCsFixer\Fixer\Phpdoc\PhpdocSummaryFixer; |
| 28 | +use PhpCsFixer\Fixer\Phpdoc\PhpdocToCommentFixer; |
| 29 | +use PhpCsFixer\Fixer\Phpdoc\PhpdocTrimConsecutiveBlankLineSeparationFixer; |
| 30 | +use PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer; |
| 31 | +use PhpCsFixer\Fixer\PhpTag\LinebreakAfterOpeningTagFixer; |
| 32 | +use PhpCsFixer\Fixer\PhpUnit\PhpUnitConstructFixer; |
| 33 | +use PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertFixer; |
| 34 | +use PhpCsFixer\Fixer\PhpUnit\PhpUnitDedicateAssertInternalTypeFixer; |
| 35 | +use PhpCsFixer\Fixer\PhpUnit\PhpUnitMockFixer; |
| 36 | +use PhpCsFixer\Fixer\PhpUnit\PhpUnitMockShortWillReturnFixer; |
| 37 | +use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestCaseStaticMethodCallsFixer; |
| 38 | +use PhpCsFixer\Fixer\ReturnNotation\NoUselessReturnFixer; |
| 39 | +use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer; |
| 40 | +use PhpCsFixer\Fixer\StringNotation\ExplicitStringVariableFixer; |
| 41 | +use PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer; |
| 42 | +use PhpCsFixer\Fixer\Whitespace\BlankLineBeforeStatementFixer; |
| 43 | +use PhpCsFixer\Fixer\Whitespace\CompactNullableTypehintFixer; |
| 44 | +use PhpCsFixerCustomFixers\Fixer\NoImportFromGlobalNamespaceFixer; |
| 45 | +use PhpCsFixerCustomFixers\Fixer\NoSuperfluousConcatenationFixer; |
| 46 | +use PhpCsFixerCustomFixers\Fixer\NoUselessCommentFixer; |
| 47 | +use PhpCsFixerCustomFixers\Fixer\NoUselessParenthesisFixer; |
| 48 | +use PhpCsFixerCustomFixers\Fixer\NoUselessStrlenFixer; |
| 49 | +use PhpCsFixerCustomFixers\Fixer\PhpdocTypesCommaSpacesFixer; |
| 50 | +use PhpCsFixerCustomFixers\Fixer\SingleSpaceAfterStatementFixer; |
| 51 | +use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayListItemNewlineFixer; |
| 52 | +use Symplify\CodingStandard\Fixer\ArrayNotation\ArrayOpenerAndCloserNewlineFixer; |
| 53 | +use Symplify\CodingStandard\Fixer\ArrayNotation\StandaloneLineInMultilineArrayFixer; |
| 54 | +use Symplify\CodingStandard\Fixer\Spacing\StandaloneLineConstructorParamFixer; |
| 55 | +use Symplify\EasyCodingStandard\Config\ECSConfig; |
| 56 | +use Symplify\EasyCodingStandard\ValueObject\Set\SetList; |
| 57 | + |
| 58 | +return static function (ECSConfig $ecsConfig): void { |
| 59 | + $ecsConfig->dynamicSets([ |
| 60 | + '@Symfony', |
| 61 | + '@Symfony:risky', |
| 62 | + ]); |
| 63 | + |
| 64 | + $ecsConfig->sets([ |
| 65 | + SetList::ARRAY, |
| 66 | + SetList::CONTROL_STRUCTURES, |
| 67 | + SetList::STRICT, |
| 68 | + SetList::PSR_12, |
| 69 | + ]); |
| 70 | + |
| 71 | + $ecsConfig->rules([ |
| 72 | + ModernizeTypesCastingFixer::class, |
| 73 | + NativeConstantInvocationFixer::class, |
| 74 | + NullableTypeDeclarationForDefaultNullValueFixer::class, |
| 75 | + VoidReturnFixer::class, |
| 76 | + OperatorLinebreakFixer::class, |
| 77 | + PhpdocLineSpanFixer::class, |
| 78 | + PhpUnitConstructFixer::class, |
| 79 | + PhpUnitDedicateAssertInternalTypeFixer::class, |
| 80 | + PhpUnitMockFixer::class, |
| 81 | + PhpUnitMockShortWillReturnFixer::class, |
| 82 | + PhpUnitTestCaseStaticMethodCallsFixer::class, |
| 83 | + NoUselessReturnFixer::class, |
| 84 | + DeclareStrictTypesFixer::class, |
| 85 | + BlankLineBeforeStatementFixer::class, |
| 86 | + CompactNullableTypehintFixer::class, |
| 87 | + NoImportFromGlobalNamespaceFixer::class, |
| 88 | + NoSuperfluousConcatenationFixer::class, |
| 89 | + NoUselessCommentFixer::class, |
| 90 | + SingleSpaceAfterStatementFixer::class, |
| 91 | + NoUselessParenthesisFixer::class, |
| 92 | + NoUselessStrlenFixer::class, |
| 93 | + PhpdocTypesCommaSpacesFixer::class, |
| 94 | + StandaloneLineConstructorParamFixer::class, |
| 95 | + ]); |
| 96 | + |
| 97 | + $ecsConfig->ruleWithConfiguration(PhpdocAlignFixer::class, ['align' => 'left']); |
| 98 | + $ecsConfig->ruleWithConfiguration(PhpdocOrderFixer::class, ['order' => ['param', 'throws', 'return']]); |
| 99 | + $ecsConfig->ruleWithConfiguration(ClassAttributesSeparationFixer::class, ['elements' => ['property' => 'one', 'method' => 'one']]); |
| 100 | + $ecsConfig->ruleWithConfiguration(MethodArgumentSpaceFixer::class, ['on_multiline' => 'ensure_fully_multiline']); |
| 101 | + $ecsConfig->ruleWithConfiguration(NativeFunctionInvocationFixer::class, [ |
| 102 | + 'include' => [NativeFunctionInvocationFixer::SET_COMPILER_OPTIMIZED], |
| 103 | + 'scope' => 'namespaced', |
| 104 | + 'strict' => false, |
| 105 | + 'exclude' => ['ini_get'], |
| 106 | + ]); |
| 107 | + $ecsConfig->ruleWithConfiguration(ConcatSpaceFixer::class, ['spacing' => 'one']); |
| 108 | + $ecsConfig->ruleWithConfiguration(GeneralPhpdocAnnotationRemoveFixer::class, ['annotations' => ['copyright', 'category']]); |
| 109 | + $ecsConfig->ruleWithConfiguration(NoSuperfluousPhpdocTagsFixer::class, ['allow_unused_params' => true, 'allow_mixed' => true]); |
| 110 | + $ecsConfig->ruleWithConfiguration(PhpUnitDedicateAssertFixer::class, ['target' => 'newest']); |
| 111 | + $ecsConfig->ruleWithConfiguration(SingleQuoteFixer::class, ['strings_containing_single_quote_chars' => true]); |
| 112 | + // workaround for https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/5495 |
| 113 | + $ecsConfig->ruleWithConfiguration(BinaryOperatorSpacesFixer::class, [ |
| 114 | + 'operators' => [ |
| 115 | + '|' => null, |
| 116 | + '&' => null, |
| 117 | + ], |
| 118 | + ]); |
| 119 | + |
| 120 | + $ecsConfig->cacheDirectory($_SERVER['SHOPWARE_TOOL_CACHE_ECS'] ?? 'var/cache/cs_fixer'); |
| 121 | + $ecsConfig->cacheNamespace('platform'); |
| 122 | + |
| 123 | + $ecsConfig->parallel(); |
| 124 | + $ecsConfig->lineEnding('\n'); |
| 125 | + |
| 126 | + $ecsConfig->skip([ |
| 127 | + // Fixture |
| 128 | + 'src/WebInstaller/Tests/_fixtures/Options.php', |
| 129 | + // skip php files in node modules (stylelint ships both js and php) |
| 130 | + '**/node_modules', |
| 131 | + |
| 132 | + ArrayOpenerAndCloserNewlineFixer::class => null, |
| 133 | + ArrayListItemNewlineFixer::class => null, |
| 134 | + SingleLineThrowFixer::class => null, |
| 135 | + SelfAccessorFixer::class => null, |
| 136 | + ExplicitIndirectVariableFixer::class => null, |
| 137 | + BlankLineAfterOpeningTagFixer::class => null, |
| 138 | + PhpdocSummaryFixer::class => null, |
| 139 | + ExplicitStringVariableFixer::class => null, |
| 140 | + StandaloneLineInMultilineArrayFixer::class => null, |
| 141 | + AssignmentInConditionSniff::class => null, |
| 142 | + PhpdocToCommentFixer::class => null, |
| 143 | + PhpdocAnnotationWithoutDotFixer::class => null, |
| 144 | + PhpdocNoPackageFixer::class => null, |
| 145 | + StandaloneLineConstructorParamFixer::class => null, |
| 146 | + LinebreakAfterOpeningTagFixer::class => null, |
| 147 | + FopenFlagsFixer::class => null, |
| 148 | + ]); |
| 149 | +}; |
0 commit comments