query('//*[@id]'); if ($elements === false) { return []; } $ids = []; foreach ($elements as $el) { if (!$el instanceof \DOMElement) { continue; } $id = $el->getAttribute('id'); if ($id === '') { continue; } if (!isset($ids[$id])) { $ids[$id] = []; } $ids[$id][] = $el; } foreach ($ids as $id => $elementsWithId) { if (count($elementsWithId) > 1) { foreach ($elementsWithId as $el) { $violations[] = $this->createViolation( "Duplicate ID \"{$id}\" found. Element ID attribute must be unique across the document.", $el ); } } } return $violations; } public function getStandard(): WCAGStandard { return WCAGStandard::A; } public function getSeverity(): Severity { return Severity::ERROR; } public function getLevel(): int { return 3; } }