From a73bafef403a234b14c1e217dccbc54b7db41f76 Mon Sep 17 00:00:00 2001 From: Dan Wallis Date: Mon, 3 Jul 2023 14:10:29 +0100 Subject: [PATCH] Respect basepath configuration option in output --- Magento2/Sniffs/Legacy/InstallUpgradeSniff.php | 3 ++- Magento2/Sniffs/Legacy/ParseXMLTrait.php | 3 ++- Magento2/Sniffs/Legacy/RestrictedCodeSniff.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Magento2/Sniffs/Legacy/InstallUpgradeSniff.php b/Magento2/Sniffs/Legacy/InstallUpgradeSniff.php index c24c31b9..da71706c 100644 --- a/Magento2/Sniffs/Legacy/InstallUpgradeSniff.php +++ b/Magento2/Sniffs/Legacy/InstallUpgradeSniff.php @@ -11,6 +11,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Common; use SplFileInfo; class InstallUpgradeSniff implements Sniff @@ -108,7 +109,7 @@ public function process(File $phpcsFile, $stackPtr) self::INVALID_DIRECTORIES_ERROR_CODES[$folderName], [ $fileInfo->getFilename(), - $fileInfo->getPath(), + Common::stripBasepath($fileInfo->getPath(), $phpcsFile->config->basepath), ] ); } diff --git a/Magento2/Sniffs/Legacy/ParseXMLTrait.php b/Magento2/Sniffs/Legacy/ParseXMLTrait.php index 13d53f31..a81cb06f 100644 --- a/Magento2/Sniffs/Legacy/ParseXMLTrait.php +++ b/Magento2/Sniffs/Legacy/ParseXMLTrait.php @@ -9,6 +9,7 @@ use DOMDocument; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Util\Common; trait ParseXMLTrait { @@ -32,7 +33,7 @@ private function getFormattedXML(File $phpcsFile) 0, 'WrongXML', [ - $phpcsFile->getFilename(), + Common::stripBasepath($phpcsFile->getFilename(), $phpcsFile->config->basepath), ] ); return false; diff --git a/Magento2/Sniffs/Legacy/RestrictedCodeSniff.php b/Magento2/Sniffs/Legacy/RestrictedCodeSniff.php index adc28fc6..c6207ec9 100644 --- a/Magento2/Sniffs/Legacy/RestrictedCodeSniff.php +++ b/Magento2/Sniffs/Legacy/RestrictedCodeSniff.php @@ -11,6 +11,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; +use PHP_CodeSniffer\Util\Common; /** * Tests to find usage of restricted code @@ -76,7 +77,7 @@ public function process(File $phpcsFile, $stackPtr) $this->classes[$token]['warning_code'], [ $token, - $phpcsFile->getFilename(), + Common::stripBasepath($phpcsFile->getFilename(), $phpcsFile->config->basepath), $this->classes[$token]['replacement'], ] );