GrumPHP\Linter\Xml\XmlLinter::lint PHP Method

lint() public method

public lint ( SplFileInfo $file ) : LintErrorsCollection
$file SplFileInfo
return GrumPHP\Collection\LintErrorsCollection
    public function lint(SplFileInfo $file)
    {
        $errors = new LintErrorsCollection();
        $useInternalErrors = $this->useInternalXmlLoggin(true);
        $this->flushXmlErrors();
        $document = $this->loadDocument($file);
        if (!$document) {
            $this->collectXmlErrors($errors);
            $this->useInternalXmlLoggin($useInternalErrors);
            return $errors;
        }
        if ($this->xInclude && $document->xinclude() === -1) {
            $this->collectXmlErrors($errors);
        }
        if ($this->dtdValidation && !$this->validateDTD($document)) {
            $this->collectXmlErrors($errors);
        }
        if ($this->schemeValidation && !$this->validateInternalSchemes($file, $document)) {
            $this->collectXmlErrors($errors);
        }
        $this->useInternalXmlLoggin($useInternalErrors);
        return $errors;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @param string $fixture
  * @param int $errors
  */
 private function validateFixture($fixture, $errors)
 {
     $result = $this->linter->lint($this->getFixture($fixture));
     $this->assertInstanceOf('GrumPHP\\Collection\\LintErrorsCollection', $result);
     $this->assertEquals($result->count(), $errors, 'Invalid error-count expected.');
     if ($result->count()) {
         $this->assertInstanceOf('GrumPHP\\Linter\\Xml\\XmlLintError', $result[0]);
     }
 }
All Usage Examples Of GrumPHP\Linter\Xml\XmlLinter::lint