From 75113e042133eed95337c393768b071ae70da337 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 7 Jun 2024 01:54:08 +0200 Subject: [PATCH] Security/Underscorejs: start using the PHPCSUtils `FilePath` utility The `FilePath::getName()` method will strip quotes from the file name, as well as normalize the slashes to forward (*nix) slashes. This allows for a minor simplication in the code and improves code readability. --- WordPressVIPMinimum/Sniffs/Security/UnderscorejsSniff.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPressVIPMinimum/Sniffs/Security/UnderscorejsSniff.php b/WordPressVIPMinimum/Sniffs/Security/UnderscorejsSniff.php index dff1655d..33339362 100644 --- a/WordPressVIPMinimum/Sniffs/Security/UnderscorejsSniff.php +++ b/WordPressVIPMinimum/Sniffs/Security/UnderscorejsSniff.php @@ -10,6 +10,7 @@ namespace WordPressVIPMinimum\Sniffs\Security; use PHP_CodeSniffer\Util\Tokens; +use PHPCSUtils\Utils\FilePath; use PHPCSUtils\Utils\TextStrings; use WordPressVIPMinimum\Sniffs\Sniff; @@ -72,7 +73,7 @@ public function process_token( $stackPtr ) { /* * Ignore Gruntfile.js files as they are configuration, not code. */ - $file_name = TextStrings::stripQuotes( $this->phpcsFile->getFileName() ); + $file_name = FilePath::getName( $this->phpcsFile ); $file_name = strtolower( basename( $file_name ) ); if ( $file_name === 'gruntfile.js' ) {