PHPCSExtra
PHPCSExtra copied to clipboard
Add Sniff to ensure file only uses PHP native functions or functions defined in the current file
Is your feature request related to a problem?
In WordPress, there are a handful of files that need to function on their own. A sniff that detects the use of functions besides those available from PHP itself and those declared in the file itself.
Describe the solution you'd like
File 1 which would pass without issue:
<?PHP
function foo( $arg ){
$arguments = func_get_args(); // allowed since function is a part of the PHP standard lib
}
function bar( $arg ){
return foo( $arg ); // allowed since foo is defined in this file
}
File 2 which would raise an issue
<?PHP
function baz( $arg ){
return foo( $arg ); // foo is defined in a different file and these this would trigger an issue
}
?>
Additional context (optional)
This is discussed in https://core.trac.wordpress.org/ticket/61694 which is a follow up to prevent issues like the one described in https://core.trac.wordpress.org/ticket/61680
- [ ] I intend to create a pull request to implement this feature.