From feeb7d4235d63ca49d8f892ed81fec8dc282a6dd Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Wed, 26 Apr 2023 17:29:23 +0200 Subject: [PATCH] Migrate to php-cs-fixer --- .gitattributes | 3 +- .github/workflows/ci.yaml | 4 +- .php-cs-fixer.dist.php | 63 ++++ .../Dashboard/Provider/PageviewsPerDay.php | 8 +- .../Dashboard/Provider/PageviewsPerPage.php | 2 +- Classes/Dashboard/Provider/Recordviews.php | 2 +- Classes/Domain/Pageview/Factory.php | 12 +- Classes/Domain/Recordview/Factory.php | 4 +- Classes/Domain/Repository/Pageview.php | 2 +- Classes/Middleware/Pageview.php | 2 +- Classes/Middleware/Recordview.php | 2 +- .../Backend/DashboardWidgetGroups.php | 1 + Configuration/RequestMiddlewares.php | 1 + Configuration/TCA/tx_tracking_pageview.php | 2 +- Configuration/TCA/tx_tracking_recordview.php | 2 +- Documentation/Changelog/2.5.0.rst | 3 + Tests/Functional/PageviewTest.php | 6 +- Tests/Functional/RecordviewTest.php | 6 +- composer.json | 2 +- ecs.php | 312 ------------------ phpcs.xml.dist | 22 -- shell.nix | 4 +- 22 files changed, 99 insertions(+), 366 deletions(-) create mode 100644 .php-cs-fixer.dist.php delete mode 100644 ecs.php delete mode 100644 phpcs.xml.dist diff --git a/.gitattributes b/.gitattributes index 0808308..9ef4c84 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,8 +5,7 @@ shell.nix export-ignore .gitattributes export-ignore .gitignore export-ignore -ecs.php export-ignore -phpcs.xml.dist export-ignore phpstan-baseline.neon export-ignore phpstan.neon export-ignore phpunit.xml.dist export-ignore +.php-cs-fixer.dist.php export-ignore diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9b4901c..765c337 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -85,7 +85,7 @@ jobs: - name: Install PHP uses: shivammathur/setup-php@v2 with: - php-version: "7.4" + php-version: "8.2" coverage: none tools: composer:v2 env: @@ -95,7 +95,7 @@ jobs: run: composer install --prefer-dist --no-progress - name: Coding Guideline - run: ./vendor/bin/ecs check + run: ./vendor/bin/php-cs-fixer fix --dry-run --diff tests-mysql: runs-on: ubuntu-latest diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..2a7eada --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,63 @@ +ignoreVCSIgnored(true) + ->in(realpath(__DIR__)) +; + +return (new \PhpCsFixer\Config()) + ->setRiskyAllowed(true) + ->setRules([ + '@DoctrineAnnotation' => true, + '@PSR2' => true, + 'array_syntax' => ['syntax' => 'short'], + 'blank_line_after_opening_tag' => true, + 'braces' => ['allow_single_line_closure' => true], + 'cast_spaces' => ['space' => 'none'], + 'compact_nullable_typehint' => true, + 'concat_space' => ['spacing' => 'one'], + 'declare_equal_normalize' => ['space' => 'none'], + 'dir_constant' => true, + 'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']], + 'function_typehint_space' => true, + 'lowercase_cast' => true, + 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], + 'modernize_strpos' => true, + 'modernize_types_casting' => true, + 'native_function_casing' => true, + 'new_with_braces' => true, + 'no_alias_functions' => true, + 'no_blank_lines_after_phpdoc' => true, + 'no_empty_phpdoc' => true, + 'no_empty_statement' => true, + 'no_extra_blank_lines' => true, + 'no_leading_import_slash' => true, + 'no_leading_namespace_whitespace' => true, + 'no_null_property_initialization' => true, + 'no_short_bool_cast' => true, + 'no_singleline_whitespace_before_semicolons' => true, + 'no_superfluous_elseif' => true, + 'no_trailing_comma_in_singleline_array' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_useless_else' => true, + 'no_whitespace_in_blank_line' => true, + 'ordered_imports' => true, + 'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']], + 'php_unit_mock_short_will_return' => true, + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], + 'phpdoc_no_access' => true, + 'phpdoc_no_empty_return' => true, + 'phpdoc_no_package' => true, + 'phpdoc_scalar' => true, + 'phpdoc_trim' => true, + 'phpdoc_types' => true, + 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], + 'return_type_declaration' => ['space_before' => 'none'], + 'single_quote' => true, + 'single_line_comment_style' => ['comment_types' => ['hash']], + 'single_trait_insert_per_statement' => true, + 'trailing_comma_in_multiline' => ['elements' => ['arrays']], + 'whitespace_after_comma_in_array' => true, + 'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false], + ]) + ->setFinder($finder); diff --git a/Classes/Dashboard/Provider/PageviewsPerDay.php b/Classes/Dashboard/Provider/PageviewsPerDay.php index b08fb94..1a71837 100644 --- a/Classes/Dashboard/Provider/PageviewsPerDay.php +++ b/Classes/Dashboard/Provider/PageviewsPerDay.php @@ -102,16 +102,16 @@ class PageviewsPerDay implements ChartDataProviderInterface $data = []; for ($daysBefore = $this->days; $daysBefore >= 0; $daysBefore--) { - $label = date($this->dateFormat, (int) strtotime('-' . $daysBefore . ' day')); + $label = date($this->dateFormat, (int)strtotime('-' . $daysBefore . ' day')); $labels[$label] = $label; $data[$label] = 0; } - $start = (int) strtotime('-' . $this->days . ' day 0:00:00'); - $end = (int) strtotime('tomorrow midnight'); + $start = (int)strtotime('-' . $this->days . ' day 0:00:00'); + $end = (int)strtotime('tomorrow midnight'); foreach ($this->getPageviewsInPeriod($start, $end) as $day) { - $data[$day['label']] = (int) $day['count']; + $data[$day['label']] = (int)$day['count']; } return [ diff --git a/Classes/Dashboard/Provider/PageviewsPerPage.php b/Classes/Dashboard/Provider/PageviewsPerPage.php index 92b07da..723c95e 100644 --- a/Classes/Dashboard/Provider/PageviewsPerPage.php +++ b/Classes/Dashboard/Provider/PageviewsPerPage.php @@ -145,7 +145,7 @@ class PageviewsPerPage implements ChartDataProviderInterface continue; } - $labels[] = $this->getRecordTitle((int) $row['pid']); + $labels[] = $this->getRecordTitle((int)$row['pid']); $data[] = $row['total']; } diff --git a/Classes/Dashboard/Provider/Recordviews.php b/Classes/Dashboard/Provider/Recordviews.php index a88752b..c6bd398 100644 --- a/Classes/Dashboard/Provider/Recordviews.php +++ b/Classes/Dashboard/Provider/Recordviews.php @@ -119,7 +119,7 @@ class Recordviews implements ChartDataProviderInterface continue; } $record = $this->getRecord( - (int) $recordview['record_uid'], + (int)$recordview['record_uid'], $recordview['record_table_name'] ); diff --git a/Classes/Domain/Pageview/Factory.php b/Classes/Domain/Pageview/Factory.php index fe5884f..4dd7b1e 100644 --- a/Classes/Domain/Pageview/Factory.php +++ b/Classes/Domain/Pageview/Factory.php @@ -49,8 +49,8 @@ class Factory $this->getRouting($request)->getPageId(), $this->getLanguage($request), new DateTimeImmutable(), - (int) $this->getRouting($request)->getPageType(), - (string) $request->getUri(), + (int)$this->getRouting($request)->getPageType(), + (string)$request->getUri(), $request->getHeader('User-Agent')[0] ?? '' ); } @@ -58,13 +58,13 @@ class Factory public function fromDbRow(array $dbRow): Pageview { return new Pageview( - (int) $dbRow['pid'], - $this->siteFinder->getSiteByPageId((int) $dbRow['pid'])->getLanguageById((int) $dbRow['sys_language_uid']), + (int)$dbRow['pid'], + $this->siteFinder->getSiteByPageId((int)$dbRow['pid'])->getLanguageById((int)$dbRow['sys_language_uid']), new DateTimeImmutable('@' . $dbRow['crdate']), - (int) $dbRow['type'], + (int)$dbRow['type'], $dbRow['url'], $dbRow['user_agent'], - (int) $dbRow['uid'] + (int)$dbRow['uid'] ); } diff --git a/Classes/Domain/Recordview/Factory.php b/Classes/Domain/Recordview/Factory.php index b97ed29..a2b5c75 100644 --- a/Classes/Domain/Recordview/Factory.php +++ b/Classes/Domain/Recordview/Factory.php @@ -69,9 +69,9 @@ class Factory self::getRouting($request)->getPageId(), self::getLanguage($request), new DateTimeImmutable(), - (string) $request->getUri(), + (string)$request->getUri(), $request->getHeader('User-Agent')[0] ?? '', - (int) $recordUid, + (int)$recordUid, $rule->getTableName() ); } diff --git a/Classes/Domain/Repository/Pageview.php b/Classes/Domain/Repository/Pageview.php index 09d5ecf..79b4f3b 100644 --- a/Classes/Domain/Repository/Pageview.php +++ b/Classes/Domain/Repository/Pageview.php @@ -59,7 +59,7 @@ class Pageview ; if (is_numeric($result)) { - return (int) $result; + return (int)$result; } return 0; diff --git a/Classes/Middleware/Pageview.php b/Classes/Middleware/Pageview.php index f32cce9..3eae658 100644 --- a/Classes/Middleware/Pageview.php +++ b/Classes/Middleware/Pageview.php @@ -88,7 +88,7 @@ class Pageview implements MiddlewareInterface ServerRequestInterface $request, Context $context ): bool { - return (bool) $this->expressionFactory->create( + return (bool)$this->expressionFactory->create( $this->rule, [ 'request' => $request, diff --git a/Classes/Middleware/Recordview.php b/Classes/Middleware/Recordview.php index cc63442..8427790 100644 --- a/Classes/Middleware/Recordview.php +++ b/Classes/Middleware/Recordview.php @@ -93,7 +93,7 @@ class Recordview implements MiddlewareInterface Context $context, RecordRule $rule ): bool { - return (bool) $this->expressionFactory->create( + return (bool)$this->expressionFactory->create( $rule->getMatchesExpression(), [ 'request' => $request, diff --git a/Configuration/Backend/DashboardWidgetGroups.php b/Configuration/Backend/DashboardWidgetGroups.php index eaf82ca..a583646 100644 --- a/Configuration/Backend/DashboardWidgetGroups.php +++ b/Configuration/Backend/DashboardWidgetGroups.php @@ -1,4 +1,5 @@ [ 'title' => 'LLL:EXT:tracking/Resources/Private/Language/locallang.xlf:dashboard.widget.group.tracking', diff --git a/Configuration/RequestMiddlewares.php b/Configuration/RequestMiddlewares.php index 41ad382..15dd5ef 100644 --- a/Configuration/RequestMiddlewares.php +++ b/Configuration/RequestMiddlewares.php @@ -2,6 +2,7 @@ use DanielSiepmann\Tracking\Middleware\Pageview; use DanielSiepmann\Tracking\Middleware\Recordview; + return [ 'frontend' => [ 'danielsiepmann/tracking/pageview' => [ diff --git a/Configuration/TCA/tx_tracking_pageview.php b/Configuration/TCA/tx_tracking_pageview.php index 2efdc5b..834b6fc 100644 --- a/Configuration/TCA/tx_tracking_pageview.php +++ b/Configuration/TCA/tx_tracking_pageview.php @@ -39,7 +39,7 @@ return [ ], 'sys_language_uid' => [ 'label' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.pageview.sys_language', - 'config' => ['type' => 'language'] + 'config' => ['type' => 'language'], ], 'user_agent' => [ 'label' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.pageview.user_agent', diff --git a/Configuration/TCA/tx_tracking_recordview.php b/Configuration/TCA/tx_tracking_recordview.php index 778afb4..145ffa5 100644 --- a/Configuration/TCA/tx_tracking_recordview.php +++ b/Configuration/TCA/tx_tracking_recordview.php @@ -39,7 +39,7 @@ return [ ], 'sys_language_uid' => [ 'label' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.recordview.sys_language', - 'config' => ['type' => 'language'] + 'config' => ['type' => 'language'], ], 'user_agent' => [ 'label' => 'LLL:EXT:tracking/Resources/Private/Language/locallang_tca.xlf:table.recordview.user_agent', diff --git a/Documentation/Changelog/2.5.0.rst b/Documentation/Changelog/2.5.0.rst index d79c92f..a7c3a9c 100644 --- a/Documentation/Changelog/2.5.0.rst +++ b/Documentation/Changelog/2.5.0.rst @@ -30,6 +30,9 @@ Tasks * Remove leftovers of rector We don't need to carry those files if we don't use them right now. +* Migrate to php-cs-fixer + That way this projects follows best practices and is streamlined to other projects. + Deprecation ----------- diff --git a/Tests/Functional/PageviewTest.php b/Tests/Functional/PageviewTest.php index aba43d0..789ffca 100644 --- a/Tests/Functional/PageviewTest.php +++ b/Tests/Functional/PageviewTest.php @@ -64,12 +64,12 @@ class PageviewTest extends TestCase $records = $this->getAllRecords('tx_tracking_pageview'); self::assertCount(1, $records); - self::assertSame('1', (string) $records[0]['pid']); - self::assertSame('1', (string) $records[0]['uid']); + self::assertSame('1', (string)$records[0]['pid']); + self::assertSame('1', (string)$records[0]['uid']); self::assertSame('http://localhost/?id=1', $records[0]['url']); self::assertSame('Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0', $records[0]['user_agent']); self::assertSame('Macintosh', $records[0]['operating_system']); - self::assertSame('0', (string) $records[0]['type']); + self::assertSame('0', (string)$records[0]['type']); } /** diff --git a/Tests/Functional/RecordviewTest.php b/Tests/Functional/RecordviewTest.php index 2c0f423..0fa271e 100644 --- a/Tests/Functional/RecordviewTest.php +++ b/Tests/Functional/RecordviewTest.php @@ -73,13 +73,13 @@ class RecordviewTest extends TestCase $records = $this->getAllRecords('tx_tracking_recordview'); self::assertCount(1, $records); - self::assertSame('1', (string) $records[0]['pid']); - self::assertSame('1', (string) $records[0]['uid']); + self::assertSame('1', (string)$records[0]['pid']); + self::assertSame('1', (string)$records[0]['uid']); self::assertSame('http://localhost/?id=1&topic_id=1', $records[0]['url']); self::assertSame('Mozilla/5.0 (Macintosh; Intel Mac OS X x.y; rv:42.0) Gecko/20100101 Firefox/42.0', $records[0]['user_agent']); self::assertSame('Macintosh', $records[0]['operating_system']); self::assertSame('sys_category_1', $records[0]['record']); - self::assertSame('1', (string) $records[0]['record_uid']); + self::assertSame('1', (string)$records[0]['record_uid']); self::assertSame('sys_category', $records[0]['record_table_name']); } diff --git a/composer.json b/composer.json index b2cb10c..2ef89cb 100644 --- a/composer.json +++ b/composer.json @@ -40,12 +40,12 @@ }, "require-dev": { "cweagans/composer-patches": "^1.7", + "friendsofphp/php-cs-fixer": "^3.14", "jangregor/phpstan-prophecy": "^1.0", "phpspec/prophecy-phpunit": "^2.0", "phpstan/extension-installer": "^1.1", "phpstan/phpstan": "^1.8.7", "phpunit/phpunit": "^9.0", - "symplify/easy-coding-standard": "^11.1", "typo3/testing-framework": "^7.0" }, "minimum-stability": "dev", diff --git a/ecs.php b/ecs.php deleted file mode 100644 index 893bf31..0000000 --- a/ecs.php +++ /dev/null @@ -1,312 +0,0 @@ -sets([ - SetList::PSR_12, - ]); - - $ecsConfig->paths([ - __DIR__ . '/Classes', - __DIR__ . '/Tests', - __DIR__ . '/ecs.php', - __DIR__ . '/ext_emconf.php', - __DIR__ . '/ext_localconf.php', - __DIR__ . '/rector.php', - ]); - - $ecsConfig->skip([ - CamelCapsMethodNameSniff::class => [ - __DIR__ . '/Classes/Hooks/DataHandler.php', - ], - ]); - - // Alias - $ecsConfig->rule(MbStrFunctionsFixer::class); - $ecsConfig->rule(NoAliasFunctionsFixer::class); - - // ArrayNotation - $ecsConfig->ruleWithConfiguration(ArraySyntaxFixer::class, [ - 'syntax' => 'short', - ]); - $ecsConfig->rule(NoMultilineWhitespaceAroundDoubleArrowFixer::class); - $ecsConfig->rule(NormalizeIndexBraceFixer::class); - $ecsConfig->rule(NoTrailingCommaInSinglelineArrayFixer::class); - $ecsConfig->rule(NoWhitespaceBeforeCommaInArrayFixer::class); - $ecsConfig->rule(TrimArraySpacesFixer::class); - - // Basic - $ecsConfig->rule(NoMultipleStatementsPerLineFixer::class); - $ecsConfig->rule(NonPrintableCharacterFixer::class); - - // Casing - $ecsConfig->rule(NativeFunctionCasingFixer::class); - $ecsConfig->rule(NativeFunctionTypeDeclarationCasingFixer::class); - - // CastNotation - $ecsConfig->rule(CastSpacesFixer::class); - $ecsConfig->rule(ModernizeTypesCastingFixer::class); - $ecsConfig->rule(NoUnsetCastFixer::class); - - // ClassNotation - $ecsConfig->ruleWithConfiguration(ClassAttributesSeparationFixer::class, [ - 'elements' => [ - 'const' => 'one', - 'method' => 'one', - 'property' => 'one', - 'trait_import' => 'one', - ], - ]); - $ecsConfig->rule(NoNullPropertyInitializationFixer::class); - $ecsConfig->rule(SelfAccessorFixer::class); - - $ecsConfig->rule(MultilineCommentOpeningClosingFixer::class); - $ecsConfig->rule(NoEmptyCommentFixer::class); - $ecsConfig->rule(SinglelineCommentSpacingFixer::class); - $ecsConfig->rule(SingleLineCommentStyleFixer::class); - - // ControlStructure - $ecsConfig->rule(NoSuperfluousElseifFixer::class); - $ecsConfig->rule(NoTrailingCommaInListCallFixer::class); - $ecsConfig->rule(NoUnneededControlParenthesesFixer::class); - $ecsConfig->rule(NoUselessElseFixer::class); - $ecsConfig->rule(SimplifiedIfReturnFixer::class); - $ecsConfig->rule(TrailingCommaInMultilineFixer::class); - $ecsConfig->rule(PSR12ControlStructureSpacingSniff::class); - - // FunctionNotation - $ecsConfig->rule(NoTrailingCommaInSinglelineFunctionCallFixer::class); - $ecsConfig->rule(NoUnreachableDefaultArgumentValueFixer::class); - $ecsConfig->rule(NoUselessSprintfFixer::class); - $ecsConfig->rule(NullableTypeDeclarationForDefaultNullValueFixer::class); - $ecsConfig->rule(RegularCallableCallFixer::class); - $ecsConfig->rule(StaticLambdaFixer::class); - - // Import - $ecsConfig->rule(FullyQualifiedStrictTypesFixer::class); - $ecsConfig->rule(GlobalNamespaceImportFixer::class); - $ecsConfig->rule(NoUnneededImportAliasFixer::class); - $ecsConfig->rule(NoUnusedImportsFixer::class); - $ecsConfig->ruleWithConfiguration(OrderedImportsFixer::class, [ - 'sort_algorithm' => 'alpha', - ]); - - // LanguageConstruct - $ecsConfig->rule(CombineConsecutiveIssetsFixer::class); - $ecsConfig->rule(CombineConsecutiveUnsetsFixer::class); - $ecsConfig->rule(SingleSpaceAfterConstructFixer::class); - - // ListNotation - $ecsConfig->rule(ListSyntaxFixer::class); - - // NamespaceNotation - $ecsConfig->rule(SingleBlankLineBeforeNamespaceFixer::class); - - // Naming - $ecsConfig->rule(CamelCapsMethodNameSniff::class); - $ecsConfig->rule(NoHomoglyphNamesFixer::class); - $ecsConfig->rule(UpperCaseConstantNameSniff::class); - - // Operator - $ecsConfig->ruleWithConfiguration(IncrementStyleFixer::class, [ - 'style' => 'post', - ]); - $ecsConfig->ruleWithConfiguration(NewWithBracesFixer::class, [ - 'anonymous_class' => false, - 'named_class' => true, - ]); - $ecsConfig->rule(ObjectOperatorWithoutWhitespaceFixer::class); - $ecsConfig->ruleWithConfiguration(OperatorLinebreakFixer::class, [ - 'position' => 'beginning', - ]); - $ecsConfig->rule(StandardizeIncrementFixer::class); - $ecsConfig->rule(TernaryToElvisOperatorFixer::class); - $ecsConfig->rule(TernaryToNullCoalescingFixer::class); - $ecsConfig->rule(UnaryOperatorSpacesFixer::class); - - // Phpdoc - $ecsConfig->rule(NoBlankLinesAfterPhpdocFixer::class); - $ecsConfig->rule(NoEmptyPhpdocFixer::class); - $ecsConfig->ruleWithConfiguration(NoSuperfluousPhpdocTagsFixer::class, [ - 'allow_mixed' => true, - ]); - $ecsConfig->ruleWithConfiguration(PhpdocAlignFixer::class, [ - 'align' => 'left', - ]); - $ecsConfig->rule(PhpdocIndentFixer::class); - $ecsConfig->rule(PhpdocLineSpanFixer::class); - $ecsConfig->rule(PhpdocNoAccessFixer::class); - $ecsConfig->ruleWithConfiguration(PhpdocOrderByValueFixer::class, [ - 'annotations' => [ - 'covers', - 'throws', - ], - ]); - $ecsConfig->rule(PhpdocOrderFixer::class); - $ecsConfig->rule(PhpdocScalarFixer::class); - $ecsConfig->rule(PhpdocSeparationFixer::class); - $ecsConfig->rule(PhpdocToCommentFixer::class); - $ecsConfig->rule(PhpdocTrimConsecutiveBlankLineSeparationFixer::class); - $ecsConfig->rule(PhpdocTrimFixer::class); - $ecsConfig->rule(PhpdocTypesFixer::class); - $ecsConfig->rule(PhpdocTypesOrderFixer::class); - $ecsConfig->rule(PhpdocVarAnnotationCorrectOrderFixer::class); - $ecsConfig->rule(PhpdocVarWithoutNameFixer::class); - - // PhpUnit - $ecsConfig->rule(PhpUnitConstructFixer::class); - $ecsConfig->rule(PhpUnitDedicateAssertFixer::class); - $ecsConfig->rule(PhpUnitDedicateAssertInternalTypeFixer::class); - $ecsConfig->rule(PhpUnitFqcnAnnotationFixer::class); - $ecsConfig->rule(PhpUnitMethodCasingFixer::class); - $ecsConfig->rule(PhpUnitMockFixer::class); - $ecsConfig->rule(PhpUnitMockShortWillReturnFixer::class); - $ecsConfig->rule(PhpUnitNamespacedFixer::class); - $ecsConfig->rule(PhpUnitNoExpectationAnnotationFixer::class); - $ecsConfig->rule(PhpUnitSetUpTearDownVisibilityFixer::class); - $ecsConfig->rule(PhpUnitStrictFixer::class); - $ecsConfig->ruleWithConfiguration(PhpUnitTestAnnotationFixer::class, [ - 'style' => 'annotation', - ]); - $ecsConfig->ruleWithConfiguration(PhpUnitTestCaseStaticMethodCallsFixer::class, [ - 'call_type' => 'self', - ]); - $ecsConfig->rule(PhpUnitTestClassRequiresCoversFixer::class); - - // ReturnNotation - $ecsConfig->rule(NoUselessReturnFixer::class); - - // Semicolon - $ecsConfig->ruleWithConfiguration(MultilineWhitespaceBeforeSemicolonsFixer::class, [ - 'strategy' => 'new_line_for_chained_calls', - ]); - $ecsConfig->rule(NoEmptyStatementFixer::class); - $ecsConfig->rule(NoSinglelineWhitespaceBeforeSemicolonsFixer::class); - $ecsConfig->rule(SemicolonAfterInstructionFixer::class); - - // StringNotation - $ecsConfig->rule(NoTrailingWhitespaceInStringFixer::class); - $ecsConfig->rule(SingleQuoteFixer::class); - $ecsConfig->rule(StringLengthToEmptyFixer::class); - - // Whitespace - $ecsConfig->rule(ArrayIndentationFixer::class); - $ecsConfig->rule(ArrayIndentSniff::class); - $ecsConfig->rule(CompactNullableTypehintFixer::class); - $ecsConfig->rule(MethodChainingIndentationFixer::class); - $ecsConfig->rule(NoExtraBlankLinesFixer::class); - $ecsConfig->rule(NoSpacesAroundOffsetFixer::class); - $ecsConfig->ruleWithConfiguration(OperatorSpacingSniff::class, [ - 'ignoreSpacingBeforeAssignments' => false, - 'ignoreNewlines' => true, - ]); - $ecsConfig->rule(StatementIndentationFixer::class); - $ecsConfig->rule(TypesSpacesFixer::class); -}; diff --git a/phpcs.xml.dist b/phpcs.xml.dist deleted file mode 100644 index c552af7..0000000 --- a/phpcs.xml.dist +++ /dev/null @@ -1,22 +0,0 @@ - - - This project coding standard - - Classes/ - Tests/ - - - - - - - - - - - /Tests/* - - - /Classes/Hooks/DataHandler.php - - diff --git a/shell.nix b/shell.nix index fc6f496..33f1b27 100644 --- a/shell.nix +++ b/shell.nix @@ -55,7 +55,7 @@ let php ]; text = '' - ./vendor/bin/ecs check + ./vendor/bin/php-cs-fixer fix --dry-run --diff ''; }; projectCglFix = pkgs.writeShellApplication { @@ -64,7 +64,7 @@ let php ]; text = '' - ./vendor/bin/ecs check --fix + ./vendor/bin/php-cs-fixer fix --diff ''; };