From a2b984df04a7748aa49893187517a2054b74f616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enes=20Yak=C4=B1=C5=9Ft=C4=B1r?= Date: Tue, 23 Jun 2026 01:15:35 +0300 Subject: [PATCH] fix: resolve autoloading in vendor execution and eliminate template false positives --- bin/a11y | 11 +++++++++-- composer.json | 2 +- src/Core/Analyser.php | 8 +++++--- src/Rules/ButtonName.php | 5 +++++ src/Rules/EmptyHeading.php | 5 +++++ src/Rules/EmptyLabel.php | 5 +++++ src/Rules/EmptyLink.php | 5 +++++ 7 files changed, 35 insertions(+), 6 deletions(-) diff --git a/bin/a11y b/bin/a11y index ab5f0a0..a5fe98f 100644 --- a/bin/a11y +++ b/bin/a11y @@ -1,7 +1,14 @@ #!/usr/bin/env php add(new ScanCommand()); diff --git a/composer.json b/composer.json index 74867e8..52ce986 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "yaknet" ], "homepage": "https://forum.yak.net.tr", - "version": "3.0.0", + "version": "3.0.1", "type": "library", "license": "MIT", "authors": [ diff --git a/src/Core/Analyser.php b/src/Core/Analyser.php index 7d56f29..6e22a56 100644 --- a/src/Core/Analyser.php +++ b/src/Core/Analyser.php @@ -23,9 +23,11 @@ class Analyser $cwd = getcwd(); $this->projectRoot = $cwd ? str_replace('\\', '/', realpath($cwd) ?: $cwd) : '.'; - $baselinePath = $this->config->getBaselinePath(); - if ($baselinePath) { - $this->baselineManager->load($this->projectRoot . '/' . $baselinePath); + if ($baselineManager === null) { + $baselinePath = $this->config->getBaselinePath(); + if ($baselinePath) { + $this->baselineManager->load($this->projectRoot . '/' . $baselinePath); + } } } diff --git a/src/Rules/ButtonName.php b/src/Rules/ButtonName.php index 22e5bbd..3b692b1 100644 --- a/src/Rules/ButtonName.php +++ b/src/Rules/ButtonName.php @@ -21,6 +21,11 @@ class ButtonName extends AbstractRule return null; } + $html = $element->ownerDocument ? $element->ownerDocument->saveHTML($element) : ''; + if ($html !== false && preg_match('/<\?php|\{\{|\{%/i', $html)) { + return null; + } + $text = trim($element->textContent); if ($text === '' && !$element->hasAttribute('aria-label') && !$element->hasAttribute('title')) { return $this->createViolation($element, $this->getDescription(), 'Add text or an aria-label to the button.'); diff --git a/src/Rules/EmptyHeading.php b/src/Rules/EmptyHeading.php index cd048b5..c4e0874 100644 --- a/src/Rules/EmptyHeading.php +++ b/src/Rules/EmptyHeading.php @@ -21,6 +21,11 @@ class EmptyHeading extends AbstractRule return null; } + $html = $element->ownerDocument ? $element->ownerDocument->saveHTML($element) : ''; + if ($html !== false && preg_match('/<\?php|\{\{|\{%/i', $html)) { + return null; + } + $text = trim($element->textContent); if ($text === '' && !$element->hasAttribute('aria-label') && !$element->hasAttribute('title')) { return $this->createViolation( diff --git a/src/Rules/EmptyLabel.php b/src/Rules/EmptyLabel.php index e4ebf8e..f1a4bea 100644 --- a/src/Rules/EmptyLabel.php +++ b/src/Rules/EmptyLabel.php @@ -21,6 +21,11 @@ class EmptyLabel extends AbstractRule return null; } + $html = $element->ownerDocument ? $element->ownerDocument->saveHTML($element) : ''; + if ($html !== false && preg_match('/<\?php|\{\{|\{%/i', $html)) { + return null; + } + $text = trim($element->textContent); if ($text === '') { return $this->createViolation( diff --git a/src/Rules/EmptyLink.php b/src/Rules/EmptyLink.php index 2dd49ed..2b55be7 100644 --- a/src/Rules/EmptyLink.php +++ b/src/Rules/EmptyLink.php @@ -21,6 +21,11 @@ class EmptyLink extends AbstractRule return null; } + $html = $element->ownerDocument ? $element->ownerDocument->saveHTML($element) : ''; + if ($html !== false && preg_match('/<\?php|\{\{|\{%/i', $html)) { + return null; + } + $text = trim($element->textContent); if ($text === '' && !$element->hasAttribute('aria-label') && !$element->hasAttribute('title')) { // Check for images inside