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 e54e792..8417adf 100644 --- a/composer.json +++ b/composer.json @@ -1,28 +1,19 @@ { "name": "lubiana/code-quality", "license": ["MIT"], - "keywords": ["dev"], "autoload": { "psr-4": { "Lubiana\\CodeQuality\\": "src/" } }, "require": { - "php": "^8.3", - "slevomat/coding-standard": "^8.19.1", - "symplify/easy-coding-standard": "^12.5.20", - "rector/rector": "^2.1.0" + "slevomat/coding-standard": "^8.6.4", + "symplify/easy-coding-standard": "^11.1.17", + "rector/rector": "^0.15.0" }, "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true } - }, - "scripts": { - "lint": [ - "rector", - "ecs --fix", - "ecs --fix" - ] } } diff --git a/composer.lock b/composer.lock index 9125db8..1b2d993 100644 --- a/composer.lock +++ b/composer.lock @@ -4,42 +4,39 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ad0d85d577b5ff899223018bfcf8eee2", + "content-hash": "ed43b0a7a305296de34ea31e50e17720", "packages": [ { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v1.1.1", + "version": "v0.7.2", "source": { "type": "git", - "url": "https://github.com/PHPCSStandards/composer-installer.git", - "reference": "6e0fa428497bf560152ee73ffbb8af5c6a56b0dd" + "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/6e0fa428497bf560152ee73ffbb8af5c6a56b0dd", - "reference": "6e0fa428497bf560152ee73ffbb8af5c6a56b0dd", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", + "reference": "1c968e542d8843d7cd71de3c5c9c3ff3ad71a1db", "shasum": "" }, "require": { - "composer-plugin-api": "^2.2", - "php": ">=5.4", + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.3", "squizlabs/php_codesniffer": "^2.0 || ^3.1.0 || ^4.0" }, "require-dev": { - "composer/composer": "^2.2", - "ext-json": "*", - "ext-zip": "*", - "php-parallel-lint/php-parallel-lint": "^1.4.0", - "phpcompatibility/php-compatibility": "^9.0", - "yoast/phpunit-polyfills": "^1.0" + "composer/composer": "*", + "php-parallel-lint/php-parallel-lint": "^1.3.1", + "phpcompatibility/php-compatibility": "^9.0" }, "type": "composer-plugin", "extra": { - "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" }, "autoload": { "psr-4": { - "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -49,16 +46,17 @@ "authors": [ { "name": "Franck Nijhof", - "email": "opensource@frenck.dev", - "homepage": "https://frenck.dev", - "role": "Open source developer" + "email": "franck.nijhof@dealerdirect.com", + "homepage": "http://www.frenck.nl", + "role": "Developer / IT Manager" }, { "name": "Contributors", - "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" + "homepage": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer/graphs/contributors" } ], "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "homepage": "http://www.dealerdirect.com", "keywords": [ "PHPCodeSniffer", "PHP_CodeSniffer", @@ -78,56 +76,35 @@ "tests" ], "support": { - "issues": "https://github.com/PHPCSStandards/composer-installer/issues", - "security": "https://github.com/PHPCSStandards/composer-installer/security/policy", - "source": "https://github.com/PHPCSStandards/composer-installer" + "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", + "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" }, - "funding": [ - { - "url": "https://github.com/PHPCSStandards", - "type": "github" - }, - { - "url": "https://github.com/jrfnl", - "type": "github" - }, - { - "url": "https://opencollective.com/php_codesniffer", - "type": "open_collective" - }, - { - "url": "https://thanks.dev/u/gh/phpcsstandards", - "type": "thanks_dev" - } - ], - "time": "2025-06-27T17:24:01+00:00" + "time": "2022-02-04T12:51:07+00:00" }, { "name": "phpstan/phpdoc-parser", - "version": "2.1.0", + "version": "1.13.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68" + "reference": "aac44118344d197e6d5f7c6cee91885f0a89acdd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/9b30d6fd026b2c132b3985ce6b23bec09ab3aa68", - "reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/aac44118344d197e6d5f7c6cee91885f0a89acdd", + "reference": "aac44118344d197e6d5f7c6cee91885f0a89acdd", "shasum": "" }, "require": { - "php": "^7.4 || ^8.0" + "php": "^7.2 || ^8.0" }, "require-dev": { - "doctrine/annotations": "^2.0", - "nikic/php-parser": "^5.3.0", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^2.0", - "phpstan/phpstan-phpunit": "^2.0", - "phpstan/phpstan-strict-rules": "^2.0", - "phpunit/phpunit": "^9.6", + "phpstan/phpstan": "^1.5", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.0", + "phpunit/phpunit": "^9.5", "symfony/process": "^5.2" }, "type": "library", @@ -145,26 +122,26 @@ "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/2.1.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.13.1" }, - "time": "2025-02-19T13:28:12+00:00" + "time": "2022-11-20T08:52:26+00:00" }, { "name": "phpstan/phpstan", - "version": "2.1.17", + "version": "1.9.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "89b5ef665716fa2a52ecd2633f21007a6a349053" + "reference": "d6fdf01c53978b6429f1393ba4afeca39cc68afa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/89b5ef665716fa2a52ecd2633f21007a6a349053", - "reference": "89b5ef665716fa2a52ecd2633f21007a6a349053", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/d6fdf01c53978b6429f1393ba4afeca39cc68afa", + "reference": "d6fdf01c53978b6429f1393ba4afeca39cc68afa", "shasum": "" }, "require": { - "php": "^7.4|^8.0" + "php": "^7.2|^8.0" }, "conflict": { "phpstan/phpstan-shim": "*" @@ -189,11 +166,8 @@ "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", - "security": "https://github.com/phpstan/phpstan/security/policy", - "source": "https://github.com/phpstan/phpstan-src" + "source": "https://github.com/phpstan/phpstan/tree/1.9.2" }, "funding": [ { @@ -203,41 +177,48 @@ { "url": "https://github.com/phpstan", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" } ], - "time": "2025-05-21T20:55:28+00:00" + "time": "2022-11-10T09:56:11+00:00" }, { "name": "rector/rector", - "version": "2.1.0", + "version": "0.15.0", "source": { "type": "git", "url": "https://github.com/rectorphp/rector.git", - "reference": "d513dea45a94394b660e15c155d1fa27826f8e30" + "reference": "fbfbe499d0fedfac7fe2fed1a55a00bd08f19c91" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rectorphp/rector/zipball/d513dea45a94394b660e15c155d1fa27826f8e30", - "reference": "d513dea45a94394b660e15c155d1fa27826f8e30", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/fbfbe499d0fedfac7fe2fed1a55a00bd08f19c91", + "reference": "fbfbe499d0fedfac7fe2fed1a55a00bd08f19c91", "shasum": "" }, "require": { - "php": "^7.4|^8.0", - "phpstan/phpstan": "^2.1.17" + "php": "^7.2|^8.0", + "phpstan/phpstan": "^1.9.2" }, "conflict": { "rector/rector-doctrine": "*", "rector/rector-downgrade-php": "*", + "rector/rector-php-parser": "*", "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" @@ -248,16 +229,9 @@ "MIT" ], "description": "Instant Upgrade and Automated Refactoring of any PHP code", - "homepage": "https://getrector.com/", - "keywords": [ - "automation", - "dev", - "migration", - "refactoring" - ], "support": { "issues": "https://github.com/rectorphp/rector/issues", - "source": "https://github.com/rectorphp/rector/tree/2.1.0" + "source": "https://github.com/rectorphp/rector/tree/0.15.0" }, "funding": [ { @@ -265,36 +239,36 @@ "type": "github" } ], - "time": "2025-06-24T20:26:57+00:00" + "time": "2022-12-04T22:40:18+00:00" }, { "name": "slevomat/coding-standard", - "version": "8.19.1", + "version": "8.6.4", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "458d665acd49009efebd7e0cb385d71ae9ac3220" + "reference": "8a02c83e59c3230a2a4367b29956a2f2b56e3a24" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/458d665acd49009efebd7e0cb385d71ae9ac3220", - "reference": "458d665acd49009efebd7e0cb385d71ae9ac3220", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/8a02c83e59c3230a2a4367b29956a2f2b56e3a24", + "reference": "8a02c83e59c3230a2a4367b29956a2f2b56e3a24", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", - "php": "^7.4 || ^8.0", - "phpstan/phpdoc-parser": "^2.1.0", - "squizlabs/php_codesniffer": "^3.13.0" + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", + "php": "^7.2 || ^8.0", + "phpstan/phpdoc-parser": ">=1.11.0 <1.14.0", + "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { - "phing/phing": "3.0.1", - "php-parallel-lint/php-parallel-lint": "1.4.0", - "phpstan/phpstan": "2.1.17", - "phpstan/phpstan-deprecation-rules": "2.0.3", - "phpstan/phpstan-phpunit": "2.0.6", - "phpstan/phpstan-strict-rules": "2.0.4", - "phpunit/phpunit": "9.6.8|10.5.45|11.4.4|11.5.21|12.1.3" + "phing/phing": "2.17.4", + "php-parallel-lint/php-parallel-lint": "1.3.2", + "phpstan/phpstan": "1.4.10|1.9.2", + "phpstan/phpstan-deprecation-rules": "1.0.0", + "phpstan/phpstan-phpunit": "1.0.0|1.2.2", + "phpstan/phpstan-strict-rules": "1.4.4", + "phpunit/phpunit": "7.5.20|8.5.21|9.5.26" }, "type": "phpcodesniffer-standard", "extra": { @@ -304,7 +278,7 @@ }, "autoload": { "psr-4": { - "SlevomatCodingStandard\\": "SlevomatCodingStandard/" + "SlevomatCodingStandard\\": "SlevomatCodingStandard" } }, "notification-url": "https://packagist.org/downloads/", @@ -318,7 +292,7 @@ ], "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/8.19.1" + "source": "https://github.com/slevomat/coding-standard/tree/8.6.4" }, "funding": [ { @@ -330,20 +304,20 @@ "type": "tidelift" } ], - "time": "2025-06-09T17:53:57+00:00" + "time": "2022-11-14T09:26:24+00:00" }, { "name": "squizlabs/php_codesniffer", - "version": "3.13.2", + "version": "3.7.1", "source": { "type": "git", - "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "5b5e3821314f947dd040c70f7992a64eac89025c" + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/5b5e3821314f947dd040c70f7992a64eac89025c", - "reference": "5b5e3821314f947dd040c70f7992a64eac89025c", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/1359e176e9307e906dc3d890bcc9603ff6d90619", + "reference": "1359e176e9307e906dc3d890bcc9603ff6d90619", "shasum": "" }, "require": { @@ -353,11 +327,11 @@ "php": ">=5.4.0" }, "require-dev": { - "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, "bin": [ - "bin/phpcbf", - "bin/phpcs" + "bin/phpcs", + "bin/phpcbf" ], "type": "library", "extra": { @@ -372,79 +346,52 @@ "authors": [ { "name": "Greg Sherwood", - "role": "Former lead" - }, - { - "name": "Juliette Reinders Folmer", - "role": "Current lead" - }, - { - "name": "Contributors", - "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + "role": "lead" } ], "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", - "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "homepage": "https://github.com/squizlabs/PHP_CodeSniffer", "keywords": [ "phpcs", - "standards", - "static analysis" + "standards" ], "support": { - "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" + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, - "funding": [ - { - "url": "https://github.com/PHPCSStandards", - "type": "github" - }, - { - "url": "https://github.com/jrfnl", - "type": "github" - }, - { - "url": "https://opencollective.com/php_codesniffer", - "type": "open_collective" - }, - { - "url": "https://thanks.dev/u/gh/phpcsstandards", - "type": "thanks_dev" - } - ], - "time": "2025-06-17T22:17:01+00:00" + "time": "2022-06-18T07:21:10+00:00" }, { "name": "symplify/easy-coding-standard", - "version": "12.5.20", + "version": "11.1.17", "source": { "type": "git", - "url": "https://github.com/easy-coding-standard/easy-coding-standard.git", - "reference": "bb44b0fc70dd2148d8a6362bc66a35e23dc31bc4" + "url": "https://github.com/symplify/easy-coding-standard.git", + "reference": "2a98e5b976a3ab573d8e5604d6eb39d9f5783760" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/easy-coding-standard/easy-coding-standard/zipball/bb44b0fc70dd2148d8a6362bc66a35e23dc31bc4", - "reference": "bb44b0fc70dd2148d8a6362bc66a35e23dc31bc4", + "url": "https://api.github.com/repos/symplify/easy-coding-standard/zipball/2a98e5b976a3ab573d8e5604d6eb39d9f5783760", + "reference": "2a98e5b976a3ab573d8e5604d6eb39d9f5783760", "shasum": "" }, "require": { "php": ">=7.2" }, "conflict": { - "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" + "friendsofphp/php-cs-fixer": "<3.0", + "squizlabs/php_codesniffer": "<3.6" }, "bin": [ "bin/ecs" ], "type": "library", + "extra": { + "branch-alias": { + "dev-main": "10.3-dev" + } + }, "autoload": { "files": [ "bootstrap.php" @@ -454,16 +401,9 @@ "license": [ "MIT" ], - "description": "Use Coding Standard with 0-knowledge of PHP-CS-Fixer and PHP_CodeSniffer", - "keywords": [ - "Code style", - "automation", - "fixer", - "static analysis" - ], + "description": "Prefixed scoped version of ECS package", "support": { - "issues": "https://github.com/easy-coding-standard/easy-coding-standard/issues", - "source": "https://github.com/easy-coding-standard/easy-coding-standard/tree/12.5.20" + "source": "https://github.com/symplify/easy-coding-standard/tree/11.1.17" }, "funding": [ { @@ -475,18 +415,16 @@ "type": "github" } ], - "time": "2025-05-30T11:42:07+00:00" + "time": "2022-11-10T15:20:49+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": { - "php": "^8.3" - }, - "platform-dev": {}, - "plugin-api-version": "2.6.0" + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.3.0" } diff --git a/config/ecs.php b/config/ecs.php index fc42fa3..76f1333 100644 --- a/config/ecs.php +++ b/config/ecs.php @@ -1,19 +1,11 @@ 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([ +return static function (ECSConfig $c): void { + $c->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([ AlphabeticallySortedUsesSniff::class, DisallowGroupUseSniff::class, MultipleUsesPerLineSniff::class, NamespaceSpacingSniff::class, - OperatorLinebreakFixer::class, - NoWhitespaceInBlankLineFixer::class, - NewWithoutParenthesesSniff::class, - OrderedAttributesFixer::class, - OrderedTraitsFixer::class, - OrderedInterfacesFixer::class, - ]) - ->withConfiguredRule(ClassConstantVisibilitySniff::class, [ - 'fixable' => true, - ]) - ->withConfiguredRule( + ]); + + // import all namespaces, and event php core functions and classes + $c->ruleWithConfiguration( ReferenceUsedNamesOnlySniff::class, [ 'allowFallbackGlobalConstants' => false, @@ -73,60 +68,46 @@ return ECSConfig::configure() 'allowFullyQualifiedNameForCollidingFunctions' => true, 'searchAnnotations' => true, ] - ) - ->withConfiguredRule(OrderedClassElementsFixer::class, [ - 'sort_algorithm' => 'alpha', - ]) + ); // define newlines between use statements - ->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( + $c->ruleWithConfiguration(UseSpacingSniff::class, [ + 'linesCountAfterLastUse' => 1, + 'linesCountBeforeFirstUse' => 1, + 'linesCountBetweenUseTypes' => 1, + ]); + + // strict types declaration should be on same line as opening tag + $c->ruleWithConfiguration( DeclareStrictTypesSniff::class, [ 'declareOnFirstLine' => true, 'spacesCountAroundEqualsSign' => 0, ] - ) - ->withConfiguredRule( - DNFTypeHintFormatSniff::class, - [ - 'nullPosition' => 'last', - 'shortNullable' => 'no', - 'withSpacesAroundOperators' => 'no', - ] - ) - ->withConfiguredRule( + ); + + // 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( NoExtraBlankLinesFixer::class, [ 'tokens' => ['square_brace_block', 'return', 'extra'], ] - ) - ->withConfiguredRule(AttributeAndTargetSpacingSniff::class, [ - 'linesCount' => 0, - ]) - ->withSkip([ - BlankLineAfterOpeningTagFixer::class, - OrderedImportsFixer::class, - FunctionToConstantFixer::class, - NewWithParenthesesFixer::class, - NewWithBracesFixer::class, - LineLengthFixer::class, - ]); + ); + + $c->rule(NoWhitespaceInBlankLineFixer::class); +}; diff --git a/config/rector.php b/config/rector.php index c6daf13..f49f121 100644 --- a/config/rector.php +++ b/config/rector.php @@ -4,7 +4,6 @@ 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; @@ -14,79 +13,78 @@ 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_\RemoveAlwaysElseRector; +use Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector; 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\Php80\Rector\ClassConstFetch\ClassOnThisVariableObjectRector; +use Rector\Set\ValueObject\LevelSetList; 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\ReturnTypeFromStrictConstantReturnRector; +use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictBoolReturnExprRector; 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\FunctionLike\AddParamTypeSplFixedArrayRector; -use Rector\TypeDeclaration\Rector\FunctionLike\AddReturnTypeDeclarationFromYieldsRector; +use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector; +use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector; +use Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector; +use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector; -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_81]); + $c->rules([ + AddArrayParamDocTypeRector::class, + AddArrayReturnDocTypeRector::class, AddArrowFunctionReturnTypeRector::class, + AddClosureReturnTypeRector::class, AddMethodCallBasedStrictParamTypeRector::class, - AddParamTypeFromPropertyTypeRector::class, - AddParamTypeSplFixedArrayRector::class, AddReturnTypeDeclarationBasedOnParentClassMethodRector::class, - AddReturnTypeDeclarationFromYieldsRector::class, BooleanNotIdenticalToNotIdenticalRector::class, + ChangeAndIfToEarlyReturnRector::class, ChangeNestedForeachIfsToEarlyContinueRector::class, ChangeNestedIfsToEarlyReturnRector::class, ChangeOrIfContinueToMultiContinueRector::class, - ClassOnThisVariableObjectRector::class, + ChangeOrIfReturnToEarlyReturnRector::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, - ReturnTypeFromReturnDirectArrayRector::class, + ReturnTypeDeclarationRector::class, ReturnTypeFromReturnNewRector::class, - ReturnTypeFromStrictConstantReturnRector::class, + ReturnTypeFromStrictBoolReturnExprRector::class, ReturnTypeFromStrictNativeCallRector::class, ReturnTypeFromStrictNewArrayRector::class, - ReturnTypeFromStrictTypedCallRector::class, ReturnTypeFromStrictTypedPropertyRector::class, SimplifyConditionsRector::class, SimplifyEmptyArrayCheckRector::class, - SimplifyEmptyCheckOnEmptyArrayRector::class, StaticArrowFunctionRector::class, StaticClosureRector::class, ThrowWithPreviousExceptionRector::class, TypedPropertyFromStrictConstructorRector::class, - RemoveAlwaysElseRector::class, - ]) -; + TypedPropertyFromStrictGetterMethodReturnTypeRector::class, + ]); +}; diff --git a/ecs.php b/ecs.php index 5ee3c42..7a1aa39 100644 --- a/ecs.php +++ b/ecs.php @@ -3,11 +3,13 @@ use Lubiana\CodeQuality\LubiSetList; use Symplify\EasyCodingStandard\Config\ECSConfig; -return ECSConfig::configure() - ->withSets([LubiSetList::ECS]) - ->withPaths( - [ - __DIR__ . '/src', - __DIR__ . '/config', - ] - )->withRootFiles(); +return static function (ECSConfig $c): void { + $c->paths([ + __DIR__ . '/src', + __DIR__ . '/config', + __DIR__ . '/rector.php', + __DIR__ . '/ecs.php', + ]); + + $c->sets([LubiSetList::ECS]); +}; 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 3517e4c..d78838d 100644 --- a/src/LubiSetList.php +++ b/src/LubiSetList.php @@ -4,6 +4,7 @@ namespace Lubiana\CodeQuality; final class LubiSetList { - public const string ECS = __DIR__ . '/../config/ecs.php'; - public const string RECTOR = __DIR__ . '/../config/rector.php'; + public const RECTOR = __DIR__ . '/../config/rector.php'; + + public const ECS = __DIR__ . '/../config/ecs.php'; } diff --git a/src/SetList.php b/src/SetList.php new file mode 100644 index 0000000..00fe282 --- /dev/null +++ b/src/SetList.php @@ -0,0 +1,17 @@ +