Skip to content

Commit

Permalink
Merge pull request #2291 from WordPress/feature/abstractarrayassignme…
Browse files Browse the repository at this point in the history
…ntrestrictions-remove-callback-option
  • Loading branch information
GaryJones authored Jul 4, 2023
2 parents c8e56b9 + 2ae05bd commit c283772
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions WordPress/AbstractArrayAssignmentRestrictionsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,9 @@ public function register() {
*
* Example: groups => array(
* 'groupname' => array(
* 'type' => 'error' | 'warning',
* 'message' => 'Descriptive error message. The error message will be passed the $key and $val of the current array assignment.',
* 'keys' => array( 'key1', 'another_key' ),
* 'callback' => array( 'class', 'method' ), // Optional.
* 'type' => 'error' | 'warning',
* 'message' => 'Descriptive error message. The error message will be passed the $key and $val of the current array assignment.',
* 'keys' => array( 'key1', 'another_key' ),
* )
* )
*
Expand Down Expand Up @@ -220,14 +219,12 @@ public function process_token( $stackPtr ) {
continue;
}

$callback = ( isset( $group['callback'] ) && is_callable( $group['callback'] ) ) ? $group['callback'] : array( $this, 'callback' );

foreach ( $inst as $key => $assignment ) {
if ( ! \in_array( $key, $group['keys'], true ) ) {
continue;
}

$output = \call_user_func( $callback, $key, $assignment['value'], $assignment['line'], $group );
$output = \call_user_func( array( $this, 'callback' ), $key, $assignment['value'], $assignment['line'], $group );

if ( ! isset( $output ) || false === $output ) {
continue;
Expand Down

0 comments on commit c283772

Please sign in to comment.