mirror of https://github.com/rectorphp/rector.git
cs fixes
This commit is contained in:
parent
92400e8a0d
commit
5d7c589533
|
@ -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
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue