Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 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/factory/class-wp-unittest-factory-for-attachment.php

    r38331 r42343  
    1818        // Backward compatibility for legacy argument format.
    1919        if ( is_string( $args ) ) {
    20             $file = $args;
    21             $args = $legacy_args;
     20            $file                = $args;
     21            $args                = $legacy_args;
    2222            $args['post_parent'] = $legacy_parent;
    23             $args['file'] = $file;
     23            $args['file']        = $file;
    2424        }
    2525
    26         $r = array_merge( array(
    27             'file' => '',
    28             'post_parent' => 0,
    29         ), $args );
     26        $r = array_merge(
     27            array(
     28                'file'        => '',
     29                'post_parent' => 0,
     30            ), $args
     31        );
    3032
    3133        return wp_insert_attachment( $r, $r['file'], $r['post_parent'] );
     
    3335
    3436    function create_upload_object( $file, $parent = 0 ) {
    35         $contents = file_get_contents($file);
    36         $upload = wp_upload_bits(basename($file), null, $contents);
     37        $contents = file_get_contents( $file );
     38        $upload   = wp_upload_bits( basename( $file ), null, $contents );
    3739
    3840        $type = '';
    39         if ( ! empty($upload['type']) ) {
     41        if ( ! empty( $upload['type'] ) ) {
    4042            $type = $upload['type'];
    4143        } else {
    4244            $mime = wp_check_filetype( $upload['file'] );
    43             if ($mime)
     45            if ( $mime ) {
    4446                $type = $mime['type'];
     47            }
    4548        }
    4649
    4750        $attachment = array(
    48             'post_title' => basename( $upload['file'] ),
    49             'post_content' => '',
    50             'post_type' => 'attachment',
    51             'post_parent' => $parent,
     51            'post_title'     => basename( $upload['file'] ),
     52            'post_content'   => '',
     53            'post_type'      => 'attachment',
     54            'post_parent'    => $parent,
    5255            'post_mime_type' => $type,
    53             'guid' => $upload[ 'url' ],
     56            'guid'           => $upload['url'],
    5457        );
    5558
    5659        // Save the data
    57         $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent );
     60        $id = wp_insert_attachment( $attachment, $upload['file'], $parent );
    5861        wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) );
    5962
Note: See TracChangeset for help on using the changeset viewer.