function LintCommand::displayTxt
File
-
vendor/
symfony/ yaml/ Command/ LintCommand.php, line 161
Class
- LintCommand
- Validates YAML files syntax and outputs encountered errors.
Namespace
Symfony\Component\Yaml\CommandCode
private function displayTxt(SymfonyStyle $io, array $filesInfo, bool $errorAsGithubAnnotations = false) : int {
$countFiles = \count($filesInfo);
$erroredFiles = 0;
$suggestTagOption = false;
if ($errorAsGithubAnnotations) {
$githubReporter = new GithubActionReporter($io);
}
foreach ($filesInfo as $info) {
if ($info['valid'] && $this->displayCorrectFiles) {
$io->comment('<info>OK</info>' . ($info['file'] ? \sprintf(' in %s', $info['file']) : ''));
}
elseif (!$info['valid']) {
++$erroredFiles;
$io->text('<error> ERROR </error>' . ($info['file'] ? \sprintf(' in %s', $info['file']) : ''));
$io->text(\sprintf('<error> >> %s</error>', $info['message']));
if (str_contains($info['message'], 'PARSE_CUSTOM_TAGS')) {
$suggestTagOption = true;
}
if ($errorAsGithubAnnotations) {
$githubReporter->error($info['message'], $info['file'] ?? 'php://stdin', $info['line']);
}
}
}
if (0 === $erroredFiles) {
$io->success(\sprintf('All %d YAML files contain valid syntax.', $countFiles));
}
else {
$io->warning(\sprintf('%d YAML files have valid syntax and %d contain errors.%s', $countFiles - $erroredFiles, $erroredFiles, $suggestTagOption ? ' Use the --parse-tags option if you want parse custom tags.' : ''));
}
return min($erroredFiles, 1);
}