Skip to content

Commit

Permalink
Merge branch 'master' into 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Jun 22, 2016
2 parents db6f091 + ed73bd3 commit 163ae2a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- PHPCBF always uses this setting to reduce memory
-- Setting $recordErrors in custom reports no longer supported

- Squiz LowercasePHPFunctionsSniff now uses the internal function list so it can ignore included global functions
-- This can happen if functions are defined by calling vendor/autoload.php
-- Thanks to Michael Butler for the patch
- Fixed bug #945 : Incorrect indent behavior using deep-nested function and arrays
- Fixed bug #961 : Two anonymous functions passed as function/method arguments cause indentation false positive
- Fixed bug #1007 : Squiz Unreachable code detection is not working properly with a closure inside a case
Expand Down
26 changes: 22 additions & 4 deletions src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@
class LowercasePHPFunctionsSniff implements 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 @@ -80,11 +99,10 @@ public function process(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 163ae2a

Please sign in to comment.