addRule(new ImgAltText()); $scanner->addRule(new FormLabel()); $scanner->addRule(new HtmlHasLang()); $scanner->addRule(new EmptyLink()); $violations = $scanner->scan($html); if (!empty($violations)) { // Locate Sources $locator = new SourceLocator(__DIR__ . '/views-fixed'); foreach ($violations as $violation) { $location = $locator->locate($violation->snippet); if ($location) { $violation->setSourceLocation($location['file'], $location['line']); } } $reporter = new HtmlReporter(); // Enable success widget for this demo $reporter->setShowSuccess(true); $reportHtml = $reporter->render($violations); $html = str_replace('', $reportHtml . '', $html); } else { // Violations is empty, but render() will return the success widget because we set it to true $reporter = new HtmlReporter(); $reporter->setShowSuccess(true); $reportHtml = $reporter->render($violations); $html = str_replace('', $reportHtml . '', $html); } echo $html;