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/src/wp-includes/functions.php

    r43466 r43571  
    108108        $req_format = $dateformatstring;
    109109
    110         $dateformatstring = preg_replace( "/(?<!\\\\)c/", DATE_W3C, $dateformatstring );
    111         $dateformatstring = preg_replace( "/(?<!\\\\)r/", DATE_RFC2822, $dateformatstring );
     110        $dateformatstring = preg_replace( '/(?<!\\\\)c/', DATE_W3C, $dateformatstring );
     111        $dateformatstring = preg_replace( '/(?<!\\\\)r/', DATE_RFC2822, $dateformatstring );
    112112
    113113        if ( ( ! empty( $wp_locale->month ) ) && ( ! empty( $wp_locale->weekday ) ) ) {
     
    18221822        if ( wp_is_stream( $path ) ) {
    18231823                list( $wrapper, $path ) = explode( '://', $path, 2 );
    1824                 $wrapper .= '://';
     1824                $wrapper               .= '://';
    18251825        }
    18261826
     
    22932293         */
    22942294        $upload_bits_error = apply_filters(
    2295                 'wp_upload_bits', array(
     2295                'wp_upload_bits',
     2296                array(
    22962297                        'name' => $name,
    22972298                        'bits' => $bits,
     
    23432344        /** This filter is documented in wp-admin/includes/file.php */
    23442345        return apply_filters(
    2345                 'wp_handle_upload', array(
     2346                'wp_handle_upload',
     2347                array(
    23462348                        'file'  => $new_file,
    23472349                        'url'   => $url,
    23482350                        'type'  => $wp_filetype['type'],
    23492351                        'error' => false,
    2350                 ), 'sideload'
     2352                ),
     2353                'sideload'
    23512354        );
    23522355}
     
    24502453                         */
    24512454                        $mime_to_ext = apply_filters(
    2452                                 'getimagesize_mimes_to_exts', array(
     2455                                'getimagesize_mimes_to_exts',
     2456                                array(
    24532457                                        'image/jpeg' => 'jpg',
    24542458                                        'image/png'  => 'png',
     
    25692573         */
    25702574        return apply_filters(
    2571                 'mime_types', array(
     2575                'mime_types',
     2576                array(
    25722577                        // Image formats.
    25732578                        'jpg|jpeg|jpe'                 => 'image/jpeg',
     
    26952700         */
    26962701        return apply_filters(
    2697                 'ext2type', array(
     2702                'ext2type',
     2703                array(
    26982704                        'image'       => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' ),
    26992705                        'audio'       => array( 'aac', 'ac3', 'aif', 'aiff', 'flac', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ),
     
    29272933                        $dir_attr = "dir='$text_direction'";
    29282934                }
    2929 ?>
     2935                ?>
    29302936<!DOCTYPE html>
    29312937<html xmlns="http://www.w3.org/1999/xhtml" <?php echo $dir_attr; ?>>
     
    29332939        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    29342940        <meta name="viewport" content="width=device-width">
    2935         <?php
    2936         if ( function_exists( 'wp_no_robots' ) ) {
    2937                 wp_no_robots();
    2938         }
    2939         ?>
     2941                <?php
     2942                if ( function_exists( 'wp_no_robots' ) ) {
     2943                        wp_no_robots();
     2944                }
     2945                ?>
    29402946        <title><?php echo $title; ?></title>
    29412947        <style type="text/css">
     
    30613067</body>
    30623068</html>
    3063 <?php
     3069        <?php
    30643070        die();
    30653071}
     
    33473353        if ( wp_doing_ajax() ) {
    33483354                wp_die(
    3349                         '', '', array(
     3355                        '',
     3356                        '',
     3357                        array(
    33503358                                'response' => null,
    33513359                        )
     
    39643972                $dir_attr = ' dir="rtl"';
    39653973        }
    3966 ?>
     3974        ?>
    39673975<!DOCTYPE html>
    39683976<html xmlns="http://www.w3.org/1999/xhtml"<?php echo $dir_attr; ?>>
     
    39763984</body>
    39773985</html>
    3978 <?php
     3986        <?php
    39793987        die();
    39803988}
     
    40994107                                        sprintf(
    41004108                                                __( 'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.' ),
    4101                                                 $class, $parent_class, $version, '<pre>__construct()</pre>'
     4109                                                $class,
     4110                                                $parent_class,
     4111                                                $version,
     4112                                                '<pre>__construct()</pre>'
    41024113                                        )
    41034114                                );
     
    41074118                                        sprintf(
    41084119                                                __( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ),
    4109                                                 $class, $version, '<pre>__construct()</pre>'
     4120                                                $class,
     4121                                                $version,
     4122                                                '<pre>__construct()</pre>'
    41104123                                        )
    41114124                                );
     
    41164129                                        sprintf(
    41174130                                                'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.',
    4118                                                 $class, $parent_class, $version, '<pre>__construct()</pre>'
     4131                                                $class,
     4132                                                $parent_class,
     4133                                                $version,
     4134                                                '<pre>__construct()</pre>'
    41194135                                        )
    41204136                                );
     
    41234139                                        sprintf(
    41244140                                                'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
    4125                                                 $class, $version, '<pre>__construct()</pre>'
     4141                                                $class,
     4142                                                $version,
     4143                                                '<pre>__construct()</pre>'
    41264144                                        )
    41274145                                );
     
    54685486                $truncate_paths = array(
    54695487                        wp_normalize_path( WP_CONTENT_DIR ),
    5470                         wp_normalize_path( ABSPATH )
     5488                        wp_normalize_path( ABSPATH ),
    54715489                );
    54725490        }
     
    56675685                                'interim-login' => '1',
    56685686                                'wp_lang'       => get_user_locale(),
    5669                         ), $login_url
     5687                        ),
     5688                        $login_url
    56705689                );
    56715690                ?>
     
    58665885 */
    58675886function wp_delete_file_from_directory( $file, $directory ) {
    5868         $real_file = realpath( wp_normalize_path( $file ) );
     5887        $real_file      = realpath( wp_normalize_path( $file ) );
    58695888        $real_directory = realpath( wp_normalize_path( $directory ) );
    58705889
     
    60496068        return sprintf(
    60506069                '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
    6051                 mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
     6070                mt_rand( 0, 0xffff ),
     6071                mt_rand( 0, 0xffff ),
    60526072                mt_rand( 0, 0xffff ),
    60536073                mt_rand( 0, 0x0fff ) | 0x4000,
    60546074                mt_rand( 0, 0x3fff ) | 0x8000,
    6055                 mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
     6075                mt_rand( 0, 0xffff ),
     6076                mt_rand( 0, 0xffff ),
     6077                mt_rand( 0, 0xffff )
    60566078        );
    60576079}
     
    61916213
    61926214        wp_mail(
    6193                 $email_change_email['to'], sprintf(
     6215                $email_change_email['to'],
     6216                sprintf(
    61946217                        $email_change_email['subject'],
    61956218                        $site_name
    6196                 ), $email_change_email['message'], $email_change_email['headers']
     6219                ),
     6220                $email_change_email['message'],
     6221                $email_change_email['headers']
    61976222        );
    61986223}
     
    62506275                if ( function_exists( 'inet_pton' ) && function_exists( 'inet_ntop' ) ) {
    62516276                        $ip_addr = inet_ntop( inet_pton( $ip_addr ) & inet_pton( $netmask ) );
    6252                         if ( false === $ip_addr) {
     6277                        if ( false === $ip_addr ) {
    62536278                                return '::';
    62546279                        }
Note: See TracChangeset for help on using the changeset viewer.