Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
101 lines
3.6 KiB
PHP
101 lines
3.6 KiB
PHP
<?php
|
||||
|
|
|
|||
|
|
namespace YakNet\AccessibilityConsole\Rules;
|
|||
|
|
|
|||
|
|
use DOMElement;
|
|||
|
|
use YakNet\AccessibilityConsole\Core\Severity;
|
|||
|
|
use YakNet\AccessibilityConsole\Core\Violation;
|
|||
|
|
use YakNet\AccessibilityConsole\Core\WCAGStandard;
|
|||
|
|
|
|||
|
|
class AriaRequiredParent extends AbstractRule
|
|||
|
|
{
|
|||
|
|
public function getId(): string { return 'WCAG_1_3_1_ARIA_REQUIRED_PARENT'; }
|
|||
|
|
public function getDescription(): string { return 'Elements with certain ARIA roles must be contained by parents with specific roles.'; }
|
|||
|
|
public function getStandard(): WCAGStandard { return WCAGStandard::A; }
|
|||
|
|
public function getSeverity(): Severity { return Severity::ERROR; }
|
|||
|
|
public function getLevel(): int { return 4; }
|
|||
|
|
|
|||
|
|
public function check(DOMElement $element): ?Violation
|
|||
|
|
{
|
|||
|
|
if (!$element->hasAttribute('role')) {
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$roles = explode(' ', strtolower(trim($element->getAttribute('role'))));
|
|||
|
|
$requiredParentMap = [
|
|||
|
|
'listitem' => ['list', 'group'],
|
|||
|
|
'menuitem' => ['menu', 'menubar', 'group'],
|
|||
|
|
'menuitemcheckbox' => ['menu', 'menubar'],
|
|||
|
|
'menuitemradio' => ['menu', 'menubar'],
|
|||
|
|
'tab' => ['tablist'],
|
|||
|
|
'treeitem' => ['tree', 'group'],
|
|||
|
|
'cell' => ['row'],
|
|||
|
|
'gridcell' => ['row'],
|
|||
|
|
'columnheader' => ['row'],
|
|||
|
|
'rowheader' => ['row'],
|
|||
|
|
'option' => ['listbox', 'group'],
|
|||
|
|
'row' => ['grid', 'table', 'treegrid', 'rowgroup']
|
|||
|
|
];
|
|||
|
|
|
|||
|
|
foreach ($roles as $role) {
|
|||
|
|
if (isset($requiredParentMap[$role])) {
|
|||
|
|
$hasRequiredParent = $this->hasParentWithRole($element, $requiredParentMap[$role]);
|
|||
|
|
|
|||
|
|
if (!$hasRequiredParent) {
|
|||
|
|
$expectedStr = implode(' veya ', $requiredParentMap[$role]);
|
|||
|
|
return $this->createViolation(
|
|||
|
|
$element,
|
|||
|
|
"ARIA rolü '{$role}' olan eleman gerekli üst eleman rollerinden hiçbirine sahip değil.",
|
|||
|
|
"Bu elemanı rolü {$expectedStr} olan bir üst elemanın içine yerleştirin."
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @param array<int, string> $requiredRoles
|
|||
|
|
*/
|
|||
|
|
private function hasParentWithRole(DOMElement $element, array $requiredRoles): bool
|
|||
|
|
{
|
|||
|
|
$parent = $element->parentNode;
|
|||
|
|
while ($parent !== null && $parent instanceof DOMElement) {
|
|||
|
|
if ($parent->hasAttribute('role')) {
|
|||
|
|
$parentRoles = explode(' ', strtolower(trim($parent->getAttribute('role'))));
|
|||
|
|
foreach ($parentRoles as $pRole) {
|
|||
|
|
if (in_array($pRole, $requiredRoles)) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
// For native HTML semantics fallback (e.g. <ul> is a list)
|
|||
|
|
$tagName = strtolower($parent->tagName);
|
|||
|
|
$nativeRole = $this->getNativeRole($tagName);
|
|||
|
|
if ($nativeRole && in_array($nativeRole, $requiredRoles)) {
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
$parent = $parent->parentNode;
|
|||
|
|
}
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private function getNativeRole(string $tagName): ?string
|
|||
|
|
{
|
|||
|
|
$map = [
|
|||
|
|
'ul' => 'list',
|
|||
|
|
'ol' => 'list',
|
|||
|
|
'dl' => 'list',
|
|||
|
|
'table' => 'table',
|
|||
|
|
'tr' => 'row',
|
|||
|
|
'tbody' => 'rowgroup',
|
|||
|
|
'thead' => 'rowgroup',
|
|||
|
|
'tfoot' => 'rowgroup',
|
|||
|
|
'select' => 'listbox',
|
|||
|
|
'optgroup' => 'group'
|
|||
|
|
];
|
|||
|
|
return $map[$tagName] ?? null;
|
|||
|
|
}
|
|||
|
|
}
|