Make WordPress Core

Changeset 56680


Ignore:
Timestamp:
09/25/2023 03:34:34 PM (7 months ago)
Author:
SergeyBiryukov
Message:

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.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/options-general.php

    r56573 r56680  
    141141$new_admin_email = get_option( 'new_admin_email' );
    142142if ( $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.' ),
  • trunk/src/wp-admin/plugins.php

    r56600 r56680  
    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 );
  • trunk/src/wp-admin/user-edit.php

    r56602 r56680  
    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.' ),
  • trunk/src/wp-includes/block-supports/elements.php

    r56604 r56680  
    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        }
  • trunk/src/wp-includes/blocks.php

    r56678 r56680  
    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            /**
     
    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
     
    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 */
     
    10601060                    ? null
    10611061                    : $block['innerBlocks'][ $block_index - 1 ];
     1062
    10621063                $block_content .= call_user_func_array(
    10631064                    $pre_callback,
     
    10721073                    ? null
    10731074                    : $block['innerBlocks'][ $block_index + 1 ];
     1075
    10741076                $block_content .= call_user_func_array(
    10751077                    $post_callback,
     
    10771079                );
    10781080            }
    1079             $block_index++;
     1081            ++$block_index;
    10801082        }
    10811083    }
     
    11311133                ? null
    11321134                : $blocks[ $index - 1 ];
     1135
    11331136            $result .= call_user_func_array(
    11341137                $pre_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,
     
    11471153        }
    11481154    }
     1155
    11491156    return $result;
    11501157}
  • trunk/src/wp-includes/media.php

    r56651 r56680  
    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
  • trunk/src/wp-includes/taxonomy.php

    r56650 r56680  
    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,
  • trunk/tests/phpunit/tests/admin/wpTermsListTable.php

    r56631 r56680  
    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.
     
    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
  • trunk/tests/phpunit/tests/blocks/editor.php

    r56629 r56680  
    544544
    545545        $this->assertArrayNotHasKey( 'postContentAttributes', $settings );
    546 
    547546    }
    548547
  • trunk/tests/phpunit/tests/media.php

    r56651 r56680  
    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' );
     
    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;
  • trunk/tests/phpunit/tests/vars.php

    r56638 r56680  
    3535     * @return array
    3636     */
    37     function get_data_to_test_wp_is_mobile(): array {
     37    public function get_data_to_test_wp_is_mobile(): array {
    3838        return array(
    3939            'mobile client hint'  => array(
     
    105105
    106106    /**
    107      * Tests that wp_is_mobile() .
    108      *
    109107     * @ticket 59370
    110108     *
     
    116114     * @param bool  $expected Whether expected.
    117115     */
    118     function test_wp_is_mobile( array $headers, bool $expected ) {
     116    public function test_wp_is_mobile( array $headers, bool $expected ) {
    119117        foreach ( $headers as $key => $value ) {
    120118            $_SERVER[ $key ] = $value;
     
    128126     * @covers ::wp_is_mobile
    129127     */
    130     function test_wp_is_mobile_is_true_with_filter() {
     128    public function test_wp_is_mobile_is_true_with_filter() {
    131129        $this->assertFalse( wp_is_mobile() );
    132130        add_filter( 'wp_is_mobile', '__return_true' );
     
    139137     * @covers ::wp_is_mobile
    140138     */
    141     function test_wp_is_mobile_is_false_with_filter() {
     139    public function test_wp_is_mobile_is_false_with_filter() {
    142140        $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.60 Mobile Safari/537.36';
    143141        $this->assertTrue( wp_is_mobile() );
Note: See TracChangeset for help on using the changeset viewer.