feat: add 15 new WCAG rules, dynamic ARIA checks and bump version to v3.1.4

This commit is contained in:
Enes Yakıştır
2026-07-30 20:34:41 +03:00
parent 164828f9f7
commit 58b1618d96
31 changed files with 1138 additions and 1 deletions
+41
View File
@@ -0,0 +1,41 @@
<?php
namespace YakNet\AccessibilityConsole\Rules;
use DOMElement;
use YakNet\AccessibilityConsole\Core\Severity;
use YakNet\AccessibilityConsole\Core\Violation;
use YakNet\AccessibilityConsole\Core\WCAGStandard;
class TableMultiCaption extends AbstractRule
{
public function getId(): string { return 'WCAG_1_3_1_TABLE_MULTI_CAPTION'; }
public function getDescription(): string { return 'A <table> element must not contain more than one <caption> element.'; }
public function getStandard(): WCAGStandard { return WCAGStandard::A; }
public function getSeverity(): Severity { return Severity::ERROR; }
public function getLevel(): int { return 2; }
public function check(DOMElement $element): ?Violation
{
if (strtolower($element->tagName) !== 'table') {
return null;
}
$captionCount = 0;
foreach ($element->childNodes as $child) {
if ($child instanceof DOMElement && strtolower($child->tagName) === 'caption') {
$captionCount++;
}
}
if ($captionCount > 1) {
return $this->createViolation(
$element,
$this->getDescription(),
'Remove duplicate <caption> elements so that the table has at most one caption.'
);
}
return null;
}
}