Skip to content

Commit

Permalink
Correct documentation and use strip_quotes only when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
grappler committed Mar 10, 2017
1 parent f3bf2b4 commit 737390a
Showing 1 changed file with 3 additions and 48 deletions.
51 changes: 3 additions & 48 deletions WordPress/AbstractFunctionRestrictionsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,51 +68,6 @@ abstract class WordPress_AbstractFunctionRestrictionsSniff extends WordPress_Sni
*/
protected $excluded_groups = array();

/**
* List of known PHP and WP functions which take a callback as an argument.
*
* Sorted alphabetically. Last updated on 8th March 2017.
*
* @since 0.11.0
*
* @var array <string function name> => <int callback argument position>
*/
protected $callback_functions = array(
'add_filter' => array( 2 ),
'add_action' => array( 2 ),
'array_diff_uassoc' => array( -1 ), // = last argument passed.
'array_diff_ukey' => array( -1 ), // = last argument passed.
'array_filter' => array( 2 ),
'array_intersect_uassoc' => array( -1 ), // = last argument passed.
'array_intersect_ukey' => array( -1 ), // = last argument passed.
'array_map' => array( 1 ),
'array_reduce' => array( 2 ),
'array_udiff_assoc' => array( -1 ), // = last argument passed.
'array_udiff_uassoc' => array( -1, -2 ), // = last argument passed.
'array_udiff' => array( -1 ), // = last argument passed.
'array_uintersect_assoc' => array( -1 ), // = last argument passed.
'array_uintersect_uassoc' => array( -1, -2 ), // = last argument passed.
'array_uintersect' => array( -1 ), // = last argument passed.
'array_walk' => array( 2 ),
'array_walk_recursive' => array( 2 ),
'call_user_func' => array( 1 ),
'call_user_func_array' => array( 1 ),
'forward_static_call' => array( 1 ),
'forward_static_call_array' => array( 1 ),
'header_register_callback' => array( 1 ),
'iterator_apply' => array( 2 ),
'mb_ereg_replace_callback' => array( 2 ),
'ob_start' => array( 1 ),
'preg_replace_callback' => array( 2 ),
'register_shutdown_function' => array( 1 ),
'register_tick_function' => array( 1 ),
'set_error_handler' => array( 1 ),
'set_exception_handler' => array( 1 ),
'uasort' => array( 2 ),
'uksort' => array( 2 ),
'usort' => array( 2 ),
);

/**
* Groups of functions to restrict.
*
Expand Down Expand Up @@ -281,7 +236,7 @@ public function is_targetted_token( $stackPtr ) {
* normal file processing.
*/
public function check_for_matches( $stackPtr ) {
$token_content = strtolower( $this->strip_quotes( $this->tokens[ $stackPtr ]['content'] ) );
$token_content = strtolower( $this->tokens[ $stackPtr ]['content'] );
$skip_to = array();

foreach ( $this->groups as $groupName => $group ) {
Expand Down Expand Up @@ -314,7 +269,7 @@ public function check_for_matches( $stackPtr ) {
*
* @param int $stackPtr The position of the current token in the stack.
*
* @return int|void If a callback was found return stackPtr for where to skip to, false if the function call is not a callback.
* @return int|void If a callback was found return stackPtr for where to skip to.
*/
public function check_for_callback_matches( $stackPtr ) {

Expand Down Expand Up @@ -354,7 +309,7 @@ public function check_for_callback_matches( $stackPtr ) {
return;
}

$skip_to[] = $this->check_for_matches( $callback );
$skip_to[] = $this->check_for_matches( $this->strip_quotes( $callback ) );
}

if ( empty( $skip_to ) || min( $skip_to ) === 0 ) {
Expand Down

0 comments on commit 737390a

Please sign in to comment.