diff --git a/easy-coding-standard.neon b/easy-coding-standard.neon index c78cfa5ad25..9b985f054ce 100644 --- a/easy-coding-standard.neon +++ b/easy-coding-standard.neon @@ -5,11 +5,13 @@ includes: checkers: # Slevomat - - SlevomatCodingStandard\Sniffs\ControlStructures\DisallowEqualOperatorsSniff - SlevomatCodingStandard\Sniffs\ControlStructures\YodaComparisonSniff - SlevomatCodingStandard\Sniffs\Exceptions\DeadCatchSniff - SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff - - SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff + SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff: + allowPartialUses: false + allowFullyQualifiedNameForCollidingClasses: false + allowFullyQualifiedGlobalClasses: true - SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff # Files @@ -22,9 +24,9 @@ checkers: # Code Analysis - PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff: - absoluteComplexity: 10 + absoluteComplexity: 5 PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\NestingLevelSniff: - absoluteNestingLevel: 5 + absoluteNestingLevel: 2 # Naming Conventions - PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff @@ -43,13 +45,10 @@ checkers: PhpCsFixer\Fixer\Operator\ConcatSpaceFixer: spacing: one - PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer - - PhpCsFixer\Fixer\LanguageConstruct\DirConstantFixer - - PhpCsFixer\Fixer\CastNotation\ModernizeTypesCastingFixer - PhpCsFixer\Fixer\Semicolon\SemicolonAfterInstructionFixer - PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer - PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer - PhpCsFixer\Fixer\ReturnNotation\NoUselessReturnFixer - - PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveUnsetsFixer - PhpCsFixer\Fixer\Strict\StrictComparisonFixer PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer: annotations: @@ -62,7 +61,8 @@ checkers: # new since PhpCsFixer 2.2-2.4 - PhpCsFixer\Fixer\Phpdoc\PhpdocReturnSelfReferenceFixer - - PhpCsFixer\Fixer\LanguageConstruct\IsNullFixer + PhpCsFixer\Fixer\LanguageConstruct\IsNullFixer: + use_yoda_style: false - PhpCsFixer\Fixer\Basic\NonPrintableCharacterFixer - PhpCsFixer\Fixer\Phpdoc\PhpdocTypesOrderFixer - PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer \ No newline at end of file diff --git a/src/NodeVisitor/DependencyInjection/NamedServicesToConstructor/GetterToPropertyNodeVisitor.php b/src/NodeVisitor/DependencyInjection/NamedServicesToConstructor/GetterToPropertyNodeVisitor.php index caaf9e7c573..18384bd4c7f 100644 --- a/src/NodeVisitor/DependencyInjection/NamedServicesToConstructor/GetterToPropertyNodeVisitor.php +++ b/src/NodeVisitor/DependencyInjection/NamedServicesToConstructor/GetterToPropertyNodeVisitor.php @@ -8,6 +8,7 @@ use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Expr\PropertyFetch; use PhpParser\Node\Expr\Variable; use PhpParser\Node\Scalar\String_; +use PhpParser\Node\Stmt\Class_; use PhpParser\NodeVisitorAbstract; use Rector\Builder\Class_\ClassPropertyCollector; use Rector\Builder\Kernel\ServiceFromKernelResolver; @@ -60,7 +61,7 @@ final class GetterToPropertyNodeVisitor extends NodeVisitorAbstract public function beforeTraverse(array $nodes): ?array { foreach ($nodes as $node) { - if ($node instanceof Node\Stmt\Class_) { + if ($node instanceof Class_) { $this->className = (string) $node->name; } } @@ -96,11 +97,9 @@ final class GetterToPropertyNodeVisitor extends NodeVisitorAbstract { // $var = $this->get('some_service'); // $var = $this->get('some_service')->getData(); - if ($node instanceof Assign) { - if ($node->expr instanceof MethodCall || $node->var instanceof MethodCall) { - if ($this->isContainerGetCall($node->expr)) { - return true; - } + if ($node instanceof Assign && ($node->expr instanceof MethodCall || $node->var instanceof MethodCall)) { + if ($this->isContainerGetCall($node->expr)) { + return true; } } diff --git a/src/NodeVisitor/UpgradeDeprecation/DeprecatedParentClassToTraitNodeVisitor.php b/src/NodeVisitor/UpgradeDeprecation/DeprecatedParentClassToTraitNodeVisitor.php index fd062c67484..2a4c9c214e1 100644 --- a/src/NodeVisitor/UpgradeDeprecation/DeprecatedParentClassToTraitNodeVisitor.php +++ b/src/NodeVisitor/UpgradeDeprecation/DeprecatedParentClassToTraitNodeVisitor.php @@ -4,6 +4,7 @@ namespace Rector\NodeVisitor\UpgradeDeprecation; use PhpParser\Node; use PhpParser\Node\Name\FullyQualified; +use PhpParser\Node\Stmt\Class_; use PhpParser\Node\Stmt\TraitUse; use PhpParser\NodeTraverser; use PhpParser\NodeVisitorAbstract; @@ -35,7 +36,7 @@ final class DeprecatedParentClassToTraitNodeVisitor extends NodeVisitorAbstract private function isCandidate(Node $node): bool { - if ($node instanceof Node\Stmt\Class_) { + if ($node instanceof Class_) { if (! $node->extends) { return false; } @@ -51,7 +52,7 @@ final class DeprecatedParentClassToTraitNodeVisitor extends NodeVisitorAbstract return false; } - private function refactor(Node\Stmt\Class_ $classNode): void + private function refactor(Class_ $classNode): void { // remove parent class $classNode->extends = null;