diff --git a/.forgejo/workflows/push.yml b/.forgejo/workflows/push.yml new file mode 100644 index 0000000..0f5e4de --- /dev/null +++ b/.forgejo/workflows/push.yml @@ -0,0 +1,34 @@ +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/README.md b/README.md new file mode 100644 index 0000000..14f028e --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# My very opiniated Configurations for Rector and ECS + +## Installation + +```bash +composer require --dev lubiana/code-quality +``` + +Add my Setlist to ECS in `ecs.php`: + +```php +return static function (\Symplify\EasyCodingStandard\Config\ECSConfig $config): void { + $config->sets([ + \Lubiana\CodeQuality\LubiSetList::ECS, + ]); +}; +``` + +And for rector.php: + +```php +return static function (\Rector\Config\RectorConfig $config): void { + $config->sets([ + \Lubiana\CodeQuality\LubiSetList::RECTOR, + ]); +}; +``` + + + diff --git a/composer.json b/composer.json index f6b6067..d384621 100644 --- a/composer.json +++ b/composer.json @@ -1,18 +1,28 @@ { "name": "lubiana/code-quality", + "license": ["MIT"], + "keywords": ["dev"], "autoload": { "psr-4": { "Lubiana\\CodeQuality\\": "src/" } }, "require": { - "slevomat/coding-standard": "^8.5.2", - "symplify/easy-coding-standard": "^11.1.10", - "rector/rector": "^0.14.5" + "php": "^8.3", + "slevomat/coding-standard": "^8.15", + "symplify/easy-coding-standard": "^12.3.5", + "rector/rector": "^1.0.5" }, "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true } + }, + "scripts": { + "lint": [ + "rector", + "ecs --fix", + "ecs --fix" + ] } } diff --git a/composer.lock b/composer.lock index 81e07f8..a57df23 100644 --- a/composer.lock +++ b/composer.lock @@ -4,39 +4,42 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fa3b794832ff085199627c2c7f8e2453", + "content-hash": "6eb7806e6594ecc073d158d2f9b483f0", "packages": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.7.2", + "version": "v1.0.0", "source": { "type": "git", - "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "4be43904336affa5c2f70744a348312336afd0da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", - "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/4be43904336affa5c2f70744a348312336afd0da", + "reference": "4be43904336affa5c2f70744a348312336afd0da", "shasum": "" }, "require": { "composer-plugin-api": "^1.0 || ^2.0", - "php": ">=5.3", + "php": ">=5.4", "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" }, "require-dev": { "composer/composer": "*", + "ext-json": "*", + "ext-zip": "*", "php-parallel-lint/php-parallel-lint": "^1.3.1", - "phpcompatibility/php-compatibility": "^9.0" + "phpcompatibility/php-compatibility": "^9.0", + "yoast/phpunit-polyfills": "^1.0" }, "type": "composer-plugin", "extra": { - "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" }, "autoload": { "psr-4": { - "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -52,7 +55,7 @@ }, { "name": "Contributors", - "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" } ], "description": "PHP_CodeSniffer Standards Composer Installer Plugin", @@ -76,29 +79,31 @@ "tests" ], "support": { - "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", - "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "source": "https://github.com/PHPCSStandards/composer-installer" }, - "time": "2022-02-04T12:51:07+00:00" + "time": "2023-01-05T11:28:13+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "1.8.0", + "version": "1.28.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "8dd908dd6156e974b9a0f8bb4cd5ad0707830f04" + "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/8dd908dd6156e974b9a0f8bb4cd5ad0707830f04", - "reference": "8dd908dd6156e974b9a0f8bb4cd5ad0707830f04", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", + "reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, "require-dev": { + "doctrine/annotations": "^2.0", + "nikic/php-parser": "^4.15", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", "phpstan/phpstan": "^1.5", @@ -122,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.8.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.28.0" }, - "time": "2022-09-04T18:59:06+00:00" + "time": "2024-04-03T18:51:33+00:00" }, { "name": "phpstan/phpstan", - "version": "1.8.8", + "version": "1.10.67", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "08310ce271984587e2a4cda94e1ac66510a6ea07" + "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/08310ce271984587e2a4cda94e1ac66510a6ea07", - "reference": "08310ce271984587e2a4cda94e1ac66510a6ea07", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", + "reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", "shasum": "" }, "require": { @@ -166,8 +171,11 @@ "static analysis" ], "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.8.8" + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" }, "funding": [ { @@ -177,50 +185,41 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2022-10-06T12:51:57+00:00" + "time": "2024-04-16T07:22:02+00:00" }, { "name": "rector/rector", - "version": "0.14.5", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "f7fd87b2435835f481e6a94ee28e09af412bd3cc" + "reference": "73eb63e4f9011dba6b7c66c3262543014e352f34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/f7fd87b2435835f481e6a94ee28e09af412bd3cc", - "reference": "f7fd87b2435835f481e6a94ee28e09af412bd3cc", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/73eb63e4f9011dba6b7c66c3262543014e352f34", + "reference": "73eb63e4f9011dba6b7c66c3262543014e352f34", "shasum": "" }, "require": { "php": "^7.2|^8.0", - "phpstan/phpstan": "^1.8.6" + "phpstan/phpstan": "^1.10.57" }, "conflict": { - "rector/rector-cakephp": "*", "rector/rector-doctrine": "*", - "rector/rector-laravel": "*", - "rector/rector-php-parser": "*", - "rector/rector-phpoffice": "*", + "rector/rector-downgrade-php": "*", "rector/rector-phpunit": "*", "rector/rector-symfony": "*" }, + "suggest": { + "ext-dom": "To manipulate phpunit.xml via the custom-rule command" + }, "bin": [ "bin/rector" ], "type": "library", - "extra": { - "branch-alias": { - "dev-main": "0.14-dev" - } - }, "autoload": { "files": [ "bootstrap.php" @@ -231,9 +230,15 @@ "MIT" ], "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" + ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/0.14.5" + "source": "https://github.com/rectorphp/rector/tree/1.0.5" }, "funding": [ { @@ -241,36 +246,36 @@ "type": "github" } ], - "time": "2022-09-29T11:05:42+00:00" + "time": "2024-05-10T05:31:15+00:00" }, { "name": "slevomat/coding-standard", - "version": "8.5.2", + "version": "8.15.0", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "f32937dc41b587f3500efed1dbca2f82aa519373" + "reference": "7d1d957421618a3803b593ec31ace470177d7817" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/f32937dc41b587f3500efed1dbca2f82aa519373", - "reference": "f32937dc41b587f3500efed1dbca2f82aa519373", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7d1d957421618a3803b593ec31ace470177d7817", + "reference": "7d1d957421618a3803b593ec31ace470177d7817", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": ">=1.7.0 <1.9.0", - "squizlabs/php_codesniffer": "^3.7.1" + "phpstan/phpdoc-parser": "^1.23.1", + "squizlabs/php_codesniffer": "^3.9.0" }, "require-dev": { "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.4.10|1.8.6", - "phpstan/phpstan-deprecation-rules": "1.0.0", - "phpstan/phpstan-phpunit": "1.0.0|1.1.1", - "phpstan/phpstan-strict-rules": "1.4.4", - "phpunit/phpunit": "7.5.20|8.5.21|9.5.25" + "phpstan/phpstan": "1.10.60", + "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" }, "type": "phpcodesniffer-standard", "extra": { @@ -280,7 +285,7 @@ }, "autoload": { "psr-4": { - "SlevomatCodingStandard\\": "SlevomatCodingStandard" + "SlevomatCodingStandard\\": "SlevomatCodingStandard/" } }, "notification-url": "https://packagist.org/downloads/", @@ -288,9 +293,13 @@ "MIT" ], "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "keywords": [ + "dev", + "phpcs" + ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/8.5.2" + "source": "https://github.com/slevomat/coding-standard/tree/8.15.0" }, "funding": [ { @@ -302,20 +311,20 @@ "type": "tidelift" } ], - "time": "2022-09-27T16:45:37+00:00" + "time": "2024-03-09T15:20:58+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.7.1", + "version": "3.9.2", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", - "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/aac1f6f347a5c5ac6bc98ad395007df00990f480", + "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480", "shasum": "" }, "require": { @@ -325,11 +334,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" }, "bin": [ - "bin/phpcs", - "bin/phpcbf" + "bin/phpcbf", + "bin/phpcs" ], "type": "library", "extra": { @@ -344,52 +353,75 @@ "authors": [ { "name": "Greg Sherwood", - "role": "lead" + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "keywords": [ "phpcs", - "standards" + "standards", + "static analysis" ], "support": { - "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", - "source": "https://github.com/squizlabs/PHP_CodeSniffer", - "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" }, - "time": "2022-06-18T07:21:10+00:00" + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], + "time": "2024-04-23T20:25:34+00:00" }, { "name": "symplify/easy-coding-standard", - "version": "11.1.10", + "version": "12.3.5", "source": { "type": "git", - "url": "https://github.com/symplify/easy-coding-standard.git", - "reference": "dc1c9c50059de9b0f51029a9446537f80bbf0c4e" + "url": "https://github.com/easy-coding-standard/easy-coding-standard.git", + "reference": "0d7c2cfee3debdf11c12135e90d69d1d9f4eef03" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symplify/easy-coding-standard/zipball/dc1c9c50059de9b0f51029a9446537f80bbf0c4e", - "reference": "dc1c9c50059de9b0f51029a9446537f80bbf0c4e", + "url": "https://api.github.com/repos/easy-coding-standard/easy-coding-standard/zipball/0d7c2cfee3debdf11c12135e90d69d1d9f4eef03", + "reference": "0d7c2cfee3debdf11c12135e90d69d1d9f4eef03", "shasum": "" }, "require": { "php": ">=7.2" }, "conflict": { - "friendsofphp/php-cs-fixer": "<3.0", - "squizlabs/php_codesniffer": "<3.6" + "friendsofphp/php-cs-fixer": "<3.46", + "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" ], "type": "library", - "extra": { - "branch-alias": { - "dev-main": "10.3-dev" - } - }, "autoload": { "files": [ "bootstrap.php" @@ -399,9 +431,16 @@ "license": [ "MIT" ], - "description": "Prefixed scoped version of ECS package", + "description": "Use Coding Standard with 0-knowledge of PHP-CS-Fixer and PHP_CodeSniffer", + "keywords": [ + "Code style", + "automation", + "fixer", + "static analysis" + ], "support": { - "source": "https://github.com/symplify/easy-coding-standard/tree/11.1.10" + "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" }, "funding": [ { @@ -413,7 +452,7 @@ "type": "github" } ], - "time": "2022-09-29T10:40:41+00:00" + "time": "2024-08-08T08:43:50+00:00" } ], "packages-dev": [], @@ -422,7 +461,9 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": "^8.3" + }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/config/ecs.php b/config/ecs.php index 76f1333..a964b49 100644 --- a/config/ecs.php +++ b/config/ecs.php @@ -1,11 +1,15 @@ skip([ - BlankLineAfterOpeningTagFixer::class, - NewWithBracesFixer::class, - OrderedImportsFixer::class, - ]); - - $c->sets([ - SetList::ARRAY, - SetList::CLEAN_CODE, - SetList::COMMENTS, - SetList::COMMON, - SetList::CONTROL_STRUCTURES, - SetList::DOCBLOCK, - SetList::NAMESPACES, - SetList::PSR_12, - SetList::SPACES, - SetList::STRICT, - SetList::SYMPLIFY, - ]); - - // force visibility declaration on class constants - $c->ruleWithConfiguration(ClassConstantVisibilitySniff::class, [ - 'fixable' => true, - ]); - - // sort all use statements - $c->rules([ +return ECSConfig::configure() + ->withPreparedSets( + symplify: true, + arrays: true, + comments: true, + docblocks: true, + spaces: true, + namespaces: true, + controlStructures: true, + strict: true, + cleanCode: true + ) + ->withPhpCsFixerSets( + perCS: true, + perCSRisky: true, + php80MigrationRisky: true, + php83Migration: true, + ) + ->withRules([ AlphabeticallySortedUsesSniff::class, DisallowGroupUseSniff::class, MultipleUsesPerLineSniff::class, NamespaceSpacingSniff::class, - ]); - - // import all namespaces, and event php core functions and classes - $c->ruleWithConfiguration( + OperatorLinebreakFixer::class, + NoWhitespaceInBlankLineFixer::class, + NewWithoutParenthesesSniff::class, + ]) + ->withConfiguredRule(ClassConstantVisibilitySniff::class, [ + 'fixable' => true, + ]) + ->withConfiguredRule( ReferenceUsedNamesOnlySniff::class, [ 'allowFallbackGlobalConstants' => false, @@ -68,46 +66,57 @@ return static function (ECSConfig $c): void { 'allowFullyQualifiedNameForCollidingFunctions' => true, 'searchAnnotations' => true, ] - ); + ) // define newlines between use statements - $c->ruleWithConfiguration(UseSpacingSniff::class, [ - 'linesCountAfterLastUse' => 1, - 'linesCountBeforeFirstUse' => 1, - 'linesCountBetweenUseTypes' => 1, - ]); - - // strict types declaration should be on same line as opening tag - $c->ruleWithConfiguration( + ->withConfiguredRule( + UseSpacingSniff::class, + [ + 'linesCountAfterLastUse' => 1, + 'linesCountBeforeFirstUse' => 1, + 'linesCountBetweenUseTypes' => 1, + ] + ) + ->withConfiguredRule( + ClassAttributesSeparationFixer::class, + [ + 'elements' => [ + 'const' => 'none', + 'method' => 'one', + 'property' => 'none', + 'trait_import' => 'none', + 'case' => 'none', + ], + ], + )->withConfiguredRule( DeclareStrictTypesSniff::class, [ 'declareOnFirstLine' => true, 'spacesCountAroundEqualsSign' => 0, ] - ); - - // disallow ?Foo typehint in favor of Foo|null - $c->ruleWithConfiguration(UnionTypeHintFormatSniff::class, [ - 'nullPosition' => 'last', - 'shortNullable' => 'no', - 'withSpaces' => 'no', - ]); - - // Remove useless parentheses in new statements - $c->rule(BracesFixer::class); - $c->rule(NewWithoutParenthesesSniff::class); - - // do not inline short multilinestatements - $c->ruleWithConfiguration(LineLengthFixer::class, [ - LineLengthFixer::INLINE_SHORT_LINES => false, - ]); - - $c->ruleWithConfiguration( + ) + ->withConfiguredRule( + UnionTypeHintFormatSniff::class, + [ + 'nullPosition' => 'last', + 'shortNullable' => 'no', + 'withSpaces' => 'no', + ] + ) + ->withConfiguredRule( NoExtraBlankLinesFixer::class, [ 'tokens' => ['square_brace_block', 'return', 'extra'], ] - ); - - $c->rule(NoWhitespaceInBlankLineFixer::class); -}; + ) + ->withConfiguredRule(AttributeAndTargetSpacingSniff::class, [ + 'linesCount' => 0, + ]) + ->withSkip([ + BlankLineAfterOpeningTagFixer::class, + OrderedImportsFixer::class, + FunctionToConstantFixer::class, + NewWithParenthesesFixer::class, + NewWithBracesFixer::class, + LineLengthFixer::class, + ]); diff --git a/config/rector.php b/config/rector.php index f49f121..c6daf13 100644 --- a/config/rector.php +++ b/config/rector.php @@ -4,6 +4,7 @@ use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector; use Rector\CodeQuality\Rector\BooleanNot\ReplaceMultipleBooleanNotRector; use Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector; use Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector; +use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector; use Rector\CodeQuality\Rector\FuncCall\InlineIsAInstanceOfRector; use Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector; use Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector; @@ -13,78 +14,79 @@ use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector; use Rector\CodingStyle\Rector\Closure\StaticClosureRector; use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector; -use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector; 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_\ChangeOrIfReturnToEarlyReturnRector; +use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; -use Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector; use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector; use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector; -use Rector\Set\ValueObject\LevelSetList; +use Rector\Php80\Rector\ClassConstFetch\ClassOnThisVariableObjectRector; use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector; -use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector; -use Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector; +use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationBasedOnParentClassMethodRector; 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; +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector; -use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector; -use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector; -use Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector; +use Rector\TypeDeclaration\Rector\FunctionLike\AddParamTypeSplFixedArrayRector; +use Rector\TypeDeclaration\Rector\FunctionLike\AddReturnTypeDeclarationFromYieldsRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector; -use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector; -return static function (RectorConfig $c): void { - $c->sets([LevelSetList::UP_TO_PHP_81]); - $c->rules([ - AddArrayParamDocTypeRector::class, - AddArrayReturnDocTypeRector::class, +return RectorConfig::configure() + ->withPhpSets(php83: true) + ->withPreparedSets( + deadCode: true, + codeQuality: true, + typeDeclarations: true, + earlyReturn: true, + strictBooleans: true, + ) + ->withRules([ AddArrowFunctionReturnTypeRector::class, - AddClosureReturnTypeRector::class, AddMethodCallBasedStrictParamTypeRector::class, + AddParamTypeFromPropertyTypeRector::class, + AddParamTypeSplFixedArrayRector::class, AddReturnTypeDeclarationBasedOnParentClassMethodRector::class, + AddReturnTypeDeclarationFromYieldsRector::class, BooleanNotIdenticalToNotIdenticalRector::class, - ChangeAndIfToEarlyReturnRector::class, ChangeNestedForeachIfsToEarlyContinueRector::class, ChangeNestedIfsToEarlyReturnRector::class, ChangeOrIfContinueToMultiContinueRector::class, - ChangeOrIfReturnToEarlyReturnRector::class, + ClassOnThisVariableObjectRector::class, CountArrayToEmptyArrayComparisonRector::class, ExplicitBoolCompareRector::class, InlineArrayReturnAssignRector::class, InlineIsAInstanceOfRector::class, - NewlineAfterStatementRector::class, NewlineBeforeNewAssignSetRector::class, NullableCompareToNullRector::class, ParamTypeByMethodCallTypeRector::class, ParamTypeByParentCallTypeRector::class, - ParamTypeFromStrictTypedPropertyRector::class, PreparedValueToEarlyReturnRector::class, ReplaceMultipleBooleanNotRector::class, - ReturnBinaryAndToEarlyReturnRector::class, ReturnBinaryOrToEarlyReturnRector::class, ReturnEarlyIfVariableRector::class, - ReturnTypeDeclarationRector::class, + ReturnTypeFromReturnDirectArrayRector::class, ReturnTypeFromReturnNewRector::class, - ReturnTypeFromStrictBoolReturnExprRector::class, + ReturnTypeFromStrictConstantReturnRector::class, ReturnTypeFromStrictNativeCallRector::class, ReturnTypeFromStrictNewArrayRector::class, + ReturnTypeFromStrictTypedCallRector::class, ReturnTypeFromStrictTypedPropertyRector::class, SimplifyConditionsRector::class, SimplifyEmptyArrayCheckRector::class, + SimplifyEmptyCheckOnEmptyArrayRector::class, StaticArrowFunctionRector::class, StaticClosureRector::class, ThrowWithPreviousExceptionRector::class, TypedPropertyFromStrictConstructorRector::class, - TypedPropertyFromStrictGetterMethodReturnTypeRector::class, - ]); -}; + RemoveAlwaysElseRector::class, + ]) +; diff --git a/ecs.php b/ecs.php index 45c8c6b..5ee3c42 100644 --- a/ecs.php +++ b/ecs.php @@ -1,15 +1,13 @@ paths([ - __DIR__ . '/src', - __DIR__ . '/config', - __DIR__ . '/rector.php', - __DIR__ . '/ecs.php', - ]); - - $c->sets([SetList::ECS]); -}; +return ECSConfig::configure() + ->withSets([LubiSetList::ECS]) + ->withPaths( + [ + __DIR__ . '/src', + __DIR__ . '/config', + ] + )->withRootFiles(); diff --git a/rector.php b/rector.php index 7970267..87b24f1 100644 --- a/rector.php +++ b/rector.php @@ -1,15 +1,13 @@ paths([ +return RectorConfig::configure() + ->withPaths([ __DIR__ . '/src', __DIR__ . '/config', - __DIR__ . '/rector.php', - __DIR__ . '/ecs.php', - ]); - - $c->sets([SetList::RECTOR]); -}; + ]) + ->withSets([LubiSetList::RECTOR]) + ->withRootFiles() +; diff --git a/src/LubiSetList.php b/src/LubiSetList.php new file mode 100644 index 0000000..092d20f --- /dev/null +++ b/src/LubiSetList.php @@ -0,0 +1,9 @@ +