/** * @param SplFileInfo $file * * @return mixed * @throws \Seld\JsonLint\ParsingException */ public function lint(SplFileInfo $file) { $errors = new LintErrorsCollection(); $flags = $this->calculateFlags(); try { $json = $this->filesystem->readFromFileInfo($file); $this->jsonParser->parse($json, $flags); } catch (ParsingException $exception) { $errors->add(JsonLintError::fromParsingException($file, $exception)); } return $errors; }
/** * @param SplFileInfo $file * * @return mixed * @throws \Seld\JsonLint\ParsingException */ public function lint(SplFileInfo $file) { $parser = new JsonParser(); $errors = new LintErrorsCollection(); $flags = $this->calculateFlags(); try { $json = file_get_contents($file->getPathname()); $parser->parse($json, $flags); } catch (ParsingException $exception) { $errors->add(JsonLintError::fromParsingException($file, $exception)); } return $errors; }
/** * @param FilesCollection $files * * @return LintErrorsCollection */ protected function lint(FilesCollection $files) { $this->guardLinterIsInstalled(); // Skip ignored patterns: $configuration = $this->getConfiguration(); foreach ($configuration['ignore_patterns'] as $pattern) { $files = $files->notPath($pattern); } // Lint every file: $lintErrors = new LintErrorsCollection(); foreach ($files as $file) { foreach ($this->linter->lint($file) as $error) { $lintErrors->add($error); } } return $lintErrors; }
/** * @param LintErrorsCollection $errors * * @return array */ private function collectXmlErrors(LintErrorsCollection $errors) { foreach (libxml_get_errors() as $error) { $errors->add(XmlLintError::fromLibXmlError($error)); } $this->flushXmlErrors(); }