Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Jun 22, 2016
2 parents 1a77a33 + 9468abe commit c6eb36c
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@
class Squiz_Sniffs_PHP_LowercasePHPFunctionsSniff implements PHP_CodeSniffer_Sniff
{

/**
* String -> int hash map of all php built in function names
*
* @var array
*/
private $_builtInFunctions;


/**
* Construct the LowercasePHPFunctionSniff
*/
public function __construct()
{

$allFunctions = get_defined_functions();
$this->_builtInFunctions = array_flip($allFunctions['internal']);

}//end __construct()


/**
* Returns an array of tokens this test wants to listen for.
Expand Down Expand Up @@ -95,11 +114,10 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
}

// Make sure it is an inbuilt PHP function.
// PHP_CodeSniffer doesn't include/require any files, so no
// user defined global functions can exist, except for
// PHP_CodeSniffer ones.
// PHP_CodeSniffer can possibly include user defined functions
// through the use of vendor/autoload.php.
$content = $tokens[$stackPtr]['content'];
if (function_exists($content) === false) {
if (isset($this->_builtInFunctions[strtolower($content)]) === false) {
return;
}

Expand Down

0 comments on commit c6eb36c

Please sign in to comment.