Lines Matching +full:php +full:- +full:lint
1 <?php
34 protected static $defaultName = 'lint:yaml';
46 $this->directoryIteratorProvider = $directoryIteratorProvider;
47 $this->isReadableProvider = $isReadableProvider;
56 ->setDescription('Lints a file and outputs encountered errors')
57 ->addArgument('filename', InputArgument::IS_ARRAY, 'A file or a directory or STDIN')
58 ->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
59 ->addOption('parse-tags', null, InputOption::VALUE_NONE, 'Parse custom tags')
60 ->setHelp(<<<EOF
66 <info>cat filename | php %command.full_name%</info>
70 <info>php %command.full_name% filename</info>
74 <info>php %command.full_name% dirname</info>
75 <info>php %command.full_name% dirname --format=json</info>
85 $filenames = (array) $input->getArgument('filename');
86 $this->format = $input->getOption('format');
87 $this->displayCorrectFiles = $output->isVerbose();
88 $flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0;
91 if (!$stdin = $this->getStdin()) {
95 return $this->display($io, [$this->validate($stdin, $flags)]);
100 if (!$this->isReadable($filename)) {
104 foreach ($this->getFiles($filename) as $file) {
105 $filesInfo[] = $this->validate(file_get_contents($file), $flags, $file);
109 return $this->display($io, $filesInfo);
116 throw new ParseException($message, $this->getParser()->getRealCurrentLineNb() + 1);
123 $this->getParser()->parse($content, Yaml::PARSE_CONSTANT | $flags);
125 …return ['file' => $file, 'line' => $e->getParsedLine(), 'valid' => false, 'message' => $e->getMess…
135 switch ($this->format) {
137 return $this->displayTxt($io, $files);
139 return $this->displayJson($io, $files);
141 … throw new InvalidArgumentException(sprintf('The format "%s" is not supported.', $this->format));
151 if ($info['valid'] && $this->displayCorrectFiles) {
152 … $io->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
155 … $io->text('<error> ERROR </error>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
156 $io->text(sprintf('<error> >> %s</error>', $info['message']));
161 $io->success(sprintf('All %d YAML files contain valid syntax.', $countFiles));
163 …$io->warning(sprintf('%d YAML files have valid syntax and %d contain errors.', $countFiles - $erro…
180 $io->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
193 foreach ($this->getDirectoryIterator($fileOrDirectory) as $file) {
194 if (!\in_array($file->getExtension(), ['yml', 'yaml'])) {
218 if (!$this->parser) {
219 $this->parser = new Parser();
222 return $this->parser;
234 if (null !== $this->directoryIteratorProvider) {
235 return ($this->directoryIteratorProvider)($directory, $default);
247 if (null !== $this->isReadableProvider) {
248 return ($this->isReadableProvider)($fileOrDirectory, $default);