Skip to content

Commit 7ea7ce4

Browse files
committed
Cleanup thanks to maybe certainty for variables in root scope
1 parent 1567d0f commit 7ea7ce4

2 files changed

Lines changed: 5 additions & 14 deletions

File tree

src/Rules/PhpDoc/WrongVariableNameInVarTagRule.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,10 +281,6 @@ private function processStmt(Scope $scope, array $varTags, ?Expr $defaultExpr):
281281
continue;
282282
}
283283

284-
if ($scope->getFunction() === null && !$scope->isInAnonymousFunction()) {
285-
continue;
286-
}
287-
288284
$errors[] = RuleErrorBuilder::message(sprintf('Variable $%s in PHPDoc tag @var does not exist.', $name))->build();
289285
}
290286

src/Rules/Variables/VariableCertaintyNullCoalesceRule.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,11 @@ public function processNode(Node $node, Scope $scope): array
5353

5454
$certainty = $scope->hasVariableType($var->name);
5555
if ($certainty->no()) {
56-
if (
57-
$scope->getFunction() !== null
58-
|| $scope->isInAnonymousFunction()
59-
) {
60-
return [RuleErrorBuilder::message(sprintf(
61-
'Variable $%s on left side of %s is never defined.',
62-
$var->name,
63-
$description
64-
))->build()];
65-
}
56+
return [RuleErrorBuilder::message(sprintf(
57+
'Variable $%s on left side of %s is never defined.',
58+
$var->name,
59+
$description
60+
))->build()];
6661
} elseif ($certainty->yes() && !$isSubNode) {
6762
$variableType = $scope->getVariableType($var->name);
6863
if ($variableType->isSuperTypeOf(new NullType())->no()) {

0 commit comments

Comments
 (0)