Skip to content

Commit

Permalink
Cleanup thanks to maybe certainty for variables in root scope
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jun 20, 2020
1 parent 1567d0f commit 7ea7ce4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
4 changes: 0 additions & 4 deletions src/Rules/PhpDoc/WrongVariableNameInVarTagRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,6 @@ private function processStmt(Scope $scope, array $varTags, ?Expr $defaultExpr):
continue;
}

if ($scope->getFunction() === null && !$scope->isInAnonymousFunction()) {
continue;
}

$errors[] = RuleErrorBuilder::message(sprintf('Variable $%s in PHPDoc tag @var does not exist.', $name))->build();
}

Expand Down
15 changes: 5 additions & 10 deletions src/Rules/Variables/VariableCertaintyNullCoalesceRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,11 @@ public function processNode(Node $node, Scope $scope): array

$certainty = $scope->hasVariableType($var->name);
if ($certainty->no()) {
if (
$scope->getFunction() !== null
|| $scope->isInAnonymousFunction()
) {
return [RuleErrorBuilder::message(sprintf(
'Variable $%s on left side of %s is never defined.',
$var->name,
$description
))->build()];
}
return [RuleErrorBuilder::message(sprintf(
'Variable $%s on left side of %s is never defined.',
$var->name,
$description
))->build()];
} elseif ($certainty->yes() && !$isSubNode) {
$variableType = $scope->getVariableType($var->name);
if ($variableType->isSuperTypeOf(new NullType())->no()) {
Expand Down

0 comments on commit 7ea7ce4

Please sign in to comment.