mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 08:50:50 +00:00
switch ecs.yaml to ecs.php
This commit is contained in:
parent
f8c50ee885
commit
70895c8f6b
|
@ -29,29 +29,29 @@
|
|||
"symfony/dependency-injection": "^4.4.8|^5.0.6",
|
||||
"symfony/finder": "^4.4.8|^5.0.6",
|
||||
"symfony/process": "^4.4.8|^5.0.6",
|
||||
"symplify/auto-bind-parameter": "^8.1.6",
|
||||
"symplify/autowire-array-parameter": "^8.1.6",
|
||||
"symplify/console-color-diff": "^8.1.6",
|
||||
"symplify/package-builder": "^8.1.6",
|
||||
"symplify/parameter-name-guard": "^8.1.6",
|
||||
"symplify/set-config-resolver": "^8.1.6",
|
||||
"symplify/auto-bind-parameter": "^8.1.9",
|
||||
"symplify/autowire-array-parameter": "^8.1.9",
|
||||
"symplify/console-color-diff": "^8.1.9",
|
||||
"symplify/package-builder": "^8.1.9",
|
||||
"symplify/parameter-name-guard": "^8.1.9",
|
||||
"symplify/set-config-resolver": "^8.1.9",
|
||||
"tracy/tracy": "^2.7",
|
||||
"phpstan/phpstan": "^0.12.32"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^2.16",
|
||||
"johnkary/phpunit-speedtrap": "^3.2",
|
||||
"migrify/config-transformer": "^0.3.8",
|
||||
"migrify/config-transformer": "^0.3.10",
|
||||
"ocramius/package-versions": "^1.4|^1.5",
|
||||
"phpunit/phpunit": "^8.5|^9.0",
|
||||
"psr/event-dispatcher": "^1.0",
|
||||
"slam/phpstan-extensions": "^5.0",
|
||||
"slevomat/coding-standard": "dev-master",
|
||||
"symplify/changelog-linker": "^8.1.6",
|
||||
"symplify/easy-coding-standard": "^8.1.6",
|
||||
"symplify/easy-testing": "^8.1.6",
|
||||
"symplify/monorepo-builder": "^8.1.6",
|
||||
"symplify/phpstan-extensions": "^8.1.6",
|
||||
"symplify/changelog-linker": "^8.1.9",
|
||||
"symplify/easy-coding-standard": "^8.1.9",
|
||||
"symplify/easy-testing": "^8.1.9",
|
||||
"symplify/monorepo-builder": "^8.1.9",
|
||||
"symplify/phpstan-extensions": "^8.1.9",
|
||||
"thecodingmachine/phpstan-strict-rules": "^0.12"
|
||||
},
|
||||
"autoload": {
|
||||
|
|
78
ecs.php
Normal file
78
ecs.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
|
||||
|
||||
use PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\MethodDeclarationSniff;
|
||||
use PhpCsFixer\Fixer\Import\GlobalNamespaceImportFixer;
|
||||
use PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer;
|
||||
use PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer;
|
||||
use PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer;
|
||||
use PhpCsFixer\Fixer\Strict\StrictComparisonFixer;
|
||||
use SlevomatCodingStandard\Sniffs\Commenting\DisallowCommentAfterCodeSniff;
|
||||
use SlevomatCodingStandard\Sniffs\ControlStructures\AssignmentInConditionSniff;
|
||||
use SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff;
|
||||
use SlevomatCodingStandard\Sniffs\Variables\UnusedVariableSniff;
|
||||
use SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff;
|
||||
use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
|
||||
use Symplify\CodingStandard\Sniffs\Debug\CommentedOutCodeSniff;
|
||||
use Symplify\EasyCodingStandard\Configuration\Option;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
$services->set(DisallowCommentAfterCodeSniff::class);
|
||||
|
||||
$services->set(DuplicateSpacesSniff::class);
|
||||
|
||||
$services->set(GeneralPhpdocAnnotationRemoveFixer::class)
|
||||
->call('configure', [['annotations' => ['throws', 'author', 'package', 'group']]]);
|
||||
|
||||
$services->set(LineLengthFixer::class);
|
||||
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
||||
$parameters->set('paths', ['bin', 'src', 'packages', 'rules', 'tests', 'utils', 'compiler', 'config']);
|
||||
|
||||
$parameters->set('sets', ['psr12', 'php70', 'php71', 'symplify', 'common', 'clean-code']);
|
||||
|
||||
$parameters->set('exclude_paths', [
|
||||
'*/Source/*',
|
||||
'*/Fixture/*', '*/Expected/*',
|
||||
__DIR__ . '/packages/doctrine-annotation-generated/src/ConstantPreservingDocParser.php',
|
||||
__DIR__ . '/packages/doctrine-annotation-generated/src/ConstantPreservingAnnotationReader.php'
|
||||
]);
|
||||
|
||||
$parameters->set(Option::SKIP, [
|
||||
GlobalNamespaceImportFixer::class => null,
|
||||
MethodDeclarationSniff::class . '.Underscore' => null,
|
||||
PhpdocTypesFixer::class => [
|
||||
__DIR__ . '/rules/php74/src/Rector/Double/RealToFloatTypeCastRector.php'
|
||||
],
|
||||
AssignmentInConditionSniff::class . '.FoundInWhileCondition' => null,
|
||||
UnusedVariableSniff::class . '.' . UnusedVariableSniff::CODE_UNUSED_VARIABLE => [
|
||||
__DIR__ . '/rules/php-office/src/Rector/MethodCall/IncreaseColumnIndexRector.php'
|
||||
],
|
||||
CommentedOutCodeSniff::class . '.Found' => [
|
||||
__DIR__ . '/rules/php72/src/Rector/Each/ListEachRector.php',
|
||||
__DIR__ . '/rules/dead-code/src/Rector/ClassMethod/RemoveOverriddenValuesRector.php',
|
||||
__DIR__ . '/rules/php-spec-to-phpunit/src/Rector/MethodCall/PhpSpecPromisesToPHPUnitAssertRector.php',
|
||||
],
|
||||
PhpUnitStrictFixer::class => [
|
||||
__DIR__ . '/packages/better-php-doc-parser/tests/PhpDocInfo/PhpDocInfo/PhpDocInfoTest.php',
|
||||
__DIR__ . '/tests/PhpParser/Node/NodeFactoryTest.php',
|
||||
'*TypeResolverTest.php'
|
||||
],
|
||||
UnaryOperatorSpacesFixer::class => null,
|
||||
StrictComparisonFixer::class => [
|
||||
__DIR__ . '/packages/polyfill/src/ConditionEvaluator.php'
|
||||
],
|
||||
ReferenceUsedNamesOnlySniff::class . '.' . ReferenceUsedNamesOnlySniff::CODE_PARTIAL_USE => null,
|
||||
ReferenceUsedNamesOnlySniff::class . '.' . ReferenceUsedNamesOnlySniff::CODE_REFERENCE_VIA_FULLY_QUALIFIED_NAME => [
|
||||
__DIR__ . '/packages/better-php-doc-parser/src/PhpDocNodeFactory/Doctrine/Property_/DoctrineTargetEntityPhpDocNodeFactory.php',
|
||||
__DIR__ . '/packages/better-php-doc-parser/src/PhpDocNodeFactory/Doctrine/Property_/JoinTablePhpDocNodeFactory.php',
|
||||
__DIR__ . '/packages/better-php-doc-parser/src/PhpDocNodeFactory/Doctrine/Class_/TablePhpDocNodeFactory.php',
|
||||
__DIR__ . '/packages/better-php-doc-parser/src/PhpDocNodeFactory/JMS/JMSInjectPhpDocNodeFactory.php']]);
|
||||
|
||||
$parameters->set('line_ending', "\n");
|
||||
};
|
98
ecs.yaml
98
ecs.yaml
|
@ -1,98 +0,0 @@
|
|||
services:
|
||||
SlevomatCodingStandard\Sniffs\Commenting\DisallowCommentAfterCodeSniff: null
|
||||
SlevomatCodingStandard\Sniffs\Whitespaces\DuplicateSpacesSniff: null
|
||||
|
||||
PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer:
|
||||
calls:
|
||||
- ['configure', [{'annotations': ['throws', 'author', 'package', 'group']}]]
|
||||
|
||||
Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer: null
|
||||
|
||||
parameters:
|
||||
paths:
|
||||
- "bin"
|
||||
- "src"
|
||||
- "packages"
|
||||
- "rules"
|
||||
- "tests"
|
||||
- "utils"
|
||||
- "compiler"
|
||||
- "config"
|
||||
|
||||
sets:
|
||||
- "psr12"
|
||||
- "php70"
|
||||
- "php71"
|
||||
- "symplify"
|
||||
- "common"
|
||||
- "clean-code"
|
||||
|
||||
exclude_paths:
|
||||
# tests files
|
||||
- '*/Source/*'
|
||||
- '*/Fixture/*'
|
||||
- '*/Expected/*'
|
||||
# generated
|
||||
- 'packages/doctrine-annotation-generated/src/ConstantPreservingDocParser.php'
|
||||
- 'packages/doctrine-annotation-generated/src/ConstantPreservingAnnotationReader.php'
|
||||
|
||||
skip:
|
||||
# rather useless
|
||||
PhpCsFixer\Fixer\Import\GlobalNamespaceImportFixer: null
|
||||
Symplify\CodingStandard\Fixer\Php\ClassStringToClassConstantFixer: null
|
||||
|
||||
PHP_CodeSniffer\Standards\PSR2\Sniffs\Methods\MethodDeclarationSniff.Underscore: null
|
||||
Symplify\CodingStandard\Sniffs\Architecture\DuplicatedClassShortNameSniff: null
|
||||
|
||||
# run manually from time to time - performance demanding + not to bother user with it
|
||||
Symplify\CodingStandard\Fixer\Order\PropertyOrderByComplexityFixer: null
|
||||
Symplify\CodingStandard\Fixer\Order\PrivateMethodOrderByUseFixer: null
|
||||
|
||||
PhpCsFixer\Fixer\Phpdoc\PhpdocTypesFixer:
|
||||
- 'rules/php74/src/Rector/Double/RealToFloatTypeCastRector.php'
|
||||
|
||||
PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff.FoundInWhileCondition: null
|
||||
|
||||
SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff.MissingParameterTypeHint:
|
||||
# 3rd party parent code
|
||||
- 'src/DependencyInjection/Loader/TolerantRectorYamlFileLoader.php'
|
||||
- 'src/PhpParser/Printer/BetterStandardPrinter.php'
|
||||
- 'tests/AbstractContainerAwareTestCase.php'
|
||||
|
||||
SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff.MissingTraversableReturnTypeHintSpecification:
|
||||
# false positive
|
||||
- 'src/Testing/PHPUnit/AbstractRectorTestCase.php'
|
||||
|
||||
SlevomatCodingStandard\Sniffs\Variables\UnusedVariableSniff.UnusedVariable:
|
||||
- 'rules/php-office/src/Rector/MethodCall/IncreaseColumnIndexRector.php'
|
||||
|
||||
Symplify\CodingStandard\Sniffs\Debug\CommentedOutCodeSniff.Found:
|
||||
# notes
|
||||
- 'rules/php72/src/Rector/Each/ListEachRector.php'
|
||||
- 'rules/dead-code/src/Rector/ClassMethod/RemoveOverriddenValuesRector.php'
|
||||
- 'rules/php-spec-to-phpunit/src/Rector/MethodCall/PhpSpecPromisesToPHPUnitAssertRector.php'
|
||||
|
||||
PhpCsFixer\Fixer\PhpUnit\PhpUnitStrictFixer:
|
||||
- 'packages/better-php-doc-parser/tests/PhpDocInfo/PhpDocInfo/PhpDocInfoTest.php'
|
||||
# intentional "assertEquals()"
|
||||
- 'tests/PhpParser/Node/NodeFactoryTest.php'
|
||||
- '*TypeResolverTest.php'
|
||||
|
||||
# conflicts with "PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer"
|
||||
PhpCsFixer\Fixer\Operator\UnaryOperatorSpacesFixer: null
|
||||
|
||||
PhpCsFixer\Fixer\Strict\StrictComparisonFixer:
|
||||
# part of the comparison logic
|
||||
- 'packages/polyfill/src/ConditionEvaluator.php'
|
||||
|
||||
# often soo many cases that need manual attention → skip and resole in automated way
|
||||
SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff.PartialUse: null
|
||||
|
||||
SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff.ReferenceViaFullyQualifiedName:
|
||||
# special case for optional entity classes in refactored project
|
||||
- 'packages/better-php-doc-parser/src/PhpDocNodeFactory/Doctrine/Property_/DoctrineTargetEntityPhpDocNodeFactory.php'
|
||||
- 'packages/better-php-doc-parser/src/PhpDocNodeFactory/Doctrine/Property_/JoinTablePhpDocNodeFactory.php'
|
||||
- 'packages/better-php-doc-parser/src/PhpDocNodeFactory/Doctrine/Class_/TablePhpDocNodeFactory.php'
|
||||
- 'packages/better-php-doc-parser/src/PhpDocNodeFactory/JMS/JMSInjectPhpDocNodeFactory.php'
|
||||
|
||||
line_ending: "\n"
|
|
@ -64,10 +64,12 @@ final class ConditionEvaluator
|
|||
}
|
||||
|
||||
if ($binaryToVersionCompareCondition->getBinaryClass() === Equal::class) {
|
||||
// weak comparison on purpose
|
||||
return $binaryToVersionCompareCondition->getExpectedValue() == $versionCompareResult;
|
||||
}
|
||||
|
||||
if ($binaryToVersionCompareCondition->getBinaryClass() === NotEqual::class) {
|
||||
// weak comparison on purpose
|
||||
return $binaryToVersionCompareCondition->getExpectedValue() != $versionCompareResult;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user