Compare commits

..

No commits in common. "main" and "1.1.9" have entirely different histories.
main ... 1.1.9

9 changed files with 188 additions and 227 deletions

View file

@ -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

View file

@ -8,10 +8,9 @@
} }
}, },
"require": { "require": {
"php": "^8.3", "slevomat/coding-standard": "^8.13",
"slevomat/coding-standard": "^8.15", "symplify/easy-coding-standard": "^12.0",
"symplify/easy-coding-standard": "^12.3.5", "rector/rector": "^0.18.1"
"rector/rector": "^1.0.5"
}, },
"config": { "config": {
"allow-plugins": { "allow-plugins": {
@ -19,7 +18,7 @@
} }
}, },
"scripts": { "scripts": {
"lint": [ "fix": [
"rector", "rector",
"ecs --fix", "ecs --fix",
"ecs --fix" "ecs --fix"

149
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "6eb7806e6594ecc073d158d2f9b483f0", "content-hash": "0db36479542579fe3ed4d0a242e19390",
"packages": [ "packages": [
{ {
"name": "dealerdirect/phpcodesniffer-composer-installer", "name": "dealerdirect/phpcodesniffer-composer-installer",
@ -86,16 +86,16 @@
}, },
{ {
"name": "phpstan/phpdoc-parser", "name": "phpstan/phpdoc-parser",
"version": "1.28.0", "version": "1.23.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpdoc-parser.git", "url": "https://github.com/phpstan/phpdoc-parser.git",
"reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb" "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/846ae76eef31c6d7790fac9bc399ecee45160b26",
"reference": "cd06d6b1a1b3c75b0b83f97577869fd85a3cd4fb", "reference": "846ae76eef31c6d7790fac9bc399ecee45160b26",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -127,22 +127,22 @@
"description": "PHPDoc parser with support for nullable, intersection and generic types", "description": "PHPDoc parser with support for nullable, intersection and generic types",
"support": { "support": {
"issues": "https://github.com/phpstan/phpdoc-parser/issues", "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.23.1"
}, },
"time": "2024-04-03T18:51:33+00:00" "time": "2023-08-03T16:32:59+00:00"
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.10.67", "version": "1.10.32",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpstan/phpstan.git", "url": "https://github.com/phpstan/phpstan.git",
"reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493" "reference": "c47e47d3ab03137c0e121e77c4d2cb58672f6d44"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/16ddbe776f10da6a95ebd25de7c1dbed397dc493", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c47e47d3ab03137c0e121e77c4d2cb58672f6d44",
"reference": "16ddbe776f10da6a95ebd25de7c1dbed397dc493", "reference": "c47e47d3ab03137c0e121e77c4d2cb58672f6d44",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -185,27 +185,31 @@
{ {
"url": "https://github.com/phpstan", "url": "https://github.com/phpstan",
"type": "github" "type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
"type": "tidelift"
} }
], ],
"time": "2024-04-16T07:22:02+00:00" "time": "2023-08-24T21:54:50+00:00"
}, },
{ {
"name": "rector/rector", "name": "rector/rector",
"version": "1.0.5", "version": "0.18.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/rectorphp/rector.git", "url": "https://github.com/rectorphp/rector.git",
"reference": "73eb63e4f9011dba6b7c66c3262543014e352f34" "reference": "ee72ef542680a7f47ed8c6784f78b032c0d2f381"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/rectorphp/rector/zipball/73eb63e4f9011dba6b7c66c3262543014e352f34", "url": "https://api.github.com/repos/rectorphp/rector/zipball/ee72ef542680a7f47ed8c6784f78b032c0d2f381",
"reference": "73eb63e4f9011dba6b7c66c3262543014e352f34", "reference": "ee72ef542680a7f47ed8c6784f78b032c0d2f381",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.2|^8.0", "php": "^7.2|^8.0",
"phpstan/phpstan": "^1.10.57" "phpstan/phpstan": "^1.10.31"
}, },
"conflict": { "conflict": {
"rector/rector-doctrine": "*", "rector/rector-doctrine": "*",
@ -213,9 +217,6 @@
"rector/rector-phpunit": "*", "rector/rector-phpunit": "*",
"rector/rector-symfony": "*" "rector/rector-symfony": "*"
}, },
"suggest": {
"ext-dom": "To manipulate phpunit.xml via the custom-rule command"
},
"bin": [ "bin": [
"bin/rector" "bin/rector"
], ],
@ -238,7 +239,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/rectorphp/rector/issues", "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.18.1"
}, },
"funding": [ "funding": [
{ {
@ -246,36 +247,36 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-05-10T05:31:15+00:00" "time": "2023-08-28T18:01:58+00:00"
}, },
{ {
"name": "slevomat/coding-standard", "name": "slevomat/coding-standard",
"version": "8.15.0", "version": "8.13.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/slevomat/coding-standard.git", "url": "https://github.com/slevomat/coding-standard.git",
"reference": "7d1d957421618a3803b593ec31ace470177d7817" "reference": "4b2af2fb17773656d02fbfb5d18024ebd19fe322"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7d1d957421618a3803b593ec31ace470177d7817", "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/4b2af2fb17773656d02fbfb5d18024ebd19fe322",
"reference": "7d1d957421618a3803b593ec31ace470177d7817", "reference": "4b2af2fb17773656d02fbfb5d18024ebd19fe322",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0", "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7 || ^1.0",
"php": "^7.2 || ^8.0", "php": "^7.2 || ^8.0",
"phpstan/phpdoc-parser": "^1.23.1", "phpstan/phpdoc-parser": "^1.23.0",
"squizlabs/php_codesniffer": "^3.9.0" "squizlabs/php_codesniffer": "^3.7.1"
}, },
"require-dev": { "require-dev": {
"phing/phing": "2.17.4", "phing/phing": "2.17.4",
"php-parallel-lint/php-parallel-lint": "1.3.2", "php-parallel-lint/php-parallel-lint": "1.3.2",
"phpstan/phpstan": "1.10.60", "phpstan/phpstan": "1.10.26",
"phpstan/phpstan-deprecation-rules": "1.1.4", "phpstan/phpstan-deprecation-rules": "1.1.3",
"phpstan/phpstan-phpunit": "1.3.16", "phpstan/phpstan-phpunit": "1.3.13",
"phpstan/phpstan-strict-rules": "1.5.2", "phpstan/phpstan-strict-rules": "1.5.1",
"phpunit/phpunit": "8.5.21|9.6.8|10.5.11" "phpunit/phpunit": "7.5.20|8.5.21|9.6.8|10.2.6"
}, },
"type": "phpcodesniffer-standard", "type": "phpcodesniffer-standard",
"extra": { "extra": {
@ -299,7 +300,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/slevomat/coding-standard/issues", "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.13.4"
}, },
"funding": [ "funding": [
{ {
@ -311,20 +312,20 @@
"type": "tidelift" "type": "tidelift"
} }
], ],
"time": "2024-03-09T15:20:58+00:00" "time": "2023-07-25T10:28:55+00:00"
}, },
{ {
"name": "squizlabs/php_codesniffer", "name": "squizlabs/php_codesniffer",
"version": "3.9.2", "version": "3.7.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480" "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/aac1f6f347a5c5ac6bc98ad395007df00990f480", "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879",
"reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480", "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -334,11 +335,11 @@
"php": ">=5.4.0" "php": ">=5.4.0"
}, },
"require-dev": { "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": [
"bin/phpcbf", "bin/phpcs",
"bin/phpcs" "bin/phpcbf"
], ],
"type": "library", "type": "library",
"extra": { "extra": {
@ -353,70 +354,44 @@
"authors": [ "authors": [
{ {
"name": "Greg Sherwood", "name": "Greg Sherwood",
"role": "Former lead" "role": "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.", "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": [ "keywords": [
"phpcs", "phpcs",
"standards", "standards",
"static analysis" "static analysis"
], ],
"support": { "support": {
"issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues",
"security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", "source": "https://github.com/squizlabs/PHP_CodeSniffer",
"source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki"
"wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki"
}, },
"funding": [ "time": "2023-02-22T23:07:41+00:00"
{
"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", "name": "symplify/easy-coding-standard",
"version": "12.3.5", "version": "12.0.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/easy-coding-standard/easy-coding-standard.git", "url": "https://github.com/easy-coding-standard/easy-coding-standard.git",
"reference": "0d7c2cfee3debdf11c12135e90d69d1d9f4eef03" "reference": "79b5679f0dd758311770543969087b8dc46429ee"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/easy-coding-standard/easy-coding-standard/zipball/0d7c2cfee3debdf11c12135e90d69d1d9f4eef03", "url": "https://api.github.com/repos/easy-coding-standard/easy-coding-standard/zipball/79b5679f0dd758311770543969087b8dc46429ee",
"reference": "0d7c2cfee3debdf11c12135e90d69d1d9f4eef03", "reference": "79b5679f0dd758311770543969087b8dc46429ee",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.2" "php": ">=7.2"
}, },
"conflict": { "conflict": {
"friendsofphp/php-cs-fixer": "<3.46", "friendsofphp/php-cs-fixer": "<3.0",
"phpcsstandards/php_codesniffer": "<3.8", "squizlabs/php_codesniffer": "<3.6",
"symplify/coding-standard": "<12.1" "symplify/coding-standard": "<11.3"
},
"suggest": {
"ext-dom": "Needed to support checkstyle output format in class CheckstyleOutputFormatter"
}, },
"bin": [ "bin": [
"bin/ecs" "bin/ecs"
@ -440,7 +415,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/easy-coding-standard/easy-coding-standard/issues", "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.0.7"
}, },
"funding": [ "funding": [
{ {
@ -452,7 +427,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2024-08-08T08:43:50+00:00" "time": "2023-08-24T21:43:33+00:00"
} }
], ],
"packages-dev": [], "packages-dev": [],
@ -461,9 +436,7 @@
"stability-flags": [], "stability-flags": [],
"prefer-stable": false, "prefer-stable": false,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": [],
"php": "^8.3"
},
"platform-dev": [], "platform-dev": [],
"plugin-api-version": "2.6.0" "plugin-api-version": "2.3.0"
} }

View file

@ -1,11 +1,8 @@
<?php declare(strict_types=1); <?php declare(strict_types=1);
use PhpCsFixer\Fixer\ClassNotation\ClassAttributesSeparationFixer; use PhpCsFixer\Fixer\Basic\BracesFixer;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer; use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
use PhpCsFixer\Fixer\LanguageConstruct\FunctionToConstantFixer;
use PhpCsFixer\Fixer\Operator\NewWithBracesFixer; use PhpCsFixer\Fixer\Operator\NewWithBracesFixer;
use PhpCsFixer\Fixer\Operator\NewWithParenthesesFixer;
use PhpCsFixer\Fixer\Operator\OperatorLinebreakFixer;
use PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer; use PhpCsFixer\Fixer\PhpTag\BlankLineAfterOpeningTagFixer;
use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer; use PhpCsFixer\Fixer\Whitespace\NoExtraBlankLinesFixer;
use PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer; use PhpCsFixer\Fixer\Whitespace\NoWhitespaceInBlankLineFixer;
@ -22,38 +19,44 @@ use SlevomatCodingStandard\Sniffs\TypeHints\DeclareStrictTypesSniff;
use SlevomatCodingStandard\Sniffs\TypeHints\UnionTypeHintFormatSniff; use SlevomatCodingStandard\Sniffs\TypeHints\UnionTypeHintFormatSniff;
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer; use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig; use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
return ECSConfig::configure() return static function (ECSConfig $c): void {
->withPreparedSets( $c->skip([
symplify: true, BlankLineAfterOpeningTagFixer::class,
arrays: true, NewWithBracesFixer::class,
comments: true, OrderedImportsFixer::class,
docblocks: true, ]);
spaces: true,
namespaces: true, $c->sets([
controlStructures: true, SetList::ARRAY,
strict: true, SetList::CLEAN_CODE,
cleanCode: true SetList::COMMENTS,
) SetList::COMMON,
->withPhpCsFixerSets( SetList::CONTROL_STRUCTURES,
perCS: true, SetList::DOCBLOCK,
perCSRisky: true, SetList::NAMESPACES,
php80MigrationRisky: true, SetList::PSR_12,
php83Migration: true, SetList::SPACES,
) SetList::STRICT,
->withRules([ SetList::SYMPLIFY,
]);
// force visibility declaration on class constants
$c->ruleWithConfiguration(ClassConstantVisibilitySniff::class, [
'fixable' => true,
]);
// sort all use statements
$c->rules([
AlphabeticallySortedUsesSniff::class, AlphabeticallySortedUsesSniff::class,
DisallowGroupUseSniff::class, DisallowGroupUseSniff::class,
MultipleUsesPerLineSniff::class, MultipleUsesPerLineSniff::class,
NamespaceSpacingSniff::class, NamespaceSpacingSniff::class,
OperatorLinebreakFixer::class, ]);
NoWhitespaceInBlankLineFixer::class,
NewWithoutParenthesesSniff::class, // import all namespaces, and event php core functions and classes
]) $c->ruleWithConfiguration(
->withConfiguredRule(ClassConstantVisibilitySniff::class, [
'fixable' => true,
])
->withConfiguredRule(
ReferenceUsedNamesOnlySniff::class, ReferenceUsedNamesOnlySniff::class,
[ [
'allowFallbackGlobalConstants' => false, 'allowFallbackGlobalConstants' => false,
@ -66,57 +69,51 @@ return ECSConfig::configure()
'allowFullyQualifiedNameForCollidingFunctions' => true, 'allowFullyQualifiedNameForCollidingFunctions' => true,
'searchAnnotations' => true, 'searchAnnotations' => true,
] ]
) );
// define newlines between use statements // define newlines between use statements
->withConfiguredRule( $c->ruleWithConfiguration(UseSpacingSniff::class, [
UseSpacingSniff::class,
[
'linesCountAfterLastUse' => 1, 'linesCountAfterLastUse' => 1,
'linesCountBeforeFirstUse' => 1, 'linesCountBeforeFirstUse' => 1,
'linesCountBetweenUseTypes' => 1, 'linesCountBetweenUseTypes' => 1,
] ]);
)
->withConfiguredRule( // strict types declaration should be on same line as opening tag
ClassAttributesSeparationFixer::class, $c->ruleWithConfiguration(
[
'elements' => [
'const' => 'none',
'method' => 'one',
'property' => 'none',
'trait_import' => 'none',
'case' => 'none',
],
],
)->withConfiguredRule(
DeclareStrictTypesSniff::class, DeclareStrictTypesSniff::class,
[ [
'declareOnFirstLine' => true, 'declareOnFirstLine' => true,
'spacesCountAroundEqualsSign' => 0, 'spacesCountAroundEqualsSign' => 0,
] ]
) );
->withConfiguredRule(
UnionTypeHintFormatSniff::class, // disallow ?Foo typehint in favor of Foo|null
[ $c->ruleWithConfiguration(UnionTypeHintFormatSniff::class, [
'nullPosition' => 'last', 'nullPosition' => 'last',
'shortNullable' => 'no', 'shortNullable' => 'no',
'withSpaces' => 'no', 'withSpaces' => 'no',
] ]);
)
->withConfiguredRule( // 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, NoExtraBlankLinesFixer::class,
[ [
'tokens' => ['square_brace_block', 'return', 'extra'], 'tokens' => ['square_brace_block', 'return', 'extra'],
] ]
) );
->withConfiguredRule(AttributeAndTargetSpacingSniff::class, [
$c->rule(NoWhitespaceInBlankLineFixer::class);
// make sure that the attribute target is on the line after the attribute
$c->ruleWithConfiguration(AttributeAndTargetSpacingSniff::class, [
'linesCount' => 0, 'linesCount' => 0,
])
->withSkip([
BlankLineAfterOpeningTagFixer::class,
OrderedImportsFixer::class,
FunctionToConstantFixer::class,
NewWithParenthesesFixer::class,
NewWithBracesFixer::class,
LineLengthFixer::class,
]); ]);
};

View file

@ -14,8 +14,10 @@ use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
use Rector\CodingStyle\Rector\Closure\StaticClosureRector; use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector; use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector; use Rector\CodingStyle\Rector\If_\NullableCompareToNullRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\Config\RectorConfig; use Rector\Config\RectorConfig;
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector; use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector; use Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector; use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
@ -23,6 +25,7 @@ use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector; use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector; use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector;
use Rector\Php80\Rector\ClassConstFetch\ClassOnThisVariableObjectRector; use Rector\Php80\Rector\ClassConstFetch\ClassOnThisVariableObjectRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector; use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector; use Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeFromPropertyTypeRector;
@ -31,6 +34,7 @@ use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector; use Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnDirectArrayRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnDirectArrayRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictBoolReturnExprRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictConstantReturnRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictConstantReturnRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNewArrayRector;
@ -38,18 +42,13 @@ use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRecto
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector; use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddParamTypeSplFixedArrayRector; use Rector\TypeDeclaration\Rector\FunctionLike\AddParamTypeSplFixedArrayRector;
use Rector\TypeDeclaration\Rector\FunctionLike\AddReturnTypeDeclarationFromYieldsRector; use Rector\TypeDeclaration\Rector\FunctionLike\AddReturnTypeDeclarationFromYieldsRector;
use Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector;
return RectorConfig::configure() return static function (RectorConfig $c): void {
->withPhpSets(php83: true) $c->sets([LevelSetList::UP_TO_PHP_82]);
->withPreparedSets( $c->rules([
deadCode: true,
codeQuality: true,
typeDeclarations: true,
earlyReturn: true,
strictBooleans: true,
)
->withRules([
AddArrowFunctionReturnTypeRector::class, AddArrowFunctionReturnTypeRector::class,
AddMethodCallBasedStrictParamTypeRector::class, AddMethodCallBasedStrictParamTypeRector::class,
AddParamTypeFromPropertyTypeRector::class, AddParamTypeFromPropertyTypeRector::class,
@ -57,6 +56,7 @@ return RectorConfig::configure()
AddReturnTypeDeclarationBasedOnParentClassMethodRector::class, AddReturnTypeDeclarationBasedOnParentClassMethodRector::class,
AddReturnTypeDeclarationFromYieldsRector::class, AddReturnTypeDeclarationFromYieldsRector::class,
BooleanNotIdenticalToNotIdenticalRector::class, BooleanNotIdenticalToNotIdenticalRector::class,
ChangeAndIfToEarlyReturnRector::class,
ChangeNestedForeachIfsToEarlyContinueRector::class, ChangeNestedForeachIfsToEarlyContinueRector::class,
ChangeNestedIfsToEarlyReturnRector::class, ChangeNestedIfsToEarlyReturnRector::class,
ChangeOrIfContinueToMultiContinueRector::class, ChangeOrIfContinueToMultiContinueRector::class,
@ -65,16 +65,19 @@ return RectorConfig::configure()
ExplicitBoolCompareRector::class, ExplicitBoolCompareRector::class,
InlineArrayReturnAssignRector::class, InlineArrayReturnAssignRector::class,
InlineIsAInstanceOfRector::class, InlineIsAInstanceOfRector::class,
NewlineAfterStatementRector::class,
NewlineBeforeNewAssignSetRector::class, NewlineBeforeNewAssignSetRector::class,
NullableCompareToNullRector::class, NullableCompareToNullRector::class,
ParamTypeByMethodCallTypeRector::class, ParamTypeByMethodCallTypeRector::class,
ParamTypeByParentCallTypeRector::class, ParamTypeByParentCallTypeRector::class,
ParamTypeFromStrictTypedPropertyRector::class,
PreparedValueToEarlyReturnRector::class, PreparedValueToEarlyReturnRector::class,
ReplaceMultipleBooleanNotRector::class, ReplaceMultipleBooleanNotRector::class,
ReturnBinaryOrToEarlyReturnRector::class, ReturnBinaryOrToEarlyReturnRector::class,
ReturnEarlyIfVariableRector::class, ReturnEarlyIfVariableRector::class,
ReturnTypeFromReturnDirectArrayRector::class, ReturnTypeFromReturnDirectArrayRector::class,
ReturnTypeFromReturnNewRector::class, ReturnTypeFromReturnNewRector::class,
ReturnTypeFromStrictBoolReturnExprRector::class,
ReturnTypeFromStrictConstantReturnRector::class, ReturnTypeFromStrictConstantReturnRector::class,
ReturnTypeFromStrictNativeCallRector::class, ReturnTypeFromStrictNativeCallRector::class,
ReturnTypeFromStrictNewArrayRector::class, ReturnTypeFromStrictNewArrayRector::class,
@ -87,6 +90,7 @@ return RectorConfig::configure()
StaticClosureRector::class, StaticClosureRector::class,
ThrowWithPreviousExceptionRector::class, ThrowWithPreviousExceptionRector::class,
TypedPropertyFromStrictConstructorRector::class, TypedPropertyFromStrictConstructorRector::class,
TypedPropertyFromStrictGetterMethodReturnTypeRector::class,
RemoveAlwaysElseRector::class, RemoveAlwaysElseRector::class,
]) ]);
; };

14
ecs.php
View file

@ -3,11 +3,13 @@
use Lubiana\CodeQuality\LubiSetList; use Lubiana\CodeQuality\LubiSetList;
use Symplify\EasyCodingStandard\Config\ECSConfig; use Symplify\EasyCodingStandard\Config\ECSConfig;
return ECSConfig::configure() return static function (ECSConfig $c): void {
->withSets([LubiSetList::ECS]) $c->paths([
->withPaths(
[
__DIR__ . '/src', __DIR__ . '/src',
__DIR__ . '/config', __DIR__ . '/config',
] __DIR__ . '/rector.php',
)->withRootFiles(); __DIR__ . '/ecs.php',
]);
$c->sets([LubiSetList::ECS]);
};

View file

@ -3,11 +3,13 @@
use Lubiana\CodeQuality\LubiSetList; use Lubiana\CodeQuality\LubiSetList;
use Rector\Config\RectorConfig; use Rector\Config\RectorConfig;
return RectorConfig::configure() return static function (RectorConfig $c): void {
->withPaths([ $c->paths([
__DIR__ . '/src', __DIR__ . '/src',
__DIR__ . '/config', __DIR__ . '/config',
]) __DIR__ . '/rector.php',
->withSets([LubiSetList::RECTOR]) __DIR__ . '/ecs.php',
->withRootFiles() ]);
;
$c->sets([LubiSetList::RECTOR]);
};

View file

@ -4,6 +4,7 @@ namespace Lubiana\CodeQuality;
final class LubiSetList final class LubiSetList
{ {
public const string RECTOR = __DIR__ . '/../config/rector.php'; public const RECTOR = __DIR__ . '/../config/rector.php';
public const string ECS = __DIR__ . '/../config/ecs.php';
public const ECS = __DIR__ . '/../config/ecs.php';
} }

17
src/SetList.php Normal file
View file

@ -0,0 +1,17 @@
<?php declare(strict_types=1);
namespace Lubiana\CodeQuality;
/** @deprecated use LubiSetList */
final class SetList
{
/**
* @deprecated use LubiSetList::RECTOR
*/
public const RECTOR = LubiSetList::RECTOR;
/**
* @deprecated use LubiSetList::ECS
*/
public const ECS = LubiSetList::ECS;
}