상속: extends Doctrine\Common\Collections\ArrayCollection
예제 #1
0
 /**
  * @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;
 }
예제 #2
0
 /**
  * @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;
 }
예제 #3
0
 /**
  * @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;
 }
예제 #4
0
 /**
  * @param LintErrorsCollection $errors
  *
  * @return array
  */
 private function collectXmlErrors(LintErrorsCollection $errors)
 {
     foreach (libxml_get_errors() as $error) {
         $errors->add(XmlLintError::fromLibXmlError($error));
     }
     $this->flushXmlErrors();
 }