Skip to content

Commit

Permalink
DefinedVariableRule - identifiers and metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 18, 2020
1 parent f96d159 commit d615508
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Rules/Variables/DefinedVariableRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,24 @@ public function processNode(Node $node, Scope $scope): array

if ($scope->hasVariableType($node->name)->no()) {
return [
RuleErrorBuilder::message(sprintf('Undefined variable: $%s', $node->name))->build(),
RuleErrorBuilder::message(sprintf('Undefined variable: $%s', $node->name))
->identifier('variable.undefined')
->metadata([
'variableName' => $node->name,
])
->build(),
];
} elseif (
$this->checkMaybeUndefinedVariables
&& !$scope->hasVariableType($node->name)->yes()
) {
return [
RuleErrorBuilder::message(sprintf('Variable $%s might not be defined.', $node->name))->build(),
RuleErrorBuilder::message(sprintf('Variable $%s might not be defined.', $node->name))
->identifier('variable.maybeUndefined')
->metadata([
'variableName' => $node->name,
])
->build(),
];
}

Expand Down

0 comments on commit d615508

Please sign in to comment.