WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (20 months 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/tests/functions/deprecated.php

    r40544 r42343  
    1313    /**
    1414     * List of functions that have been passed through _deprecated_function()
     15     *
    1516     * @var string[]
    1617     */
     
    1920    /**
    2021     * List of arguments that have been passed through _deprecated_argument()
     22     *
    2123     * @var string[]
    2224     */
     
    2527    /**
    2628     * List of files that have been passed through _deprecated_file()
     29     *
    2730     * @var string[]
    2831     */
     
    3134    /**
    3235     * Set up the test fixture
     36     *
    3337     * @return void
    3438     */
     
    3741        $this->_deprecated_functions = array();
    3842        $this->_deprecated_arguments = array();
    39         $this->_deprecated_files = array();
    40         add_action( 'deprecated_function_run' , array( $this, 'deprecated_function' ), 10, 3 );
     43        $this->_deprecated_files     = array();
     44        add_action( 'deprecated_function_run', array( $this, 'deprecated_function' ), 10, 3 );
    4145        add_action( 'deprecated_function_trigger_error', '__return_false' );
    42         add_action( 'deprecated_argument_run' , array( $this, 'deprecated_argument' ), 10, 3 );
     46        add_action( 'deprecated_argument_run', array( $this, 'deprecated_argument' ), 10, 3 );
    4347        add_action( 'deprecated_argument_trigger_error', '__return_false' );
    44         add_action( 'deprecated_file_included' , array( $this, 'deprecated_file' ), 10, 4 );
     48        add_action( 'deprecated_file_included', array( $this, 'deprecated_file' ), 10, 4 );
    4549        add_action( 'deprecated_file_trigger_error', '__return_false' );
    4650    }
     
    4852    /**
    4953     * Tear down the test fixture
     54     *
    5055     * @return void
    5156     */
    5257    public function teardown() {
    53         remove_action( 'deprecated_function_run' , array( $this, 'deprecated_function' ), 10, 3 );
     58        remove_action( 'deprecated_function_run', array( $this, 'deprecated_function' ), 10, 3 );
    5459        remove_action( 'deprecated_function_trigger_error', '__return_false' );
    55         remove_action( 'deprecated_argument_run' , array( $this, 'deprecated_argument' ), 10, 3 );
     60        remove_action( 'deprecated_argument_run', array( $this, 'deprecated_argument' ), 10, 3 );
    5661        remove_action( 'deprecated_argument_trigger_error', '__return_false' );
    57         remove_action( 'deprecated_file_included' , array( $this, 'deprecated_argument' ), 10, 4 );
     62        remove_action( 'deprecated_file_included', array( $this, 'deprecated_argument' ), 10, 4 );
    5863        remove_action( 'deprecated_file_trigger_error', '__return_false' );
    5964        parent::tearDown();
     
    6267    /**
    6368     * Catch functions that have passed through _deprecated_function
     69     *
    6470     * @param string $function
    6571     * @param string $replacement
     
    7177            'function'    => $function,
    7278            'replacement' => $replacement,
    73             'version'     => $version
     79            'version'     => $version,
    7480        );
    7581    }
     
    7783    /**
    7884     * Catch arguments that have passed through _deprecated_argument
     85     *
    7986     * @param string $argument
    8087     * @param string $message
     
    8693            'argument' => $argument,
    8794            'message'  => $message,
    88             'version'  => $version
     95            'version'  => $version,
    8996        );
    9097    }
     
    9299    /**
    93100     * Catch arguments that have passed through _deprecated_argument
     101     *
    94102     * @param string $argument
    95103     * @param string $message
     
    102110            'version'     => $version,
    103111            'replacement' => $replacement,
    104             'message'     => $message
     112            'message'     => $message,
    105113        );
    106114    }
     
    108116    /**
    109117     * Check if something was deprecated
     118     *
    110119     * @param string $type argument|function|file
    111120     * @param string $name
     
    114123    protected function was_deprecated( $type, $name ) {
    115124        switch ( $type ) {
    116             case 'argument' :
     125            case 'argument':
    117126                $search = $this->_deprecated_arguments;
    118127                $key    = 'argument';
    119128                break;
    120             case 'function' :
     129            case 'function':
    121130                $search = $this->_deprecated_functions;
    122131                $key    = 'function';
    123132                break;
    124             default :
     133            default:
    125134                $search = $this->_deprecated_files;
    126135                $key    = 'file';
    127136        }
    128137        foreach ( $search as $v ) {
    129             if ( $name == $v[$key] ) {
     138            if ( $name == $v[ $key ] ) {
    130139                return $v;
    131140            }
     
    136145    /**
    137146     * Test that wp_save_image_file has a deprecated argument when passed a GD resource
     147     *
    138148     * @ticket 6821
    139149     * @expectedDeprecated wp_save_image_file
    140150     */
    141151    public function test_wp_save_image_file_deprecated_with_gd_resource() {
    142         if ( !function_exists( 'imagejpeg' ) )
     152        if ( ! function_exists( 'imagejpeg' ) ) {
    143153            $this->fail( 'jpeg support unavailable' );
     154        }
    144155
    145156        // Call wp_save_image_file
    146157        include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
    147158        $file = wp_tempnam();
    148         $img = imagecreatefromjpeg( DIR_TESTDATA . '/images/canola.jpg' );
     159        $img  = imagecreatefromjpeg( DIR_TESTDATA . '/images/canola.jpg' );
    149160        wp_save_image_file( $file, $img, 'image/jpeg', 1 );
    150161        imagedestroy( $img );
     
    158169    /**
    159170     * Test that wp_save_image_file doesn't have a deprecated argument when passed a WP_Image_Editor
     171     *
    160172     * @ticket 6821
    161173     */
    162174    public function test_wp_save_image_file_not_deprecated_with_wp_image_editor() {
    163         if ( !function_exists( 'imagejpeg' ) )
     175        if ( ! function_exists( 'imagejpeg' ) ) {
    164176            $this->fail( 'jpeg support unavailable' );
     177        }
    165178
    166179        // Call wp_save_image_file
    167180        include_once( ABSPATH . 'wp-admin/includes/image-edit.php' );
    168181        $file = wp_tempnam();
    169         $img = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
     182        $img  = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
    170183        wp_save_image_file( $file, $img, 'image/jpeg', 1 );
    171184        unset( $img );
Note: See TracChangeset for help on using the changeset viewer.