From f7dfbc7508521e8a597c5abac22562fba27faf99 Mon Sep 17 00:00:00 2001 From: TomasVotruba <924196+TomasVotruba@users.noreply.github.com> Date: Sun, 24 Aug 2025 00:38:53 +0000 Subject: [PATCH] [automated] Apply Coding Standard --- .../Class_/ConvertStaticToSelfRector.php | 7 ++-- .../Switch_/ColonAfterSwitchCaseRector.php | 2 +- ...pFuncCallWithPhpVersionIdCheckerRector.php | 2 +- ...ocblockForScalarArrayFromAssignsRector.php | 34 ++++++++++--------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php b/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php index 7d256c9b881..217cf69d72a 100644 --- a/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php +++ b/rules/CodeQuality/Rector/Class_/ConvertStaticToSelfRector.php @@ -4,8 +4,6 @@ namespace Rector\CodeQuality\Rector\Class_; -use PHPStan\Analyser\Scope; -use PHPStan\Reflection\ClassConstantReflection; use PhpParser\Node; use PhpParser\Node\Expr\ClassConstFetch; use PhpParser\Node\Expr\StaticCall; @@ -13,6 +11,8 @@ use PhpParser\Node\Identifier; use PhpParser\Node\Name; use PhpParser\Node\Stmt\Class_; +use PHPStan\Analyser\Scope; +use PHPStan\Reflection\ClassConstantReflection; use PHPStan\Reflection\ClassReflection; use Rector\Configuration\Parameter\FeatureFlags; use Rector\Enum\ObjectReference; @@ -165,7 +165,8 @@ private function shouldSkip( if (! $isFinal) { $memberIsFinal = $reflection instanceof ClassConstantReflection ? $reflection->isFinal() - : $reflection->isFinalByKeyword()->yes(); + : $reflection->isFinalByKeyword() + ->yes(); // Final native members can be safely converted if ($memberIsFinal) { diff --git a/rules/Php85/Rector/Switch_/ColonAfterSwitchCaseRector.php b/rules/Php85/Rector/Switch_/ColonAfterSwitchCaseRector.php index 02a7dfbe389..910f961640e 100644 --- a/rules/Php85/Rector/Switch_/ColonAfterSwitchCaseRector.php +++ b/rules/Php85/Rector/Switch_/ColonAfterSwitchCaseRector.php @@ -66,7 +66,7 @@ public function refactor(Node $node): ?Node } if (count($case->stmts) === 0) { - $startCaseStmtsPos = isset($node->cases[$key + 1]) + $startCaseStmtsPos = isset($node->cases[$key + 1]) ? $node->cases[$key + 1]->getStartTokenPos() : $node->getEndTokenPos(); } else { diff --git a/rules/Transform/Rector/FuncCall/WrapFuncCallWithPhpVersionIdCheckerRector.php b/rules/Transform/Rector/FuncCall/WrapFuncCallWithPhpVersionIdCheckerRector.php index 87c289f37b9..753e70f7054 100644 --- a/rules/Transform/Rector/FuncCall/WrapFuncCallWithPhpVersionIdCheckerRector.php +++ b/rules/Transform/Rector/FuncCall/WrapFuncCallWithPhpVersionIdCheckerRector.php @@ -132,7 +132,7 @@ private function isWrappedFuncCall(StmtsAwareInterface $stmtsAware): bool } $phpVersionId = $this->getPhpVersionId($stmtsAware->cond); - if (!$phpVersionId instanceof Int_) { + if (! $phpVersionId instanceof Int_) { return false; } diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddReturnDocblockForScalarArrayFromAssignsRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddReturnDocblockForScalarArrayFromAssignsRector.php index 86d7438c6f0..8e4a05e1fc2 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddReturnDocblockForScalarArrayFromAssignsRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddReturnDocblockForScalarArrayFromAssignsRector.php @@ -5,30 +5,30 @@ namespace Rector\TypeDeclaration\Rector\ClassMethod; use PhpParser\Node; -use PHPStan\Type\Type; use PhpParser\Node\Expr; -use PHPStan\Type\ArrayType; -use PHPStan\Type\FloatType; -use PHPStan\Type\MixedType; -use PHPStan\Type\StringType; -use PHPStan\Type\IntegerType; use PhpParser\Node\Expr\Array_; +use PhpParser\Node\Expr\ArrayDimFetch; use PhpParser\Node\Expr\Assign; -use PhpParser\Node\Scalar\Int_; -use PhpParser\Node\Stmt\Return_; use PhpParser\Node\Expr\Variable; -use Rector\Rector\AbstractRector; use PhpParser\Node\Scalar\DNumber; +use PhpParser\Node\Scalar\Int_; use PhpParser\Node\Scalar\String_; -use PhpParser\Node\Stmt\Function_; use PhpParser\Node\Stmt\ClassMethod; -use PhpParser\Node\Expr\ArrayDimFetch; +use PhpParser\Node\Stmt\Function_; +use PhpParser\Node\Stmt\Return_; +use PHPStan\Type\ArrayType; +use PHPStan\Type\FloatType; +use PHPStan\Type\IntegerType; +use PHPStan\Type\MixedType; +use PHPStan\Type\StringType; +use PHPStan\Type\Type; +use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; +use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; use Rector\PhpParser\Node\BetterNodeFinder; +use Rector\Rector\AbstractRector; use Rector\TypeDeclaration\NodeAnalyzer\ReturnAnalyzer; -use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; -use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; -use Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger; +use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** * @see \Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddReturnDocblockForScalarArrayFromAssignsRector\AddReturnDocblockForScalarArrayFromAssignsRectorTest @@ -123,7 +123,6 @@ public function refactor(Node $node): ?Node $returnsScoped = $this->betterNodeFinder->findReturnsScoped($node); - if (! $this->returnAnalyzer->hasOnlyReturnWithExpr($node, $returnsScoped)) { return null; } @@ -191,7 +190,10 @@ private function resolveScalarArrayTypeForVariable(ClassMethod|Function_ $node, $arrayHasDimAssigns = false; foreach ($assigns as $assign) { - if ($assign->var instanceof Variable && $this->isName($assign->var, $variableName) && ($assign->expr instanceof Array_ && $assign->expr->items === [])) { + if ($assign->var instanceof Variable && $this->isName( + $assign->var, + $variableName + ) && ($assign->expr instanceof Array_ && $assign->expr->items === [])) { $arrayHasInitialized = true; continue; }