diff --git a/.forgejo/workflows/push.yml b/.forgejo/workflows/push.yml deleted file mode 100644 index 0f5e4de..0000000 --- a/.forgejo/workflows/push.yml +++ /dev/null @@ -1,34 +0,0 @@ -on: [push] -jobs: - ls: - runs-on: docker - container: - image: git.php.fail/lubiana/container/php:ci - steps: - - name: Manually checkout - env: - REPO: '${{ github.repository }}' - TOKEN: '${{ secrets.GITHUB_TOKEN }}' - GIT_SERVER: 'git.php.fail' - run: | - git clone --branch $GITHUB_REF_NAME https://${TOKEN}@${GIT_SERVER}/${REPO}.git . - git fetch - git checkout ${{ github.head_ref }} - - name: composer install - env: - COMPOSER_CACHE_DIR: /opt/hostedtoolcache/.composer/cache/files - run: | - mkdir -p ${{ env.COMPOSER_CACHE_DIR }} - composer install - - run: composer lint - - name: GIT commit and push all changed files - env: - CI_COMMIT_MESSAGE: Continuous Integration Fixes - CI_COMMIT_AUTHOR: Continuous Integration - run: | - if [[ -n "$(git status -s)" ]]; then - git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}" - git config --global user.email "gitbot@users.noreply.php.fail" - git commit -am "${{ env.CI_COMMIT_MESSAGE }}" - git push - fi \ No newline at end of file diff --git a/composer.json b/composer.json index d384621..a2399fd 100644 --- a/composer.json +++ b/composer.json @@ -8,10 +8,9 @@ } }, "require": { - "php": "^8.3", - "slevomat/coding-standard": "^8.15", - "symplify/easy-coding-standard": "^12.3.5", - "rector/rector": "^1.0.5" + "slevomat/coding-standard": "^8.14.1", + "symplify/easy-coding-standard": "^12.1.8", + "rector/rector": "^0.19.2" }, "config": { "allow-plugins": { @@ -19,7 +18,7 @@ } }, "scripts": { - "lint": [ + "fix": [ "rector", "ecs --fix", "ecs --fix" diff --git a/composer.lock b/composer.lock index a57df23..03cb2b0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6eb7806e6594ecc073d158d2f9b483f0", + "content-hash": "a2ee536230b7262151afd736f0600119", "packages": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", @@ -86,16 +86,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.28.0", + "version": "1.25.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb" + "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", - "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/bd84b629c8de41aa2ae82c067c955e06f1b00240", + "reference": "bd84b629c8de41aa2ae82c067c955e06f1b00240", "shasum": "" }, "require": { @@ -127,22 +127,22 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.28.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.25.0" }, - "time": "2024-04-03T18:51:33+00:00" + "time": "2024-01-04T17:06:16+00:00" }, { "name": "phpstan/phpstan", - "version": "1.10.67", + "version": "1.10.57", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" + "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", - "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/1627b1d03446904aaa77593f370c5201d2ecc34e", + "reference": "1627b1d03446904aaa77593f370c5201d2ecc34e", "shasum": "" }, "require": { @@ -185,27 +185,31 @@ { "url": "https://github.com/phpstan", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" } ], - "time": "2024-04-16T07:22:02+00:00" + "time": "2024-01-24T11:51:34+00:00" }, { "name": "rector/rector", - "version": "1.0.5", + "version": "0.19.2", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "73eb63e4f9011dba6b7c66c3262543014e352f34" + "reference": "bc96a99895bf47c6bfe70ea1b799f0081ed5a903" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/73eb63e4f9011dba6b7c66c3262543014e352f34", - "reference": "73eb63e4f9011dba6b7c66c3262543014e352f34", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/bc96a99895bf47c6bfe70ea1b799f0081ed5a903", + "reference": "bc96a99895bf47c6bfe70ea1b799f0081ed5a903", "shasum": "" }, "require": { "php": "^7.2|^8.0", - "phpstan/phpstan": "^1.10.57" + "phpstan/phpstan": "^1.10.56" }, "conflict": { "rector/rector-doctrine": "*", @@ -213,9 +217,6 @@ "rector/rector-phpunit": "*", "rector/rector-symfony": "*" }, - "suggest": { - "ext-dom": "To manipulate phpunit.xml via the custom-rule command" - }, "bin": [ "bin/rector" ], @@ -238,7 +239,7 @@ ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/1.0.5" + "source": "https://github.com/rectorphp/rector/tree/0.19.2" }, "funding": [ { @@ -246,36 +247,36 @@ "type": "github" } ], - "time": "2024-05-10T05:31:15+00:00" + "time": "2024-01-19T10:58:30+00:00" }, { "name": "slevomat/coding-standard", - "version": "8.15.0", + "version": "8.14.1", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "7d1d957421618a3803b593ec31ace470177d7817" + "reference": "fea1fd6f137cc84f9cba0ae30d549615dbc6a926" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7d1d957421618a3803b593ec31ace470177d7817", - "reference": "7d1d957421618a3803b593ec31ace470177d7817", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/fea1fd6f137cc84f9cba0ae30d549615dbc6a926", + "reference": "fea1fd6f137cc84f9cba0ae30d549615dbc6a926", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "php": "^7.2 || ^8.0", "phpstan/phpdoc-parser": "^1.23.1", - "squizlabs/php_codesniffer": "^3.9.0" + "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.10.60", + "phpstan/phpstan": "1.10.37", "phpstan/phpstan-deprecation-rules": "1.1.4", - "phpstan/phpstan-phpunit": "1.3.16", - "phpstan/phpstan-strict-rules": "1.5.2", - "phpunit/phpunit": "8.5.21|9.6.8|10.5.11" + "phpstan/phpstan-phpunit": "1.3.14", + "phpstan/phpstan-strict-rules": "1.5.1", + "phpunit/phpunit": "8.5.21|9.6.8|10.3.5" }, "type": "phpcodesniffer-standard", "extra": { @@ -299,7 +300,7 @@ ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/8.15.0" + "source": "https://github.com/slevomat/coding-standard/tree/8.14.1" }, "funding": [ { @@ -311,20 +312,20 @@ "type": "tidelift" } ], - "time": "2024-03-09T15:20:58+00:00" + "time": "2023-10-08T07:28:08+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.2", + "version": "3.8.1", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480" + "reference": "14f5fff1e64118595db5408e946f3a22c75807f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/aac1f6f347a5c5ac6bc98ad395007df00990f480", - "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/14f5fff1e64118595db5408e946f3a22c75807f7", + "reference": "14f5fff1e64118595db5408e946f3a22c75807f7", "shasum": "" }, "require": { @@ -391,20 +392,20 @@ "type": "open_collective" } ], - "time": "2024-04-23T20:25:34+00:00" + "time": "2024-01-11T20:47:48+00:00" }, { "name": "symplify/easy-coding-standard", - "version": "12.3.5", + "version": "12.1.8", "source": { "type": "git", "url": "https://github.com/easy-coding-standard/easy-coding-standard.git", - "reference": "0d7c2cfee3debdf11c12135e90d69d1d9f4eef03" + "reference": "7962c810a8eebc4174a38d7dff673f1999e61595" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/easy-coding-standard/easy-coding-standard/zipball/0d7c2cfee3debdf11c12135e90d69d1d9f4eef03", - "reference": "0d7c2cfee3debdf11c12135e90d69d1d9f4eef03", + "url": "https://api.github.com/repos/easy-coding-standard/easy-coding-standard/zipball/7962c810a8eebc4174a38d7dff673f1999e61595", + "reference": "7962c810a8eebc4174a38d7dff673f1999e61595", "shasum": "" }, "require": { @@ -415,9 +416,6 @@ "phpcsstandards/php_codesniffer": "<3.8", "symplify/coding-standard": "<12.1" }, - "suggest": { - "ext-dom": "Needed to support checkstyle output format in class CheckstyleOutputFormatter" - }, "bin": [ "bin/ecs" ], @@ -440,7 +438,7 @@ ], "support": { "issues": "https://github.com/easy-coding-standard/easy-coding-standard/issues", - "source": "https://github.com/easy-coding-standard/easy-coding-standard/tree/12.3.5" + "source": "https://github.com/easy-coding-standard/easy-coding-standard/tree/12.1.8" }, "funding": [ { @@ -452,7 +450,7 @@ "type": "github" } ], - "time": "2024-08-08T08:43:50+00:00" + "time": "2024-01-16T22:56:06+00:00" } ], "packages-dev": [], @@ -461,9 +459,7 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": { - "php": "^8.3" - }, + "platform": [], "platform-dev": [], "plugin-api-version": "2.6.0" } diff --git a/config/ecs.php b/config/ecs.php index a964b49..f05925b 100644 --- a/config/ecs.php +++ b/config/ecs.php @@ -1,10 +1,7 @@ withPreparedSets( - symplify: true, arrays: true, + cleanCode: true, comments: true, - docblocks: true, - spaces: true, - namespaces: true, controlStructures: true, + docblocks: true, + namespaces: true, + spaces: true, strict: true, - cleanCode: true + symplify: true ) ->withPhpCsFixerSets( perCS: true, perCSRisky: true, - php80MigrationRisky: true, php83Migration: true, + php80MigrationRisky: true, ) ->withRules([ AlphabeticallySortedUsesSniff::class, @@ -78,17 +75,6 @@ return ECSConfig::configure() ] ) ->withConfiguredRule( - ClassAttributesSeparationFixer::class, - [ - 'elements' => [ - 'const' => 'none', - 'method' => 'one', - 'property' => 'none', - 'trait_import' => 'none', - 'case' => 'none', - ], - ], - )->withConfiguredRule( DeclareStrictTypesSniff::class, [ 'declareOnFirstLine' => true, @@ -103,6 +89,12 @@ return ECSConfig::configure() 'withSpaces' => 'no', ] ) + ->withConfiguredRule( + LineLengthFixer::class, + [ + LineLengthFixer::INLINE_SHORT_LINES => false, + ] + ) ->withConfiguredRule( NoExtraBlankLinesFixer::class, [ @@ -116,7 +108,4 @@ return ECSConfig::configure() BlankLineAfterOpeningTagFixer::class, OrderedImportsFixer::class, FunctionToConstantFixer::class, - NewWithParenthesesFixer::class, - NewWithBracesFixer::class, - LineLengthFixer::class, ]); diff --git a/config/rector.php b/config/rector.php index c6daf13..4687fc7 100644 --- a/config/rector.php +++ b/config/rector.php @@ -16,6 +16,7 @@ use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector; use Rector\Config\RectorConfig; use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; +use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector; use Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector; use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector; use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; @@ -23,6 +24,7 @@ use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector; use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector; use Rector\Php80\Rector\ClassConstFetch\ClassOnThisVariableObjectRector; +use Rector\Set\ValueObject\LevelSetList; use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector; @@ -31,6 +33,7 @@ use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector; use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnDirectArrayRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector; +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictBoolReturnExprRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictConstantReturnRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector; @@ -40,16 +43,9 @@ use Rector\TypeDeclaration\Rector\FunctionLike\AddParamTypeSplFixedArrayRector; use Rector\TypeDeclaration\Rector\FunctionLike\AddReturnTypeDeclarationFromYieldsRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector; -return RectorConfig::configure() - ->withPhpSets(php83: true) - ->withPreparedSets( - deadCode: true, - codeQuality: true, - typeDeclarations: true, - earlyReturn: true, - strictBooleans: true, - ) - ->withRules([ +return static function (RectorConfig $c): void { + $c->sets([LevelSetList::UP_TO_PHP_82]); + $c->rules([ AddArrowFunctionReturnTypeRector::class, AddMethodCallBasedStrictParamTypeRector::class, AddParamTypeFromPropertyTypeRector::class, @@ -57,6 +53,7 @@ return RectorConfig::configure() AddReturnTypeDeclarationBasedOnParentClassMethodRector::class, AddReturnTypeDeclarationFromYieldsRector::class, BooleanNotIdenticalToNotIdenticalRector::class, + ChangeAndIfToEarlyReturnRector::class, ChangeNestedForeachIfsToEarlyContinueRector::class, ChangeNestedIfsToEarlyReturnRector::class, ChangeOrIfContinueToMultiContinueRector::class, @@ -75,6 +72,7 @@ return RectorConfig::configure() ReturnEarlyIfVariableRector::class, ReturnTypeFromReturnDirectArrayRector::class, ReturnTypeFromReturnNewRector::class, + ReturnTypeFromStrictBoolReturnExprRector::class, ReturnTypeFromStrictConstantReturnRector::class, ReturnTypeFromStrictNativeCallRector::class, ReturnTypeFromStrictNewArrayRector::class, @@ -88,5 +86,5 @@ return RectorConfig::configure() ThrowWithPreviousExceptionRector::class, TypedPropertyFromStrictConstructorRector::class, RemoveAlwaysElseRector::class, - ]) -; + ]); +}; diff --git a/rector.php b/rector.php index 87b24f1..80408b1 100644 --- a/rector.php +++ b/rector.php @@ -3,11 +3,13 @@ use Lubiana\CodeQuality\LubiSetList; use Rector\Config\RectorConfig; -return RectorConfig::configure() - ->withPaths([ +return static function (RectorConfig $c): void { + $c->paths([ __DIR__ . '/src', __DIR__ . '/config', - ]) - ->withSets([LubiSetList::RECTOR]) - ->withRootFiles() -; + __DIR__ . '/rector.php', + __DIR__ . '/ecs.php', + ]); + + $c->sets([LubiSetList::RECTOR]); +}; diff --git a/src/LubiSetList.php b/src/LubiSetList.php index 092d20f..d78838d 100644 --- a/src/LubiSetList.php +++ b/src/LubiSetList.php @@ -4,6 +4,7 @@ namespace Lubiana\CodeQuality; final class LubiSetList { - public const string RECTOR = __DIR__ . '/../config/rector.php'; - public const string ECS = __DIR__ . '/../config/ecs.php'; + public const RECTOR = __DIR__ . '/../config/rector.php'; + + public const ECS = __DIR__ . '/../config/ecs.php'; }