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
build: upgrade PHPStan to level 9 and fix strict type errors
This commit is contained in:
@@ -16,12 +16,21 @@ abstract class AbstractRule implements RuleInterface
|
||||
|
||||
protected function createViolation(DOMElement $element, string $message, ?string $suggestion = null): Violation
|
||||
{
|
||||
$doc = $element->ownerDocument;
|
||||
$html = '';
|
||||
if ($doc !== null) {
|
||||
$htmlVal = $doc->saveHTML($element);
|
||||
if (is_string($htmlVal)) {
|
||||
$html = $htmlVal;
|
||||
}
|
||||
}
|
||||
|
||||
return new Violation(
|
||||
ruleId: $this->getId(),
|
||||
message: $message,
|
||||
severity: $this->getSeverity(),
|
||||
standard: $this->getStandard(),
|
||||
htmlSnippet: $element->ownerDocument->saveHTML($element),
|
||||
htmlSnippet: $html,
|
||||
fixSuggestion: $suggestion
|
||||
);
|
||||
}
|
||||
|
||||
+35
-31
@@ -28,43 +28,47 @@ class AriaRole extends AbstractRule
|
||||
|
||||
// 1. Check WAI-ARIA Role Validity
|
||||
$roleElements = $xpath->query('//*[@role]');
|
||||
foreach ($roleElements as $el) {
|
||||
if (!$el instanceof \DOMElement) {
|
||||
continue;
|
||||
}
|
||||
$role = trim($el->getAttribute('role'));
|
||||
if ($role === '') {
|
||||
continue;
|
||||
}
|
||||
$roles = array_filter(explode(' ', $role));
|
||||
foreach ($roles as $r) {
|
||||
if (!in_array(strtolower($r), self::$validRoles, true)) {
|
||||
$violations[] = $this->createViolation(
|
||||
"Invalid ARIA role \"{$r}\" declared on element. Must use standard WAI-ARIA roles.",
|
||||
$el
|
||||
);
|
||||
if ($roleElements !== false) {
|
||||
foreach ($roleElements as $el) {
|
||||
if (!$el instanceof \DOMElement) {
|
||||
continue;
|
||||
}
|
||||
$role = trim($el->getAttribute('role'));
|
||||
if ($role === '') {
|
||||
continue;
|
||||
}
|
||||
$roles = array_filter(explode(' ', $role));
|
||||
foreach ($roles as $r) {
|
||||
if (!in_array(strtolower($r), self::$validRoles, true)) {
|
||||
$violations[] = $this->createViolation(
|
||||
"Invalid ARIA role \"{$r}\" declared on element. Must use standard WAI-ARIA roles.",
|
||||
$el
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Check aria-controls Targets Existence
|
||||
$controlsElements = $xpath->query('//*[@aria-controls]');
|
||||
foreach ($controlsElements as $el) {
|
||||
if (!$el instanceof \DOMElement) {
|
||||
continue;
|
||||
}
|
||||
$targetsStr = trim($el->getAttribute('aria-controls'));
|
||||
if ($targetsStr === '') {
|
||||
continue;
|
||||
}
|
||||
$targets = array_filter(explode(' ', $targetsStr));
|
||||
foreach ($targets as $targetId) {
|
||||
$targetQuery = $xpath->query('//*[@id="' . $targetId . '"]');
|
||||
if ($targetQuery->length === 0) {
|
||||
$violations[] = $this->createViolation(
|
||||
"Attribute aria-controls=\"{$targetId}\" targets an element that does not exist in the document.",
|
||||
$el
|
||||
);
|
||||
if ($controlsElements !== false) {
|
||||
foreach ($controlsElements as $el) {
|
||||
if (!$el instanceof \DOMElement) {
|
||||
continue;
|
||||
}
|
||||
$targetsStr = trim($el->getAttribute('aria-controls'));
|
||||
if ($targetsStr === '') {
|
||||
continue;
|
||||
}
|
||||
$targets = array_filter(explode(' ', $targetsStr));
|
||||
foreach ($targets as $targetId) {
|
||||
$targetQuery = $xpath->query('//*[@id="' . $targetId . '"]');
|
||||
if ($targetQuery !== false && $targetQuery->length === 0) {
|
||||
$violations[] = $this->createViolation(
|
||||
"Attribute aria-controls=\"{$targetId}\" targets an element that does not exist in the document.",
|
||||
$el
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,14 +99,14 @@ class ColorContrast extends AbstractRule
|
||||
{
|
||||
$hex = ltrim($hex, '#');
|
||||
if (strlen($hex) === 3) {
|
||||
$r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1));
|
||||
$g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1));
|
||||
$b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1));
|
||||
$r = (int)hexdec(substr($hex, 0, 1) . substr($hex, 0, 1));
|
||||
$g = (int)hexdec(substr($hex, 1, 1) . substr($hex, 1, 1));
|
||||
$b = (int)hexdec(substr($hex, 2, 1) . substr($hex, 2, 1));
|
||||
return [$r, $g, $b];
|
||||
} elseif (strlen($hex) === 6) {
|
||||
$r = hexdec(substr($hex, 0, 2));
|
||||
$g = hexdec(substr($hex, 2, 2));
|
||||
$b = hexdec(substr($hex, 4, 2));
|
||||
$r = (int)hexdec(substr($hex, 0, 2));
|
||||
$g = (int)hexdec(substr($hex, 2, 2));
|
||||
$b = (int)hexdec(substr($hex, 4, 2));
|
||||
return [$r, $g, $b];
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -13,6 +13,9 @@ class DuplicateId extends AbstractRule
|
||||
$violations = [];
|
||||
$xpath = new \DOMXPath($doc);
|
||||
$elements = $xpath->query('//*[@id]');
|
||||
if ($elements === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$ids = [];
|
||||
foreach ($elements as $el) {
|
||||
|
||||
@@ -29,10 +29,13 @@ class FormLabel extends AbstractRule
|
||||
|
||||
if ($element->hasAttribute('id')) {
|
||||
$id = $element->getAttribute('id');
|
||||
$xpath = new \DOMXPath($element->ownerDocument);
|
||||
$labels = $xpath->query("//label[@for='$id']");
|
||||
if ($labels->length > 0) {
|
||||
return null;
|
||||
$doc = $element->ownerDocument;
|
||||
if ($doc !== null) {
|
||||
$xpath = new \DOMXPath($doc);
|
||||
$labels = $xpath->query("//label[@for='$id']");
|
||||
if ($labels !== false && $labels->length > 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ class HeadingOrderRule extends AbstractRule
|
||||
$violations = [];
|
||||
$xpath = new \DOMXPath($doc);
|
||||
$headings = $xpath->query('//h1|//h2|//h3|//h4|//h5|//h6');
|
||||
if ($headings === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$lastLevel = 0;
|
||||
foreach ($headings as $h) {
|
||||
|
||||
@@ -9,7 +9,8 @@ class StandardRuleSet
|
||||
*/
|
||||
public static function all(): array
|
||||
{
|
||||
return [
|
||||
/** @var RuleInterface[] $rules */
|
||||
$rules = [
|
||||
new HtmlHasLang(),
|
||||
new ImgAltText(),
|
||||
new EmptyLink(),
|
||||
@@ -24,5 +25,6 @@ class StandardRuleSet
|
||||
new AriaRole(),
|
||||
new IframeTitle(),
|
||||
];
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user