mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 08:50:50 +00:00
cs fixes
This commit is contained in:
parent
92400e8a0d
commit
5d7c589533
|
@ -5,11 +5,13 @@ includes:
|
||||||
|
|
||||||
checkers:
|
checkers:
|
||||||
# Slevomat
|
# Slevomat
|
||||||
- SlevomatCodingStandard\Sniffs\ControlStructures\DisallowEqualOperatorsSniff
|
|
||||||
- SlevomatCodingStandard\Sniffs\ControlStructures\YodaComparisonSniff
|
- SlevomatCodingStandard\Sniffs\ControlStructures\YodaComparisonSniff
|
||||||
- SlevomatCodingStandard\Sniffs\Exceptions\DeadCatchSniff
|
- SlevomatCodingStandard\Sniffs\Exceptions\DeadCatchSniff
|
||||||
- SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff
|
- SlevomatCodingStandard\Sniffs\Exceptions\ReferenceThrowableOnlySniff
|
||||||
- SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff
|
SlevomatCodingStandard\Sniffs\Namespaces\ReferenceUsedNamesOnlySniff:
|
||||||
|
allowPartialUses: false
|
||||||
|
allowFullyQualifiedNameForCollidingClasses: false
|
||||||
|
allowFullyQualifiedGlobalClasses: true
|
||||||
- SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff
|
- SlevomatCodingStandard\Sniffs\Classes\UnusedPrivateElementsSniff
|
||||||
|
|
||||||
# Files
|
# Files
|
||||||
|
@ -22,9 +24,9 @@ checkers:
|
||||||
# Code Analysis
|
# Code Analysis
|
||||||
- PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff
|
- PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\EmptyStatementSniff
|
||||||
PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff:
|
PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff:
|
||||||
absoluteComplexity: 10
|
absoluteComplexity: 5
|
||||||
PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\NestingLevelSniff:
|
PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\NestingLevelSniff:
|
||||||
absoluteNestingLevel: 5
|
absoluteNestingLevel: 2
|
||||||
|
|
||||||
# Naming Conventions
|
# Naming Conventions
|
||||||
- PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff
|
- PHP_CodeSniffer\Standards\Generic\Sniffs\NamingConventions\CamelCapsFunctionNameSniff
|
||||||
|
@ -43,13 +45,10 @@ checkers:
|
||||||
PhpCsFixer\Fixer\Operator\ConcatSpaceFixer:
|
PhpCsFixer\Fixer\Operator\ConcatSpaceFixer:
|
||||||
spacing: one
|
spacing: one
|
||||||
- PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer
|
- PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer
|
||||||
- PhpCsFixer\Fixer\LanguageConstruct\DirConstantFixer
|
|
||||||
- PhpCsFixer\Fixer\CastNotation\ModernizeTypesCastingFixer
|
|
||||||
- PhpCsFixer\Fixer\Semicolon\SemicolonAfterInstructionFixer
|
- PhpCsFixer\Fixer\Semicolon\SemicolonAfterInstructionFixer
|
||||||
- PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer
|
- PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer
|
||||||
- PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer
|
- PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer
|
||||||
- PhpCsFixer\Fixer\ReturnNotation\NoUselessReturnFixer
|
- PhpCsFixer\Fixer\ReturnNotation\NoUselessReturnFixer
|
||||||
- PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveUnsetsFixer
|
|
||||||
- PhpCsFixer\Fixer\Strict\StrictComparisonFixer
|
- PhpCsFixer\Fixer\Strict\StrictComparisonFixer
|
||||||
PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer:
|
PhpCsFixer\Fixer\Phpdoc\GeneralPhpdocAnnotationRemoveFixer:
|
||||||
annotations:
|
annotations:
|
||||||
|
@ -62,7 +61,8 @@ checkers:
|
||||||
|
|
||||||
# new since PhpCsFixer 2.2-2.4
|
# new since PhpCsFixer 2.2-2.4
|
||||||
- PhpCsFixer\Fixer\Phpdoc\PhpdocReturnSelfReferenceFixer
|
- PhpCsFixer\Fixer\Phpdoc\PhpdocReturnSelfReferenceFixer
|
||||||
- PhpCsFixer\Fixer\LanguageConstruct\IsNullFixer
|
PhpCsFixer\Fixer\LanguageConstruct\IsNullFixer:
|
||||||
|
use_yoda_style: false
|
||||||
- PhpCsFixer\Fixer\Basic\NonPrintableCharacterFixer
|
- PhpCsFixer\Fixer\Basic\NonPrintableCharacterFixer
|
||||||
- PhpCsFixer\Fixer\Phpdoc\PhpdocTypesOrderFixer
|
- PhpCsFixer\Fixer\Phpdoc\PhpdocTypesOrderFixer
|
||||||
- PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer
|
- PhpCsFixer\Fixer\Comment\SingleLineCommentStyleFixer
|
|
@ -8,6 +8,7 @@ use PhpParser\Node\Expr\MethodCall;
|
||||||
use PhpParser\Node\Expr\PropertyFetch;
|
use PhpParser\Node\Expr\PropertyFetch;
|
||||||
use PhpParser\Node\Expr\Variable;
|
use PhpParser\Node\Expr\Variable;
|
||||||
use PhpParser\Node\Scalar\String_;
|
use PhpParser\Node\Scalar\String_;
|
||||||
|
use PhpParser\Node\Stmt\Class_;
|
||||||
use PhpParser\NodeVisitorAbstract;
|
use PhpParser\NodeVisitorAbstract;
|
||||||
use Rector\Builder\Class_\ClassPropertyCollector;
|
use Rector\Builder\Class_\ClassPropertyCollector;
|
||||||
use Rector\Builder\Kernel\ServiceFromKernelResolver;
|
use Rector\Builder\Kernel\ServiceFromKernelResolver;
|
||||||
|
@ -60,7 +61,7 @@ final class GetterToPropertyNodeVisitor extends NodeVisitorAbstract
|
||||||
public function beforeTraverse(array $nodes): ?array
|
public function beforeTraverse(array $nodes): ?array
|
||||||
{
|
{
|
||||||
foreach ($nodes as $node) {
|
foreach ($nodes as $node) {
|
||||||
if ($node instanceof Node\Stmt\Class_) {
|
if ($node instanceof Class_) {
|
||||||
$this->className = (string) $node->name;
|
$this->className = (string) $node->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,11 +97,9 @@ final class GetterToPropertyNodeVisitor extends NodeVisitorAbstract
|
||||||
{
|
{
|
||||||
// $var = $this->get('some_service');
|
// $var = $this->get('some_service');
|
||||||
// $var = $this->get('some_service')->getData();
|
// $var = $this->get('some_service')->getData();
|
||||||
if ($node instanceof Assign) {
|
if ($node instanceof Assign && ($node->expr instanceof MethodCall || $node->var instanceof MethodCall)) {
|
||||||
if ($node->expr instanceof MethodCall || $node->var instanceof MethodCall) {
|
if ($this->isContainerGetCall($node->expr)) {
|
||||||
if ($this->isContainerGetCall($node->expr)) {
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace Rector\NodeVisitor\UpgradeDeprecation;
|
||||||
|
|
||||||
use PhpParser\Node;
|
use PhpParser\Node;
|
||||||
use PhpParser\Node\Name\FullyQualified;
|
use PhpParser\Node\Name\FullyQualified;
|
||||||
|
use PhpParser\Node\Stmt\Class_;
|
||||||
use PhpParser\Node\Stmt\TraitUse;
|
use PhpParser\Node\Stmt\TraitUse;
|
||||||
use PhpParser\NodeTraverser;
|
use PhpParser\NodeTraverser;
|
||||||
use PhpParser\NodeVisitorAbstract;
|
use PhpParser\NodeVisitorAbstract;
|
||||||
|
@ -35,7 +36,7 @@ final class DeprecatedParentClassToTraitNodeVisitor extends NodeVisitorAbstract
|
||||||
|
|
||||||
private function isCandidate(Node $node): bool
|
private function isCandidate(Node $node): bool
|
||||||
{
|
{
|
||||||
if ($node instanceof Node\Stmt\Class_) {
|
if ($node instanceof Class_) {
|
||||||
if (! $node->extends) {
|
if (! $node->extends) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +52,7 @@ final class DeprecatedParentClassToTraitNodeVisitor extends NodeVisitorAbstract
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function refactor(Node\Stmt\Class_ $classNode): void
|
private function refactor(Class_ $classNode): void
|
||||||
{
|
{
|
||||||
// remove parent class
|
// remove parent class
|
||||||
$classNode->extends = null;
|
$classNode->extends = null;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user