From 273a80d50ba7be118911eb522da63f702704ddf0 Mon Sep 17 00:00:00 2001 From: Marc Galang Date: Mon, 2 Mar 2020 14:45:35 +0200 Subject: [PATCH] Skip validating user defined functions which has similar name as filesystem function --- Security/Sniffs/BadFunctions/FilesystemFunctionsSniff.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Security/Sniffs/BadFunctions/FilesystemFunctionsSniff.php b/Security/Sniffs/BadFunctions/FilesystemFunctionsSniff.php index 0fa198f..be325f0 100644 --- a/Security/Sniffs/BadFunctions/FilesystemFunctionsSniff.php +++ b/Security/Sniffs/BadFunctions/FilesystemFunctionsSniff.php @@ -47,6 +47,11 @@ public function process(File $phpcsFile, $stackPtr) { return; } + // Skip user defined functions which has similar names with a filesystem function. + if ($tokens[$stackPtr - 2]['content'] == 'function') { + return; + } + $closer = $tokens[$opener]['parenthesis_closer']; $s = $phpcsFile->findNext(array_merge(\PHP_CodeSniffer\Util\Tokens::$emptyTokens, \PHP_CodeSniffer\Util\Tokens::$bracketTokens, \PHPCS_SecurityAudit\Security\Sniffs\Utils::$staticTokens), $s, $closer, true); if ($s) {