Skip to content

Commit bccc6fc

Browse files
Coding Standards: Fix a few newly introduced WPCS issues.
Follow-up to [56570], [56573], [56589], [56604], [56612], [56620], [56629], [56631], [56638], [56642], [56644], [56649]. Props jrf. See #59161, #58831. git-svn-id: https://develop.svn.wordpress.org/trunk@56680 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 68347e0 commit bccc6fc

11 files changed

Lines changed: 37 additions & 33 deletions

File tree

src/wp-admin/options-general.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
<?php
141141
$new_admin_email = get_option( 'new_admin_email' );
142142
if ( $new_admin_email && get_option( 'admin_email' ) !== $new_admin_email ) {
143-
$pending_admin_email_message = sprintf(
143+
$pending_admin_email_message = sprintf(
144144
/* translators: %s: New admin email. */
145145
__( 'There is a pending change of the admin email to %s.' ),
146146
'<code>' . esc_html( $new_admin_email ) . '</code>'

src/wp-admin/plugins.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@
690690
);
691691

692692
} elseif ( isset( $_GET['deleted'] ) ) {
693-
$delete_result = get_transient( 'plugins_delete_result_' . $user_ID );
693+
$delete_result = get_transient( 'plugins_delete_result_' . $user_ID );
694694
// Delete it once we're done.
695695
delete_transient( 'plugins_delete_result_' . $user_ID );
696696

src/wp-admin/user-edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@
550550
$new_email = get_user_meta( $current_user->ID, '_new_email', true );
551551
if ( $new_email && $new_email['newemail'] !== $current_user->user_email && $profile_user->ID === $current_user->ID ) :
552552

553-
$pending_change_message = sprintf(
553+
$pending_change_message = sprintf(
554554
/* translators: %s: New email. */
555555
__( 'There is a pending change of your email to %s.' ),
556556
'<code>' . esc_html( $new_email['newemail'] ) . '</code>'

src/wp-includes/block-supports/elements.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function wp_render_elements_support( $block_content, $block ) {
9898

9999
foreach ( $element_config['paths'] as $path ) {
100100
if ( null !== _wp_array_get( $block['attrs'], explode( '.', $path ), null ) ) {
101-
$element_colors_set++;
101+
++$element_colors_set;
102102
}
103103
}
104104
}

src/wp-includes/blocks.php

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -790,20 +790,20 @@ function make_before_block_visitor( $context ) {
790790
* Furthermore, prepend the markup for any blocks hooked `before` the given block and as its parent's
791791
* `first_child`, respectively, to the serialized markup for the given block.
792792
*
793-
* @param array $block The block to inject the theme attribute into, and hooked blocks before.
794-
* @param array $parent The parent block of the given block.
795-
* @param array $prev The previous sibling block of the given block.
793+
* @param array $block The block to inject the theme attribute into, and hooked blocks before.
794+
* @param array $parent_block The parent block of the given block.
795+
* @param array $prev The previous sibling block of the given block.
796796
* @return string The serialized markup for the given block, with the markup for any hooked blocks prepended to it.
797797
*/
798-
return function( &$block, $parent = null, $prev = null ) use ( $context ) {
798+
return function ( &$block, $parent_block = null, $prev = null ) use ( $context ) {
799799
_inject_theme_attribute_in_template_part_block( $block );
800800

801801
$markup = '';
802802

803-
if ( $parent && ! $prev ) {
803+
if ( $parent_block && ! $prev ) {
804804
// Candidate for first-child insertion.
805805
$relative_position = 'first_child';
806-
$anchor_block_type = $parent['blockName'];
806+
$anchor_block_type = $parent_block['blockName'];
807807
$hooked_block_types = array_keys( get_hooked_blocks( $anchor_block_type, $relative_position ) );
808808
/**
809809
* Filters the list of hooked block types for a given anchor block type and relative position.
@@ -856,12 +856,12 @@ function make_after_block_visitor( $context ) {
856856
* Append the markup for any blocks hooked `after` the given block and as its parent's
857857
* `last_child`, respectively, to the serialized markup for the given block.
858858
*
859-
* @param array $block The block to inject the hooked blocks after.
860-
* @param array $parent The parent block of the given block.
861-
* @param array $next The next sibling block of the given block.
859+
* @param array $block The block to inject the hooked blocks after.
860+
* @param array $parent_block The parent block of the given block.
861+
* @param array $next The next sibling block of the given block.
862862
* @return string The serialized markup for the given block, with the markup for any hooked blocks appended to it.
863863
*/
864-
return function( &$block, $parent = null, $next = null ) use ( $context ) {
864+
return function ( &$block, $parent_block = null, $next = null ) use ( $context ) {
865865
$markup = '';
866866

867867
$relative_position = 'after';
@@ -873,10 +873,10 @@ function make_after_block_visitor( $context ) {
873873
$markup .= get_comment_delimited_block_content( $hooked_block_type, array(), '' );
874874
}
875875

876-
if ( $parent && ! $next ) {
876+
if ( $parent_block && ! $next ) {
877877
// Candidate for last-child insertion.
878878
$relative_position = 'last_child';
879-
$anchor_block_type = $parent['blockName'];
879+
$anchor_block_type = $parent_block['blockName'];
880880
$hooked_block_types = array_keys( get_hooked_blocks( $anchor_block_type, $relative_position ) );
881881
/** This filter is documented in wp-includes/blocks.php */
882882
$hooked_block_types = apply_filters( 'hooked_block_types', $hooked_block_types, $relative_position, $anchor_block_type, $context );
@@ -1059,6 +1059,7 @@ function traverse_and_serialize_block( $block, $pre_callback = null, $post_callb
10591059
$prev = 0 === $block_index
10601060
? null
10611061
: $block['innerBlocks'][ $block_index - 1 ];
1062+
10621063
$block_content .= call_user_func_array(
10631064
$pre_callback,
10641065
array( &$inner_block, $block, $prev )
@@ -1071,12 +1072,13 @@ function traverse_and_serialize_block( $block, $pre_callback = null, $post_callb
10711072
$next = count( $block['innerBlocks'] ) - 1 === $block_index
10721073
? null
10731074
: $block['innerBlocks'][ $block_index + 1 ];
1075+
10741076
$block_content .= call_user_func_array(
10751077
$post_callback,
10761078
array( &$inner_block, $block, $next )
10771079
);
10781080
}
1079-
$block_index++;
1081+
++$block_index;
10801082
}
10811083
}
10821084

@@ -1130,22 +1132,27 @@ function traverse_and_serialize_blocks( $blocks, $pre_callback = null, $post_cal
11301132
$prev = 0 === $index
11311133
? null
11321134
: $blocks[ $index - 1 ];
1135+
11331136
$result .= call_user_func_array(
11341137
$pre_callback,
11351138
array( &$block, null, $prev ) // At the top level, there is no parent block to pass to the callback.
11361139
);
11371140
}
1141+
11381142
$result .= traverse_and_serialize_block( $block, $pre_callback, $post_callback );
1143+
11391144
if ( is_callable( $post_callback ) ) {
11401145
$next = count( $blocks ) - 1 === $index
11411146
? null
11421147
: $blocks[ $index + 1 ];
1148+
11431149
$result .= call_user_func_array(
11441150
$post_callback,
11451151
array( &$block, null, $next ) // At the top level, there is no parent block to pass to the callback.
11461152
);
11471153
}
11481154
}
1155+
11491156
return $result;
11501157
}
11511158

src/wp-includes/media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5730,7 +5730,7 @@ function wp_get_loading_optimization_attributes( $tag_name, $attr, $context ) {
57305730
if ( null === $maybe_in_viewport ) {
57315731
$header_enforced_contexts = array(
57325732
'template_part_' . WP_TEMPLATE_PART_AREA_HEADER => true,
5733-
'get_header_image_tag' => true,
5733+
'get_header_image_tag' => true,
57345734
);
57355735

57365736
/**

src/wp-includes/taxonomy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ function create_initial_taxonomies() {
231231
'publicly_queryable' => false,
232232
'hierarchical' => false,
233233
'labels' => array(
234-
'name' => _x( 'Pattern Categories', 'taxonomy general name' ),
235-
'singular_name' => _x( 'Pattern Category', 'taxonomy singular name' ),
234+
'name' => _x( 'Pattern Categories', 'taxonomy general name' ),
235+
'singular_name' => _x( 'Pattern Category', 'taxonomy singular name' ),
236236
),
237237
'query_var' => false,
238238
'rewrite' => false,

tests/phpunit/tests/admin/wpTermsListTable.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ public function set_up() {
4141
/**
4242
* Call an inaccessible (private or protected) method.
4343
*
44-
* @param object|string $object Object instance or class string to call the method of.
44+
* @param object|string $instance Object instance or class string to call the method of.
4545
* @param string $method_name Name of the method to call.
4646
* @param array $args Optional. Array of arguments to pass to the method.
4747
* @return mixed Return value of the method call.
4848
* @throws ReflectionException If the object could not be reflected upon.
4949
*/
50-
private function call_inaccessible_method( $object, $method_name, $args = array() ) {
51-
$method = ( new ReflectionClass( $object ) )->getMethod( $method_name );
50+
private function call_inaccessible_method( $instance, $method_name, $args = array() ) {
51+
$method = ( new ReflectionClass( $instance ) )->getMethod( $method_name );
5252
$method->setAccessible( true );
53-
return $method->invokeArgs( $object, $args );
53+
return $method->invokeArgs( $instance, $args );
5454
}
5555

5656
/**

tests/phpunit/tests/blocks/editor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,6 @@ public function test_get_block_editor_settings_without_post_content_block() {
543543
$settings = get_block_editor_settings( array(), $post_editor_context );
544544

545545
$this->assertArrayNotHasKey( 'postContentAttributes', $settings );
546-
547546
}
548547

549548
/**

tests/phpunit/tests/media.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4436,7 +4436,7 @@ public function test_wp_get_loading_optimization_attributes_should_return_empty_
44364436
$result = null;
44374437
add_filter(
44384438
'the_content',
4439-
function( $content ) use ( &$result ) {
4439+
function ( $content ) use ( &$result ) {
44404440
$attr = $this->get_width_height_for_high_priority();
44414441
$result = wp_get_loading_optimization_attributes( 'img', $attr, 'something_completely_arbitrary' );
44424442
return $content;
@@ -4496,7 +4496,7 @@ public function test_wp_loading_optimization_force_header_contexts_filter() {
44964496

44974497
add_filter(
44984498
'wp_loading_optimization_force_header_contexts',
4499-
function( $context ) {
4499+
function ( $context ) {
45004500
$contexts['something_completely_arbitrary'] = true;
45014501
return $contexts;
45024502
}

0 commit comments

Comments
 (0)