Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/functions.php

    r41966 r42343  
    2121
    2222// For adding hooks before loading WP
    23 function tests_add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
     23function tests_add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {
    2424    global $wp_filter;
    2525
     
    2727        add_filter( $tag, $function_to_add, $priority, $accepted_args );
    2828    } else {
    29         $idx = _test_filter_build_unique_id($tag, $function_to_add, $priority);
    30         $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
     29        $idx                                    = _test_filter_build_unique_id( $tag, $function_to_add, $priority );
     30        $wp_filter[ $tag ][ $priority ][ $idx ] = array(
     31            'function'      => $function_to_add,
     32            'accepted_args' => $accepted_args,
     33        );
    3134    }
    3235    return true;
    3336}
    3437
    35 function _test_filter_build_unique_id($tag, $function, $priority) {
    36     if ( is_string($function) )
     38function _test_filter_build_unique_id( $tag, $function, $priority ) {
     39    if ( is_string( $function ) ) {
    3740        return $function;
     41    }
    3842
    39     if ( is_object($function) ) {
     43    if ( is_object( $function ) ) {
    4044        // Closures are currently implemented as objects
    4145        $function = array( $function, '' );
     
    4448    }
    4549
    46     if (is_object($function[0]) ) {
    47         return spl_object_hash($function[0]) . $function[1];
    48     } else if ( is_string($function[0]) ) {
     50    if ( is_object( $function[0] ) ) {
     51        return spl_object_hash( $function[0] ) . $function[1];
     52    } elseif ( is_string( $function[0] ) ) {
    4953        // Static Calling
    50         return $function[0].$function[1];
     54        return $function[0] . $function[1];
    5155    }
    5256}
     
    6165        $wpdb->commentmeta,
    6266        $wpdb->term_relationships,
    63         $wpdb->termmeta
     67        $wpdb->termmeta,
    6468    ) as $table ) {
    6569        $wpdb->query( "DELETE FROM {$table}" );
     
    6872    foreach ( array(
    6973        $wpdb->terms,
    70         $wpdb->term_taxonomy
     74        $wpdb->term_taxonomy,
    7175    ) as $table ) {
    7276        $wpdb->query( "DELETE FROM {$table} WHERE term_id != 1" );
     
    97101
    98102function _wp_die_handler( $message, $title = '', $args = array() ) {
    99     if ( !$GLOBALS['_wp_die_disabled'] ) {
    100         _wp_die_handler_txt( $message, $title, $args);
     103    if ( ! $GLOBALS['_wp_die_disabled'] ) {
     104        _wp_die_handler_txt( $message, $title, $args );
    101105    } else {
    102106        //Ignore at our peril
     
    126130    if ( ! empty( $args ) ) {
    127131        echo "Args: \n";
    128         foreach( $args as $k => $v ){
     132        foreach ( $args as $k => $v ) {
    129133            echo "\t $k : $v\n";
    130134        }
     
    138142    if ( ! empty( $args ) ) {
    139143        echo "Args: \n";
    140         foreach( $args as $k => $v ){
     144        foreach ( $args as $k => $v ) {
    141145            echo "\t $k : $v\n";
    142146        }
     
    164168
    165169    $uploads['subdir'] = '';
    166     $uploads['path'] = str_replace( $subdir, '', $uploads['path'] );
    167     $uploads['url'] = str_replace( $subdir, '', $uploads['url'] );
     170    $uploads['path']   = str_replace( $subdir, '', $uploads['path'] );
     171    $uploads['url']    = str_replace( $subdir, '', $uploads['url'] );
    168172
    169173    return $uploads;
     
    174178 */
    175179function _upload_dir_https( $uploads ) {
    176     $uploads['url'] = str_replace( 'http://', 'https://', $uploads['url'] );
     180    $uploads['url']     = str_replace( 'http://', 'https://', $uploads['url'] );
    177181    $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] );
    178182
Note: See TracChangeset for help on using the changeset viewer.