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/src/wp-includes/class-wp-http-ixr-client.php

    r37492 r42343  
    55 * @package WordPress
    66 * @since 3.1.0
    7  *
    87 */
    98class WP_HTTP_IXR_Client extends IXR_Client {
     
    2019     * @param int $timeout
    2120     */
    22     public function __construct($server, $path = false, $port = false, $timeout = 15) {
     21    public function __construct( $server, $path = false, $port = false, $timeout = 15 ) {
    2322        if ( ! $path ) {
    2423            // Assume we have been given a URL instead
    25             $bits = parse_url($server);
     24            $bits         = parse_url( $server );
    2625            $this->scheme = $bits['scheme'];
    2726            $this->server = $bits['host'];
    28             $this->port = isset($bits['port']) ? $bits['port'] : $port;
    29             $this->path = !empty($bits['path']) ? $bits['path'] : '/';
     27            $this->port   = isset( $bits['port'] ) ? $bits['port'] : $port;
     28            $this->path   = ! empty( $bits['path'] ) ? $bits['path'] : '/';
    3029
    3130            // Make absolutely sure we have a path
     
    4039            $this->scheme = 'http';
    4140            $this->server = $server;
    42             $this->path = $path;
    43             $this->port = $port;
     41            $this->path   = $path;
     42            $this->port   = $port;
    4443        }
    4544        $this->useragent = 'The Incutio XML-RPC PHP Library';
    46         $this->timeout = $timeout;
     45        $this->timeout   = $timeout;
    4746    }
    4847
     
    5150     */
    5251    public function query() {
    53         $args = func_get_args();
    54         $method = array_shift($args);
    55         $request = new IXR_Request($method, $args);
    56         $xml = $request->getXml();
     52        $args    = func_get_args();
     53        $method  = array_shift( $args );
     54        $request = new IXR_Request( $method, $args );
     55        $xml     = $request->getXml();
    5756
    5857        $port = $this->port ? ":$this->port" : '';
    59         $url = $this->scheme . '://' . $this->server . $port . $this->path;
     58        $url  = $this->scheme . '://' . $this->server . $port . $this->path;
    6059        $args = array(
    61             'headers'    => array('Content-Type' => 'text/xml'),
     60            'headers'    => array( 'Content-Type' => 'text/xml' ),
    6261            'user-agent' => $this->useragent,
    6362            'body'       => $xml,
     
    6665        // Merge Custom headers ala #8145
    6766        foreach ( $this->headers as $header => $value ) {
    68             $args['headers'][$header] = $value;
     67            $args['headers'][ $header ] = $value;
    6968        }
    7069
     
    8483        // Now send the request
    8584        if ( $this->debug ) {
    86             echo '<pre class="ixr_request">' . htmlspecialchars($xml) . "\n</pre>\n\n";
     85            echo '<pre class="ixr_request">' . htmlspecialchars( $xml ) . "\n</pre>\n\n";
    8786        }
    8887
    89         $response = wp_remote_post($url, $args);
     88        $response = wp_remote_post( $url, $args );
    9089
    91         if ( is_wp_error($response) ) {
    92             $errno    = $response->get_error_code();
    93             $errorstr = $response->get_error_message();
    94             $this->error = new IXR_Error(-32300, "transport error: $errno $errorstr");
     90        if ( is_wp_error( $response ) ) {
     91            $errno       = $response->get_error_code();
     92            $errorstr    = $response->get_error_message();
     93            $this->error = new IXR_Error( -32300, "transport error: $errno $errorstr" );
    9594            return false;
    9695        }
    9796
    9897        if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
    99             $this->error = new IXR_Error(-32301, 'transport error - HTTP status code was not 200 (' . wp_remote_retrieve_response_code( $response ) . ')');
     98            $this->error = new IXR_Error( -32301, 'transport error - HTTP status code was not 200 (' . wp_remote_retrieve_response_code( $response ) . ')' );
    10099            return false;
    101100        }
     
    109108        if ( ! $this->message->parse() ) {
    110109            // XML error
    111             $this->error = new IXR_Error(-32700, 'parse error. not well formed');
     110            $this->error = new IXR_Error( -32700, 'parse error. not well formed' );
    112111            return false;
    113112        }
     
    115114        // Is the message a fault?
    116115        if ( $this->message->messageType == 'fault' ) {
    117             $this->error = new IXR_Error($this->message->faultCode, $this->message->faultString);
     116            $this->error = new IXR_Error( $this->message->faultCode, $this->message->faultString );
    118117            return false;
    119118        }
Note: See TracChangeset for help on using the changeset viewer.