Lines Matching +full:php +full:- +full:lint
1 <?php
37 protected static $defaultName = 'lint:yaml';
38 protected static $defaultDescription = 'Lint a YAML file and outputs encountered errors';
50 $this->directoryIteratorProvider = $directoryIteratorProvider;
51 $this->isReadableProvider = $isReadableProvider;
60 ->setDescription(self::$defaultDescription)
61 …->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from ST…
62 ->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format')
63 …->addOption('exclude', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Path(s) t…
64 ->addOption('parse-tags', null, InputOption::VALUE_NEGATABLE, 'Parse custom tags', null)
65 ->setHelp(<<<EOF
71 <info>cat filename | php %command.full_name% -</info>
75 <info>php %command.full_name% filename</info>
79 <info>php %command.full_name% dirname</info>
80 <info>php %command.full_name% dirname --format=json</info>
84 …<info>php %command.full_name% dirname --exclude="dirname/foo.yaml" --exclude="dirname/bar.yaml"</i…
94 $filenames = (array) $input->getArgument('filename');
95 $excludes = $input->getOption('exclude');
96 $this->format = $input->getOption('format');
97 $flags = $input->getOption('parse-tags');
99 if ('github' === $this->format && !class_exists(GithubActionReporter::class)) {
103 if (null === $this->format) {
105 …$this->format = class_exists(GithubActionReporter::class) && GithubActionReporter::isGithubActionE…
110 $this->displayCorrectFiles = $output->isVerbose();
112 if (['-'] === $filenames) {
113 return $this->display($io, [$this->validate(file_get_contents('php://stdin'), $flags)]);
122 if (!$this->isReadable($filename)) {
126 foreach ($this->getFiles($filename) as $file) {
127 if (!\in_array($file->getPathname(), $excludes, true)) {
128 $filesInfo[] = $this->validate(file_get_contents($file), $flags, $file);
133 return $this->display($io, $filesInfo);
140 throw new ParseException($message, $this->getParser()->getRealCurrentLineNb() + 1);
147 $this->getParser()->parse($content, Yaml::PARSE_CONSTANT | $flags);
149 …return ['file' => $file, 'line' => $e->getParsedLine(), 'valid' => false, 'message' => $e->getMess…
159 switch ($this->format) {
161 return $this->displayTxt($io, $files);
163 return $this->displayJson($io, $files);
165 return $this->displayTxt($io, $files, true);
167 … throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $this->format));
182 if ($info['valid'] && $this->displayCorrectFiles) {
183 … $io->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
186 … $io->text('<error> ERROR </error>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
187 $io->text(sprintf('<error> >> %s</error>', $info['message']));
194 … $githubReporter->error($info['message'], $info['file'] ?? 'php://stdin', $info['line']);
200 $io->success(sprintf('All %d YAML files contain valid syntax.', $countFiles));
202 …->warning(sprintf('%d YAML files have valid syntax and %d contain errors.%s', $countFiles - $error…
219 $v['message'] .= ' Use the --parse-tags option if you want parse custom tags.';
223 $io->writeln(json_encode($filesInfo, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES));
236 foreach ($this->getDirectoryIterator($fileOrDirectory) as $file) {
237 if (!\in_array($file->getExtension(), ['yml', 'yaml'])) {
247 if (!$this->parser) {
248 $this->parser = new Parser();
251 return $this->parser;
263 if (null !== $this->directoryIteratorProvider) {
264 return ($this->directoryIteratorProvider)($directory, $default);
276 if (null !== $this->isReadableProvider) {
277 return ($this->isReadableProvider)($fileOrDirectory, $default);
285 if ($input->mustSuggestOptionValuesFor('format')) {
286 $suggestions->suggestValues(['txt', 'json', 'github']);