Skip to content

Commit 75113e0

Browse files
committed
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.
1 parent 3bc61bd commit 75113e0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

WordPressVIPMinimum/Sniffs/Security/UnderscorejsSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace WordPressVIPMinimum\Sniffs\Security;
1111

1212
use PHP_CodeSniffer\Util\Tokens;
13+
use PHPCSUtils\Utils\FilePath;
1314
use PHPCSUtils\Utils\TextStrings;
1415
use WordPressVIPMinimum\Sniffs\Sniff;
1516

@@ -72,7 +73,7 @@ public function process_token( $stackPtr ) {
7273
/*
7374
* Ignore Gruntfile.js files as they are configuration, not code.
7475
*/
75-
$file_name = TextStrings::stripQuotes( $this->phpcsFile->getFileName() );
76+
$file_name = FilePath::getName( $this->phpcsFile );
7677
$file_name = strtolower( basename( $file_name ) );
7778

7879
if ( $file_name === 'gruntfile.js' ) {

0 commit comments

Comments
 (0)