Skip to content

Commit

Permalink
Error identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Sep 28, 2023
1 parent 6a0cefe commit ce3c258
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/Rules/Symfony/ContainerInterfacePrivateServiceRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function processNode(Node $node, Scope $scope): array
if ($service !== null && !$service->isPublic()) {
return [
RuleErrorBuilder::message(sprintf('Service "%s" is private.', $serviceId))
->identifier('symfonyContainer.privateService')
->build(),
];
}
Expand Down
4 changes: 3 additions & 1 deletion src/Rules/Symfony/ContainerInterfaceUnknownServiceRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public function processNode(Node $node, Scope $scope): array
$serviceIdType = $scope->getType($node->getArgs()[0]->value);
if ($service === null && !$scope->getType(Helper::createMarkerNode($node->var, $serviceIdType, $this->printer))->equals($serviceIdType)) {
return [
RuleErrorBuilder::message(sprintf('Service "%s" is not registered in the container.', $serviceId))->build(),
RuleErrorBuilder::message(sprintf('Service "%s" is not registered in the container.', $serviceId))
->identifier('symfonyContainer.serviceNotFound')
->build(),
];
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Rules/Symfony/InvalidArgumentDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function processNode(Node $node, Scope $scope): array
RuleErrorBuilder::message(sprintf(
'Parameter #4 $default of method Symfony\Component\Console\Command\Command::addArgument() expects string|null, %s given.',
$defaultType->describe(VerbosityLevel::typeOnly())
))->build(),
))->identifier('argument.type')->build(),
];
}

Expand All @@ -73,7 +73,7 @@ public function processNode(Node $node, Scope $scope): array
RuleErrorBuilder::message(sprintf(
'Parameter #4 $default of method Symfony\Component\Console\Command\Command::addArgument() expects array<int, string>|null, %s given.',
$defaultType->describe(VerbosityLevel::typeOnly())
))->build(),
))->identifier('argument.type')->build(),
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Rules/Symfony/InvalidOptionDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function processNode(Node $node, Scope $scope): array
'Parameter #5 $default of method Symfony\Component\Console\Command\Command::addOption() expects %s, %s given.',
$checkType->describe(VerbosityLevel::typeOnly()),
$defaultType->describe(VerbosityLevel::typeOnly())
))->build(),
))->identifier('argument.type')->build(),
];
}
}
Expand All @@ -79,7 +79,7 @@ public function processNode(Node $node, Scope $scope): array
RuleErrorBuilder::message(sprintf(
'Parameter #5 $default of method Symfony\Component\Console\Command\Command::addOption() expects array<string>|null, %s given.',
$defaultType->describe(VerbosityLevel::typeOnly())
))->build(),
))->identifier('argument.type')->build(),
];
}

Expand Down
4 changes: 3 additions & 1 deletion src/Rules/Symfony/UndefinedArgumentRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ public function processNode(Node $node, Scope $scope): array
if ($scope->getType(Helper::createMarkerNode($node->var, $argType, $this->printer))->equals($argType)) {
continue;
}
$errors[] = RuleErrorBuilder::message(sprintf('Command "%s" does not define argument "%s".', $name, $argName))->build();
$errors[] = RuleErrorBuilder::message(sprintf('Command "%s" does not define argument "%s".', $name, $argName))
->identifier('symfonyConsole.argumentNotFound')
->build();
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/Rules/Symfony/UndefinedOptionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ public function processNode(Node $node, Scope $scope): array
if ($scope->getType(Helper::createMarkerNode($node->var, $optType, $this->printer))->equals($optType)) {
continue;
}
$errors[] = RuleErrorBuilder::message(sprintf('Command "%s" does not define option "%s".', $name, $optName))->build();
$errors[] = RuleErrorBuilder::message(sprintf('Command "%s" does not define option "%s".', $name, $optName))
->identifier('symfonyConsole.optionNotFound')
->build();
}
}

Expand Down

0 comments on commit ce3c258

Please sign in to comment.