Make WordPress Core


Ignore:
Timestamp:
08/17/2018 01:50:26 AM (8 years ago)
Author:
pento
Message:

Coding Standards: Upgrade WPCS to 1.0.0

WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:

  • Multiline function calls must now put each parameter on a new line.
  • Auto-formatting files is now part of the grunt precommit script.
  • Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-tags-controller.php

    r43567 r43571  
    5959                parent::setUp();
    6060
    61                 register_meta( 'term', 'test_single', array(
    62                         'show_in_rest' => true,
    63                         'single' => true,
    64                         'type' => 'string',
    65                 ));
    66                 register_meta( 'term', 'test_multi', array(
    67                         'show_in_rest' => true,
    68                         'single' => false,
    69                         'type' => 'string',
    70                 ));
    71                 register_term_meta( 'post_tag', 'test_tag_single', array(
    72                         'show_in_rest' => true,
    73                         'single' => true,
    74                         'type' => 'string',
    75                 ));
    76                 register_term_meta( 'post_tag', 'test_tag_multi', array(
    77                         'show_in_rest' => true,
    78                         'single' => false,
    79                         'type' => 'string',
    80                 ));
    81                 register_term_meta( 'category', 'test_cat_meta', array(
    82                         'show_in_rest' => true,
    83                         'single' => true,
    84                         'type' => 'string',
    85                 ));
     61                register_meta(
     62                        'term',
     63                        'test_single',
     64                        array(
     65                                'show_in_rest' => true,
     66                                'single'       => true,
     67                                'type'         => 'string',
     68                        )
     69                );
     70                register_meta(
     71                        'term',
     72                        'test_multi',
     73                        array(
     74                                'show_in_rest' => true,
     75                                'single'       => false,
     76                                'type'         => 'string',
     77                        )
     78                );
     79                register_term_meta(
     80                        'post_tag',
     81                        'test_tag_single',
     82                        array(
     83                                'show_in_rest' => true,
     84                                'single'       => true,
     85                                'type'         => 'string',
     86                        )
     87                );
     88                register_term_meta(
     89                        'post_tag',
     90                        'test_tag_multi',
     91                        array(
     92                                'show_in_rest' => true,
     93                                'single'       => false,
     94                                'type'         => 'string',
     95                        )
     96                );
     97                register_term_meta(
     98                        'category',
     99                        'test_cat_meta',
     100                        array(
     101                                'show_in_rest' => true,
     102                                'single'       => true,
     103                                'type'         => 'string',
     104                        )
     105                );
    86106        }
    87107
    … …  
    128148                                'search',
    129149                                'slug',
    130                         ), $keys
     150                        ),
     151                        $keys
    131152                );
    132153        }
    … …  
    465486                $request = new WP_REST_Request( 'GET', '/wp/v2/tags' );
    466487                $request->set_param(
    467                         'slug', array(
     488                        'slug',
     489                        array(
    468490                                'taco',
    469491                                'burrito',
    … …  
    531553                        array(
    532554                                'page' => 2,
    533                         ), rest_url( 'wp/v2/tags' )
     555                        ),
     556                        rest_url( 'wp/v2/tags' )
    534557                );
    535558                $this->assertFalse( stripos( $headers['Link'], 'rel="prev"' ) );
    … …  
    550573                        array(
    551574                                'page' => 2,
    552                         ), rest_url( 'wp/v2/tags' )
     575                        ),
     576                        rest_url( 'wp/v2/tags' )
    553577                );
    554578                $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
    … …  
    556580                        array(
    557581                                'page' => 4,
    558                         ), rest_url( 'wp/v2/tags' )
     582                        ),
     583                        rest_url( 'wp/v2/tags' )
    559584                );
    560585                $this->assertContains( '<' . $next_link . '>; rel="next"', $headers['Link'] );
    … …  
    569594                        array(
    570595                                'page' => 5,
    571                         ), rest_url( 'wp/v2/tags' )
     596                        ),
     597                        rest_url( 'wp/v2/tags' )
    572598                );
    573599                $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
    … …  
    583609                        array(
    584610                                'page' => 6,
    585                         ), rest_url( 'wp/v2/tags' )
     611                        ),
     612                        rest_url( 'wp/v2/tags' )
    586613                );
    587614                $this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
    … …  
    607634                $request  = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id );
    608635                $response = rest_get_server()->dispatch( $request );
    609                 $data = $response->get_data();
     636                $data     = $response->get_data();
    610637                $this->assertArrayHasKey( 'meta', $data );
    611638
    … …  
    625652                $request  = new WP_REST_Request( 'GET', '/wp/v2/tags/' . $id );
    626653                $response = rest_get_server()->dispatch( $request );
    627                 $data = $response->get_data();
     654                $data     = $response->get_data();
    628655                $this->assertArrayHasKey( 'meta', $data );
    629656
    … …  
    743770                $request->set_param( 'description', 'New Description' );
    744771                $request->set_param( 'slug', 'new-slug' );
    745                 $request->set_param( 'meta', array(
    746                         'test_single' => 'just meta',
    747                         'test_tag_single' => 'tag-specific meta',
    748                         'test_cat_meta' => 'category-specific meta',
    749                 ) );
     772                $request->set_param(
     773                        'meta',
     774                        array(
     775                                'test_single'     => 'just meta',
     776                                'test_tag_single' => 'tag-specific meta',
     777                                'test_cat_meta'   => 'category-specific meta',
     778                        )
     779                );
    750780                $response = rest_get_server()->dispatch( $request );
    751781                $this->assertEquals( 200, $response->get_status() );
    … …  
    898928                                'name'        => '\o/ ¯\_(ツ)_/¯',
    899929                                'description' => '\o/ ¯\_(ツ)_/¯',
    900                         ), array(
     930                        ),
     931                        array(
    901932                                'name'        => '\o/ ¯\_(ツ)_/¯',
    902933                                'description' => '\o/ ¯\_(ツ)_/¯',
    … …  
    913944                                        'name'        => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    914945                                        'description' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    915                                 ), array(
     946                                ),
     947                                array(
    916948                                        'name'        => 'div strong',
    917949                                        'description' => 'div <strong>strong</strong> oh noes',
    … …  
    924956                                        'name'        => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    925957                                        'description' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    926                                 ), array(
     958                                ),
     959                                array(
    927960                                        'name'        => 'div strong',
    928961                                        'description' => 'div <strong>strong</strong> oh noes',
    … …  
    939972                                'name'        => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    940973                                'description' => '\\\&\\\ &amp; &invalid; < &lt; &amp;lt;',
    941                         ), array(
     974                        ),
     975                        array(
    942976                                'name'        => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
    943977                                'description' => '\\\&amp;\\\ &amp; &amp;invalid; &lt; &lt; &amp;lt;',
    … …  
    953987                                'name'        => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    954988                                'description' => '<div>div</div> <strong>strong</strong> <script>oh noes</script>',
    955                         ), array(
     989                        ),
     990                        array(
    956991                                'name'        => 'div strong',
    957992                                'description' => 'div <strong>strong</strong> oh noes',
    … …  
    10641099                $term     = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );
    10651100                $response = $endpoint->prepare_item_for_response( $term, $request );
    1066                 $this->assertEquals( array(
    1067                         'id',
    1068                         'name',
    1069                 ), array_keys( $response->get_data() ) );
     1101                $this->assertEquals(
     1102                        array(
     1103                                'id',
     1104                                'name',
     1105                        ),
     1106                        array_keys( $response->get_data() )
     1107                );
    10701108        }
    10711109
    … …  
    11061144
    11071145                register_rest_field(
    1108                         'tag', 'my_custom_int', array(
     1146                        'tag',
     1147                        'my_custom_int',
     1148                        array(
    11091149                                'schema'       => $schema,
    11101150                                'get_callback' => array( $this, 'additional_field_get_callback' ),
    … …  
    11381178
    11391179                register_rest_field(
    1140                         'tag', 'my_custom_int', array(
     1180                        'tag',
     1181                        'my_custom_int',
     1182                        array(
    11411183                                'schema'          => $schema,
    11421184                                'get_callback'    => array( $this, 'additional_field_get_callback' ),
Note: See TracChangeset for help on using the changeset viewer.