From 1798cf49dd752411f373e2fb3e7d028289fc7311 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Sat, 15 Oct 2022 12:02:16 +0100 Subject: [PATCH] Fix PHP error with short class names --- Magento2/Sniffs/Less/ClassNamingSniff.php | 3 ++- Magento2/Tests/Less/ClassNamingUnitTest.less | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Magento2/Sniffs/Less/ClassNamingSniff.php b/Magento2/Sniffs/Less/ClassNamingSniff.php index e684172b..9a2e1dd0 100644 --- a/Magento2/Sniffs/Less/ClassNamingSniff.php +++ b/Magento2/Sniffs/Less/ClassNamingSniff.php @@ -66,7 +66,8 @@ public function process(File $phpcsFile, $stackPtr) [implode("", $matches[0])] ); } - if (strpos($className, self::STRING_HELPER_CLASSES_PREFIX, 2) !== false) { + + if (strlen($className) > 1 && strpos($className, self::STRING_HELPER_CLASSES_PREFIX, 2) !== false) { $phpcsFile->addError( 'CSS class names should be separated with "-" (dash) instead of "_" (underscore)', $stackPtr, diff --git a/Magento2/Tests/Less/ClassNamingUnitTest.less b/Magento2/Tests/Less/ClassNamingUnitTest.less index ba60c205..f67a938b 100644 --- a/Magento2/Tests/Less/ClassNamingUnitTest.less +++ b/Magento2/Tests/Less/ClassNamingUnitTest.less @@ -30,3 +30,8 @@ .category-title { background: green; } + +// @see https://github.com/magento/magento-coding-standard/issues/425 +.a { + text-decoration: none; +}