-
-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modularizing the discouraged functions
- Loading branch information
Showing
23 changed files
with
777 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* WordPress Coding Standard. | ||
* | ||
* @package WPCS\WordPressCodingStandards | ||
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards | ||
* @license https://opensource.org/licenses/MIT MIT | ||
*/ | ||
|
||
/** | ||
* Restrict the use of various development functions. | ||
* | ||
* @package WPCS\WordPressCodingStandards | ||
* | ||
* @since 0.11.0 | ||
*/ | ||
class WordPress_Sniffs_PHP_DevelopmentFunctionsSniff extends WordPress_AbstractFunctionRestrictionsSniff { | ||
|
||
/** | ||
* Groups of functions to restrict. | ||
* | ||
* Example: groups => array( | ||
* 'lambda' => array( | ||
* 'type' => 'error' | 'warning', | ||
* 'message' => 'Use anonymous functions instead please!', | ||
* 'functions' => array( 'eval', 'create_function' ), | ||
* ) | ||
* ) | ||
* | ||
* @return array | ||
*/ | ||
public function getGroups() { | ||
return array( | ||
'error_log' => array( | ||
'type' => 'error', | ||
'message' => '%s() Debug code is not to be used in Production', | ||
'functions' => array( | ||
'error_log', | ||
'var_dump', | ||
'var_export', | ||
'print_r', | ||
'trigger_error', | ||
'set_error_handler', | ||
'debug_backtrace', | ||
'debug_print_backtrace', | ||
'wp_debug_backtrace_summary', | ||
), | ||
), | ||
|
||
'prevent_path_disclosure' => array( | ||
'type' => 'error', | ||
'message' => '%s() is prohibited as it can lead to full path disclosure.', | ||
'functions' => array( | ||
'error_reporting', | ||
'phpinfo', | ||
), | ||
), | ||
|
||
); | ||
} // end getGroups() | ||
|
||
} // end class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
/** | ||
* WordPress Coding Standard. | ||
* | ||
* @package WPCS\WordPressCodingStandards | ||
* @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards | ||
* @license https://opensource.org/licenses/MIT MIT | ||
*/ | ||
|
||
/** | ||
* Restricts the use of various functions and suggests alternatives. | ||
* | ||
* @package WPCS\WordPressCodingStandards | ||
* | ||
* @since 0.11.0 | ||
*/ | ||
class WordPress_Sniffs_PHP_RestrictedFunctionsSniff extends WordPress_AbstractFunctionRestrictionsSniff { | ||
|
||
/** | ||
* Groups of functions to discourage. | ||
* | ||
* Example: groups => array( | ||
* 'lambda' => array( | ||
* 'type' => 'error' | 'warning', | ||
* 'message' => 'Use anonymous functions instead please!', | ||
* 'functions' => array( 'eval', 'create_function' ), | ||
* ) | ||
* ) | ||
* | ||
* @return array | ||
*/ | ||
public function getGroups() { | ||
return array( | ||
'eval' => array( | ||
'type' => 'error', | ||
'message' => '%s() is not allowed.', | ||
'functions' => array( | ||
'eval', | ||
), | ||
), | ||
|
||
'runtime_configuration' => array( | ||
'type' => 'error', | ||
'message' => '%s() is prohibited, changing configuration at runtime should not be done.', | ||
'functions' => array( | ||
'dl', | ||
'error_reporting', | ||
'ini_alter', | ||
'ini_restore', | ||
'ini_set', | ||
'magic_quotes_runtime', | ||
'set_magic_quotes_runtime', | ||
'apache_setenv', | ||
'putenv', | ||
'set_include_path', | ||
'restore_include_path', | ||
), | ||
), | ||
|
||
'system_calls' => array( | ||
'type' => 'error', | ||
'message' => 'PHP system calls are often disabled by server admins and should not be used. Found %s().', | ||
'functions' => array( | ||
'exec', | ||
'passthru', | ||
'proc_open', | ||
'shell_exec', | ||
'system', | ||
'popen', | ||
), | ||
), | ||
|
||
'obfuscation' => array( | ||
'type' => 'error', | ||
'message' => '%s() is not allowed.', | ||
'functions' => array( | ||
'base64_decode', | ||
'base64_encode', | ||
'convert_uudecode', | ||
'convert_uuencode', | ||
'str_rot13', | ||
), | ||
), | ||
|
||
); | ||
} // end getGroups() | ||
|
||
} // End class. |
Oops, something went wrong.