-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Hey, interesting bug due to this commit: 0ade769
A project I'm working on uses composer autoload features that let's us put in "functions_include.php" into the global space. For a public example of this see guzzlehttp/psr7/src/functions_include.php
in the Guzzle project --> https://github.com/guzzle/guzzle/blob/master/src/functions.php
.
It just so happens that they (Guzzle) are defining global functions in all lowercase so it won't break. However we have legacy custom functions that do have uppercase naming, thus when the PHP lowercase function sniff runs it does if (function_exists($name)) { ... warn ... }
because it thinks only PHP functions are available but in reality all of the global functions included by composer vendor autoload features are available.
I think the more reliable way to fix this is to just have a hard-coded array of all PHP function built-ins for the Squiz.PHP.LowercasePHPFunctions.CallUppercase Sniff. There should only be a couple hundred even if you include the most common extensions like mysql and zip libs.
PHPCS code comment is this:
// 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.
$content = $tokens[$stackPtr]['content'];
if (function_exists($content) === false) {
return;
}
It's no longer true that:
no user defined global functions can exist