diff --git a/src/Analyser/NodeScopeResolver.php b/src/Analyser/NodeScopeResolver.php index 54ed793d30..c5d4bb96f2 100644 --- a/src/Analyser/NodeScopeResolver.php +++ b/src/Analyser/NodeScopeResolver.php @@ -1910,7 +1910,7 @@ private function processStmtNode( continue; } - foreach ($catchTypes as $catchTypeIndex => $catchTypeItem) { + foreach ($catchTypes as $catchTypeItem) { if ($catchTypeItem->isSuperTypeOf($throwPoint->getType())->no()) { continue; } @@ -6393,7 +6393,7 @@ private function processAssignVar( $throwPoints = array_merge($throwPoints, $keyResult->getThrowPoints()); $impurePoints = array_merge($impurePoints, $keyResult->getImpurePoints()); $isAlwaysTerminating = $isAlwaysTerminating || $keyResult->isAlwaysTerminating(); - $itemScope = $keyResult->getScope(); + // no need for $keyResult->getScope() } if ($arrayItem->key === null) { diff --git a/src/PhpDoc/StubValidator.php b/src/PhpDoc/StubValidator.php index ca40efdecd..2b57559ca3 100644 --- a/src/PhpDoc/StubValidator.php +++ b/src/PhpDoc/StubValidator.php @@ -133,7 +133,7 @@ public function validate(array $stubFiles, bool $debug): array ]); $ruleRegistry = $this->getRuleRegistry($container); - $collectorRegistry = $this->getCollectorRegistry($container); + $collectorRegistry = $this->getCollectorRegistry(); $fileAnalyser = $container->getByType(FileAnalyser::class); @@ -293,7 +293,7 @@ private function getRuleRegistry(Container $container): RuleRegistry return new DirectRuleRegistry($rules); } - private function getCollectorRegistry(Container $container): CollectorRegistry + private function getCollectorRegistry(): CollectorRegistry { return new CollectorRegistry([]); } diff --git a/src/Rules/PhpDoc/WrongVariableNameInVarTagRule.php b/src/Rules/PhpDoc/WrongVariableNameInVarTagRule.php index a517f4e38e..ddfe1ff7e1 100644 --- a/src/Rules/PhpDoc/WrongVariableNameInVarTagRule.php +++ b/src/Rules/PhpDoc/WrongVariableNameInVarTagRule.php @@ -101,7 +101,7 @@ public function processNode(Node $node, Scope $scope): array } if ($node instanceof Node\Stmt\Global_) { - return $this->processGlobal($scope, $node, $varTags); + return $this->processGlobal($node, $varTags); } if ($node instanceof InClassNode || $node instanceof InClassMethodNode || $node instanceof InFunctionNode) { @@ -372,7 +372,7 @@ private function processStmt(Scope $scope, array $varTags, ?Expr $defaultExpr): * @param VarTag[] $varTags * @return list */ - private function processGlobal(Scope $scope, Node\Stmt\Global_ $node, array $varTags): array + private function processGlobal(Node\Stmt\Global_ $node, array $varTags): array { $variableNames = []; foreach ($node->vars as $var) { diff --git a/src/Type/Php/StatDynamicReturnTypeExtension.php b/src/Type/Php/StatDynamicReturnTypeExtension.php index b4dcd8bb7e..7f1d3367a3 100644 --- a/src/Type/Php/StatDynamicReturnTypeExtension.php +++ b/src/Type/Php/StatDynamicReturnTypeExtension.php @@ -17,6 +17,7 @@ use PHPStan\Type\Type; use PHPStan\Type\TypeCombinator; use SplFileObject; +use function count; use function in_array; #[AutowiredService] @@ -68,7 +69,7 @@ private function getReturnType(): Type 'blocks', ]; - foreach ($keys as $key) { + for ($i = 0; $i < count($keys); $i++) { $builder->setOffsetValueType(null, $valueType); } diff --git a/tests/PHPStan/Rules/Methods/data/uppercase-string.php b/tests/PHPStan/Rules/Methods/data/uppercase-string.php index de7500ee8c..628fd20dbd 100644 --- a/tests/PHPStan/Rules/Methods/data/uppercase-string.php +++ b/tests/PHPStan/Rules/Methods/data/uppercase-string.php @@ -28,6 +28,6 @@ public function test( $this->acceptUppercaseString($string); $this->acceptUppercaseString($uppercaseString); $this->acceptUppercaseString($numericString); - $this->acceptUppercaseString($nonEmptyLowercaseString); + $this->acceptUppercaseString($nonEmptyUppercaseString); } }