hasAttribute('aria-roledescription')) { return null; } $desc = trim($element->getAttribute('aria-roledescription')); if ($desc === '') { return $this->createViolation( $element, "Attribute aria-roledescription is empty or contains only whitespace.", "Provide a meaningful description or remove the aria-roledescription attribute." ); } $role = strtolower(trim($element->getAttribute('role'))); if ($role === 'presentation' || $role === 'none' || $role === 'generic') { return $this->createViolation( $element, "aria-roledescription must not be used on elements with role=\"{$role}\".", "Remove aria-roledescription from presentation/generic elements, or provide an appropriate semantic ARIA role." ); } $tagName = strtolower($element->tagName); if ($role === '' && in_array($tagName, ['div', 'span'], true)) { return $this->createViolation( $element, "aria-roledescription is used on a generic <{$tagName}> element without an explicit ARIA role.", "Add an explicit ARIA role (e.g. role=\"region\", role=\"button\") or use a semantic HTML element." ); } return null; } }