diff --git a/bin/create_pear_package.php b/bin/create_pear_package.php index 326770929..8f0589464 100755 --- a/bin/create_pear_package.php +++ b/bin/create_pear_package.php @@ -33,9 +33,9 @@ ); $context['files'] = ''; -$path = realpath(dirname(__FILE__).'/../library/Requests'); +$path = realpath(dirname(__FILE__) . '/../library/Requests'); foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::LEAVES_ONLY) as $file) { - if (preg_match('/\.php$/', $file)) { + if (preg_match('/\.php$/', $file)) { $name = str_replace($path . DIRECTORY_SEPARATOR, '', $file); $name = str_replace(DIRECTORY_SEPARATOR, '/', $name); $context['files'][] = "\t\t\t\t\t" . ''; @@ -44,9 +44,9 @@ $context['files'] = implode("\n", $context['files']); -$template = file_get_contents(dirname(__FILE__).'/../package.xml.tpl'); +$template = file_get_contents(dirname(__FILE__) . '/../package.xml.tpl'); $content = preg_replace_callback('/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/', 'replace_parameters', $template); -file_put_contents(dirname(__FILE__).'/../package.xml', $content); +file_put_contents(dirname(__FILE__) . '/../package.xml', $content); function replace_parameters($matches) { global $context; diff --git a/examples/basic-auth.php b/examples/basic-auth.php index 6150dcb5d..b65e23bb7 100644 --- a/examples/basic-auth.php +++ b/examples/basic-auth.php @@ -13,4 +13,4 @@ $request = Requests::get('http://httpbin.org/basic-auth/someuser/password', array(), $options); // Check what we received -var_dump($request); \ No newline at end of file +var_dump($request); diff --git a/examples/cookie.php b/examples/cookie.php index d1b955294..cb90c5843 100644 --- a/examples/cookie.php +++ b/examples/cookie.php @@ -13,4 +13,4 @@ $request = Requests::get('http://httpbin.org/cookies', array('Cookie' => $c->formatForHeader())); // Check what we received -var_dump($request); \ No newline at end of file +var_dump($request); diff --git a/examples/cookie_jar.php b/examples/cookie_jar.php index d0f239679..0083b5795 100644 --- a/examples/cookie_jar.php +++ b/examples/cookie_jar.php @@ -7,7 +7,7 @@ Requests::register_autoloader(); // Say you need to fake a login cookie -$c = new Requests_Cookie_Jar(['login_uid' => 'something']); +$c = new Requests_Cookie_Jar(['login_uid' => 'something']); // Now let's make a request! $request = Requests::get( @@ -17,4 +17,4 @@ ); // Check what we received -var_dump($request); \ No newline at end of file +var_dump($request); diff --git a/examples/get.php b/examples/get.php index 1f4585972..bb6d57f9f 100644 --- a/examples/get.php +++ b/examples/get.php @@ -10,4 +10,4 @@ $request = Requests::get('http://httpbin.org/get', array('Accept' => 'application/json')); // Check what we received -var_dump($request); \ No newline at end of file +var_dump($request); diff --git a/examples/multiple.php b/examples/multiple.php index 46bacb0e6..abce996ca 100644 --- a/examples/multiple.php +++ b/examples/multiple.php @@ -42,4 +42,4 @@ function my_callback(&$request, $id) { // my_callback() anyway! // // If you don't believe me, uncomment this: -# var_dump($responses); \ No newline at end of file +# var_dump($responses); diff --git a/examples/post.php b/examples/post.php index 35f413808..c91cf2841 100644 --- a/examples/post.php +++ b/examples/post.php @@ -10,4 +10,4 @@ $request = Requests::post('http://httpbin.org/post', array(), array('mydata' => 'something')); // Check what we received -var_dump($request); \ No newline at end of file +var_dump($request); diff --git a/examples/proxy.php b/examples/proxy.php index 6f06dcc9a..4fe15dd8e 100644 --- a/examples/proxy.php +++ b/examples/proxy.php @@ -12,7 +12,7 @@ // If you need to authenticate, use the following syntax: // 'proxy' => array( '127.0.0.1:8080', 'username', 'password' ), ); -$request = Requests::get('http://httpbin.org/ip', array(), $options ); +$request = Requests::get('http://httpbin.org/ip', array(), $options); // See result var_dump($request->body); diff --git a/library/Requests.php b/library/Requests.php index 9bba88163..fa3c87639 100644 --- a/library/Requests.php +++ b/library/Requests.php @@ -535,7 +535,7 @@ protected static function get_default_options($multirequest = false) { * @return string Default certificate path. */ public static function get_certificate_path() { - if ( ! empty( Requests::$certificate_path ) ) { + if (!empty(Requests::$certificate_path)) { return Requests::$certificate_path; } @@ -547,7 +547,7 @@ public static function get_certificate_path() { * * @param string $path Certificate path, pointing to a PEM file. */ - public static function set_certificate_path( $path ) { + public static function set_certificate_path($path) { Requests::$certificate_path = $path; } @@ -755,8 +755,6 @@ protected static function decode_chunked($data) { return $data; } - - $decoded = ''; $encoded = $data; diff --git a/library/Requests/Auth.php b/library/Requests/Auth.php index f5bc78bb0..914c7449c 100644 --- a/library/Requests/Auth.php +++ b/library/Requests/Auth.php @@ -30,4 +30,4 @@ interface Requests_Auth { * @param Requests_Hooks $hooks Hook system */ public function register(Requests_Hooks $hooks); -} \ No newline at end of file +} diff --git a/library/Requests/Auth/Basic.php b/library/Requests/Auth/Basic.php index 469e1d4d8..68d15bd5d 100644 --- a/library/Requests/Auth/Basic.php +++ b/library/Requests/Auth/Basic.php @@ -85,4 +85,4 @@ public function fsockopen_header(&$out) { public function getAuthString() { return $this->user . ':' . $this->pass; } -} \ No newline at end of file +} diff --git a/library/Requests/Cookie/Jar.php b/library/Requests/Cookie/Jar.php index b47948755..e65a448f6 100644 --- a/library/Requests/Cookie/Jar.php +++ b/library/Requests/Cookie/Jar.php @@ -172,4 +172,4 @@ public function before_redirect_check(Requests_Response $return) { $this->cookies = array_merge($this->cookies, $cookies); $return->cookies = $this; } -} \ No newline at end of file +} diff --git a/library/Requests/Exception.php b/library/Requests/Exception.php index 37d4711c1..1080efd97 100644 --- a/library/Requests/Exception.php +++ b/library/Requests/Exception.php @@ -59,4 +59,4 @@ public function getType() { public function getData() { return $this->data; } -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP.php b/library/Requests/Exception/HTTP.php index 9ac6a873d..42ac59095 100644 --- a/library/Requests/Exception/HTTP.php +++ b/library/Requests/Exception/HTTP.php @@ -68,4 +68,4 @@ public static function get_class($code) { return 'Requests_Exception_HTTP_Unknown'; } -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/304.php b/library/Requests/Exception/HTTP/304.php index 679903358..2636ba451 100644 --- a/library/Requests/Exception/HTTP/304.php +++ b/library/Requests/Exception/HTTP/304.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_304 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Not Modified'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/400.php b/library/Requests/Exception/HTTP/400.php index b3ad77435..5bd5428c0 100644 --- a/library/Requests/Exception/HTTP/400.php +++ b/library/Requests/Exception/HTTP/400.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_400 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Bad Request'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/401.php b/library/Requests/Exception/HTTP/401.php index 2e1e3d0b2..62a283ab0 100644 --- a/library/Requests/Exception/HTTP/401.php +++ b/library/Requests/Exception/HTTP/401.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_401 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Unauthorized'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/402.php b/library/Requests/Exception/HTTP/402.php index 1d965d232..f287fd4b2 100644 --- a/library/Requests/Exception/HTTP/402.php +++ b/library/Requests/Exception/HTTP/402.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_402 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Payment Required'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/403.php b/library/Requests/Exception/HTTP/403.php index 5ca3cafc1..2ae1c4445 100644 --- a/library/Requests/Exception/HTTP/403.php +++ b/library/Requests/Exception/HTTP/403.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_403 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Forbidden'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/404.php b/library/Requests/Exception/HTTP/404.php index f08be2d27..e6e28672c 100644 --- a/library/Requests/Exception/HTTP/404.php +++ b/library/Requests/Exception/HTTP/404.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_404 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Not Found'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/405.php b/library/Requests/Exception/HTTP/405.php index b8419e1ee..0461e6108 100644 --- a/library/Requests/Exception/HTTP/405.php +++ b/library/Requests/Exception/HTTP/405.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_405 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Method Not Allowed'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/406.php b/library/Requests/Exception/HTTP/406.php index 09d0622b1..980ef0efc 100644 --- a/library/Requests/Exception/HTTP/406.php +++ b/library/Requests/Exception/HTTP/406.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_406 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Not Acceptable'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/407.php b/library/Requests/Exception/HTTP/407.php index c21d1ec64..d08c6af7c 100644 --- a/library/Requests/Exception/HTTP/407.php +++ b/library/Requests/Exception/HTTP/407.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_407 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Proxy Authentication Required'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/408.php b/library/Requests/Exception/HTTP/408.php index 0691863a9..db15bc291 100644 --- a/library/Requests/Exception/HTTP/408.php +++ b/library/Requests/Exception/HTTP/408.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_408 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Request Timeout'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/409.php b/library/Requests/Exception/HTTP/409.php index 5a3e0d1f1..83002f936 100644 --- a/library/Requests/Exception/HTTP/409.php +++ b/library/Requests/Exception/HTTP/409.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_409 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Conflict'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/410.php b/library/Requests/Exception/HTTP/410.php index 8eb3dafa6..5bf7aa6d4 100644 --- a/library/Requests/Exception/HTTP/410.php +++ b/library/Requests/Exception/HTTP/410.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_410 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Gone'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/411.php b/library/Requests/Exception/HTTP/411.php index cee6496ac..25517b4f3 100644 --- a/library/Requests/Exception/HTTP/411.php +++ b/library/Requests/Exception/HTTP/411.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_411 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Length Required'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/412.php b/library/Requests/Exception/HTTP/412.php index e377d7975..e89533a7e 100644 --- a/library/Requests/Exception/HTTP/412.php +++ b/library/Requests/Exception/HTTP/412.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_412 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Precondition Failed'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/413.php b/library/Requests/Exception/HTTP/413.php index 3b5fe276a..a7b38fce1 100644 --- a/library/Requests/Exception/HTTP/413.php +++ b/library/Requests/Exception/HTTP/413.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_413 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Request Entity Too Large'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/414.php b/library/Requests/Exception/HTTP/414.php index 14d5a59d3..54c8b8c9a 100644 --- a/library/Requests/Exception/HTTP/414.php +++ b/library/Requests/Exception/HTTP/414.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_414 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Request-URI Too Large'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/415.php b/library/Requests/Exception/HTTP/415.php index 32446c854..6b5f0785b 100644 --- a/library/Requests/Exception/HTTP/415.php +++ b/library/Requests/Exception/HTTP/415.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_415 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Unsupported Media Type'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/416.php b/library/Requests/Exception/HTTP/416.php index 8c5f833db..48a4ecdb8 100644 --- a/library/Requests/Exception/HTTP/416.php +++ b/library/Requests/Exception/HTTP/416.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_416 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Requested Range Not Satisfiable'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/417.php b/library/Requests/Exception/HTTP/417.php index 8807c7171..81570330a 100644 --- a/library/Requests/Exception/HTTP/417.php +++ b/library/Requests/Exception/HTTP/417.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_417 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Expectation Failed'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/418.php b/library/Requests/Exception/HTTP/418.php index d6af806c4..0fcc87d61 100644 --- a/library/Requests/Exception/HTTP/418.php +++ b/library/Requests/Exception/HTTP/418.php @@ -26,4 +26,4 @@ class Requests_Exception_HTTP_418 extends Requests_Exception_HTTP { * @var string */ protected $reason = "I'm A Teapot"; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/428.php b/library/Requests/Exception/HTTP/428.php index 469e95454..799ddffd5 100644 --- a/library/Requests/Exception/HTTP/428.php +++ b/library/Requests/Exception/HTTP/428.php @@ -26,4 +26,4 @@ class Requests_Exception_HTTP_428 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Precondition Required'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/429.php b/library/Requests/Exception/HTTP/429.php index 2a21fb345..78a3148ad 100644 --- a/library/Requests/Exception/HTTP/429.php +++ b/library/Requests/Exception/HTTP/429.php @@ -26,4 +26,4 @@ class Requests_Exception_HTTP_429 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Too Many Requests'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/431.php b/library/Requests/Exception/HTTP/431.php index ba1294e65..a92b48a4e 100644 --- a/library/Requests/Exception/HTTP/431.php +++ b/library/Requests/Exception/HTTP/431.php @@ -26,4 +26,4 @@ class Requests_Exception_HTTP_431 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Request Header Fields Too Large'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/500.php b/library/Requests/Exception/HTTP/500.php index 5165e353b..22a6406ab 100644 --- a/library/Requests/Exception/HTTP/500.php +++ b/library/Requests/Exception/HTTP/500.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_500 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Internal Server Error'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/501.php b/library/Requests/Exception/HTTP/501.php index 3dd694623..11f395b20 100644 --- a/library/Requests/Exception/HTTP/501.php +++ b/library/Requests/Exception/HTTP/501.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_501 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Not Implemented'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/502.php b/library/Requests/Exception/HTTP/502.php index 50c72d471..43f576a62 100644 --- a/library/Requests/Exception/HTTP/502.php +++ b/library/Requests/Exception/HTTP/502.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_502 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Bad Gateway'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/503.php b/library/Requests/Exception/HTTP/503.php index 9304ecc6b..4024a4f5c 100644 --- a/library/Requests/Exception/HTTP/503.php +++ b/library/Requests/Exception/HTTP/503.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_503 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Service Unavailable'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/504.php b/library/Requests/Exception/HTTP/504.php index f46696bc1..25fd08631 100644 --- a/library/Requests/Exception/HTTP/504.php +++ b/library/Requests/Exception/HTTP/504.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_504 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Gateway Timeout'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/505.php b/library/Requests/Exception/HTTP/505.php index 1f80294e2..1f7cfec9b 100644 --- a/library/Requests/Exception/HTTP/505.php +++ b/library/Requests/Exception/HTTP/505.php @@ -24,4 +24,4 @@ class Requests_Exception_HTTP_505 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'HTTP Version Not Supported'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/511.php b/library/Requests/Exception/HTTP/511.php index 920d334b1..3332513b1 100644 --- a/library/Requests/Exception/HTTP/511.php +++ b/library/Requests/Exception/HTTP/511.php @@ -26,4 +26,4 @@ class Requests_Exception_HTTP_511 extends Requests_Exception_HTTP { * @var string */ protected $reason = 'Network Authentication Required'; -} \ No newline at end of file +} diff --git a/library/Requests/Exception/HTTP/Unknown.php b/library/Requests/Exception/HTTP/Unknown.php index c70f58988..b7eeb7953 100644 --- a/library/Requests/Exception/HTTP/Unknown.php +++ b/library/Requests/Exception/HTTP/Unknown.php @@ -41,4 +41,4 @@ public function __construct($reason = null, $data = null) { parent::__construct($reason, $data); } -} \ No newline at end of file +} diff --git a/library/Requests/Hooker.php b/library/Requests/Hooker.php index f667ae9c5..c852931f1 100644 --- a/library/Requests/Hooker.php +++ b/library/Requests/Hooker.php @@ -30,4 +30,4 @@ public function register($hook, $callback, $priority = 0); * @return boolean Successfulness */ public function dispatch($hook, $parameters = array()); -} \ No newline at end of file +} diff --git a/library/Requests/Hooks.php b/library/Requests/Hooks.php index 2e61c7340..f857902ce 100644 --- a/library/Requests/Hooks.php +++ b/library/Requests/Hooks.php @@ -65,4 +65,4 @@ public function dispatch($hook, $parameters = array()) { return true; } -} \ No newline at end of file +} diff --git a/library/Requests/IDNAEncoder.php b/library/Requests/IDNAEncoder.php index fc2a5fd29..9fe35a258 100644 --- a/library/Requests/IDNAEncoder.php +++ b/library/Requests/IDNAEncoder.php @@ -190,9 +190,8 @@ protected static function utf8_to_codepoints($input) { $position--; } - if ( - // Non-shortest form sequences are invalid - $length > 1 && $character <= 0x7F + if (// Non-shortest form sequences are invalid + $length > 1 && $character <= 0x7F || $length > 2 && $character <= 0x7FF || $length > 3 && $character <= 0xFFFF // Outside of range of ucschar codepoints @@ -201,7 +200,7 @@ protected static function utf8_to_codepoints($input) { || $character >= 0xFDD0 && $character <= 0xFDEF || ( // Everything else not in ucschar - $character > 0xD7FF && $character < 0xF900 + $character > 0xD7FF && $character < 0xF900 || $character < 0x20 || $character > 0x7E && $character < 0xA0 || $character > 0xEFFFD @@ -381,4 +380,4 @@ protected static function adapt($delta, $numpoints, $firsttime) { // return k + (((base - tmin + 1) * delta) div (delta + skew)) return $k + floor(((self::BOOTSTRAP_BASE - self::BOOTSTRAP_TMIN + 1) * $delta) / ($delta + self::BOOTSTRAP_SKEW)); } -} \ No newline at end of file +} diff --git a/library/Requests/Proxy.php b/library/Requests/Proxy.php index 1f02d0613..0a798dbe9 100644 --- a/library/Requests/Proxy.php +++ b/library/Requests/Proxy.php @@ -32,4 +32,4 @@ interface Requests_Proxy { * @param Requests_Hooks $hooks Hook system */ public function register(Requests_Hooks $hooks); -} \ No newline at end of file +} diff --git a/library/Requests/Proxy/HTTP.php b/library/Requests/Proxy/HTTP.php index 82883b8cc..e2b8a87b8 100644 --- a/library/Requests/Proxy/HTTP.php +++ b/library/Requests/Proxy/HTTP.php @@ -148,4 +148,4 @@ public function fsockopen_header(&$out) { public function get_auth_string() { return $this->user . ':' . $this->pass; } -} \ No newline at end of file +} diff --git a/library/Requests/SSL.php b/library/Requests/SSL.php index 8da0c6a95..7d8af850a 100644 --- a/library/Requests/SSL.php +++ b/library/Requests/SSL.php @@ -149,4 +149,4 @@ public static function match_domain($host, $reference) { return false; } -} \ No newline at end of file +} diff --git a/library/Requests/Transport.php b/library/Requests/Transport.php index 7e4a26293..5146c01d8 100644 --- a/library/Requests/Transport.php +++ b/library/Requests/Transport.php @@ -38,4 +38,4 @@ public function request_multiple($requests, $options); * @return bool */ public static function test(); -} \ No newline at end of file +} diff --git a/library/Requests/Transport/cURL.php b/library/Requests/Transport/cURL.php index 24d55b563..e7a99f157 100644 --- a/library/Requests/Transport/cURL.php +++ b/library/Requests/Transport/cURL.php @@ -239,11 +239,11 @@ public function request_multiple($requests, $options) { //get error string for handle. $reason = curl_error($done['handle']); $exception = new Requests_Exception_Transport_cURL( - $reason, - Requests_Exception_Transport_cURL::EASY, - $done['handle'], - $done['result'] - ); + $reason, + Requests_Exception_Transport_cURL::EASY, + $done['handle'], + $done['result'] + ); $responses[$key] = $exception; $options['hooks']->dispatch('transport.internal.parse_error', array(&$responses[$key], $requests[$key])); } @@ -310,7 +310,7 @@ protected function setup_handle($url, $headers, $data, $options) { $options['hooks']->dispatch('curl.before_request', array(&$this->handle)); // Force closing the connection for old versions of cURL (<7.22). - if ( ! isset( $headers['Connection'] ) ) { + if (!isset($headers['Connection'])) { $headers['Connection'] = 'close'; } diff --git a/library/Requests/Transport/fsockopen.php b/library/Requests/Transport/fsockopen.php index ac2e22fc8..dee4649df 100644 --- a/library/Requests/Transport/fsockopen.php +++ b/library/Requests/Transport/fsockopen.php @@ -176,7 +176,7 @@ public function request($url, $headers = array(), $data = array(), $options = ar if (!isset($case_insensitive_headers['Host'])) { $out .= sprintf('Host: %s', $url_parts['host']); - if (( 'http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80 ) || ( 'https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443 )) { + if (('http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80) || ('https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443)) { $out .= ':' . $url_parts['port']; } $out .= "\r\n"; diff --git a/tests/Auth/Basic.php b/tests/Auth/Basic.php index b1d5af28b..8f8605245 100644 --- a/tests/Auth/Basic.php +++ b/tests/Auth/Basic.php @@ -74,7 +74,7 @@ public function testPOSTUsingInstantiation($transport) { $auth = explode(' ', $auth); $this->assertEquals(base64_encode('user:passwd'), $auth[1]); - $this->assertEquals('test', $result->data); + $this->assertEquals('test', $result->data); } /** @@ -84,4 +84,4 @@ public function testMissingPassword() { $auth = new Requests_Auth_Basic(array('user')); } -} \ No newline at end of file +} diff --git a/tests/ChunkedEncoding.php b/tests/ChunkedEncoding.php index 32ff92ffb..ffa41af5c 100644 --- a/tests/ChunkedEncoding.php +++ b/tests/ChunkedEncoding.php @@ -33,7 +33,7 @@ public static function chunkedProvider() { /** * @dataProvider chunkedProvider */ - public function testChunked($body, $expected){ + public function testChunked($body, $expected) { $transport = new MockTransport(); $transport->body = $body; $transport->chunked = true; @@ -48,12 +48,12 @@ public function testChunked($body, $expected){ public static function notChunkedProvider() { return array( - 'invalid chunk size' => array( 'Hello! This is a non-chunked response!' ), - 'invalid chunk extension' => array( '1BNot chunked\r\nLooks chunked but it is not\r\n' ), - 'unquoted chunk-ext-val with space' => array( "02;foo=unquoted with space\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n" ), - 'unquoted chunk-ext-val with forbidden character' => array( "02;foo={unquoted}\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n" ), - 'invalid chunk-ext-name' => array( "02;{foo}=bar\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n" ), - 'incomplete quote for chunk-ext-value' => array( "02;foo=\"no end quote\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n" ), + 'invalid chunk size' => array('Hello! This is a non-chunked response!'), + 'invalid chunk extension' => array('1BNot chunked\r\nLooks chunked but it is not\r\n'), + 'unquoted chunk-ext-val with space' => array("02;foo=unquoted with space\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n"), + 'unquoted chunk-ext-val with forbidden character' => array("02;foo={unquoted}\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n"), + 'invalid chunk-ext-name' => array("02;{foo}=bar\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n"), + 'incomplete quote for chunk-ext-value' => array("02;foo=\"no end quote\r\nab\r\n04\r\nra\nc\r\n06\r\nadabra\r\n0c\r\n\nall we got\n"), ); } @@ -90,4 +90,4 @@ public function testMixedChunkiness() { $response = Requests::get('http://example.com/', array(), $options); $this->assertEquals($transport->body, $response->body); } -} \ No newline at end of file +} diff --git a/tests/Cookies.php b/tests/Cookies.php index 9096a32da..c158c5d29 100644 --- a/tests/Cookies.php +++ b/tests/Cookies.php @@ -38,9 +38,11 @@ public function testCookieJarSetter() { $jar1 = new Requests_Cookie_Jar(); $jar1['requests-testcookie'] = 'testvalue'; - $jar2 = new Requests_Cookie_Jar(array( - 'requests-testcookie' => 'testvalue', - )); + $jar2 = new Requests_Cookie_Jar( + array( + 'requests-testcookie' => 'testvalue', + ) + ); $this->assertEquals($jar1, $jar2); } @@ -84,8 +86,8 @@ public function testReceivingCookies() { $response = Requests::get($url, array(), $options); $cookie = $response->cookies['requests-testcookie']; - $this->assertNotEmpty( $cookie ); - $this->assertEquals( 'testvalue', $cookie->value ); + $this->assertNotEmpty($cookie); + $this->assertEquals('testvalue', $cookie->value); } public function testPersistenceOnRedirect() { @@ -97,8 +99,8 @@ public function testPersistenceOnRedirect() { $response = Requests::get($url, array(), $options); $cookie = $response->cookies['requests-testcookie']; - $this->assertNotEmpty( $cookie ); - $this->assertEquals( 'testvalue', $cookie->value ); + $this->assertNotEmpty($cookie); + $this->assertEquals('testvalue', $cookie->value); } protected function setCookieRequest($cookies) { @@ -142,9 +144,11 @@ public function testCookieExpiration() { } public function testSendingCookieWithJar() { - $cookies = new Requests_Cookie_Jar(array( - 'requests-testcookie1' => 'testvalue1', - )); + $cookies = new Requests_Cookie_Jar( + array( + 'requests-testcookie1' => 'testvalue1', + ) + ); $data = $this->setCookieRequest($cookies); $this->assertArrayHasKey('requests-testcookie1', $data); @@ -166,10 +170,12 @@ public function testSendingMultipleCookies() { } public function testSendingMultipleCookiesWithJar() { - $cookies = new Requests_Cookie_Jar(array( - 'requests-testcookie1' => 'testvalue1', - 'requests-testcookie2' => 'testvalue2', - )); + $cookies = new Requests_Cookie_Jar( + array( + 'requests-testcookie1' => 'testvalue1', + 'requests-testcookie2' => 'testvalue2', + ) + ); $data = $this->setCookieRequest($cookies); $this->assertArrayHasKey('requests-testcookie1', $data); @@ -180,9 +186,11 @@ public function testSendingMultipleCookiesWithJar() { } public function testSendingPrebakedCookie() { - $cookies = new Requests_Cookie_Jar(array( - new Requests_Cookie('requests-testcookie', 'testvalue'), - )); + $cookies = new Requests_Cookie_Jar( + array( + new Requests_Cookie('requests-testcookie', 'testvalue'), + ) + ); $data = $this->setCookieRequest($cookies); $this->assertArrayHasKey('requests-testcookie', $data); @@ -191,23 +199,23 @@ public function testSendingPrebakedCookie() { public function domainMatchProvider() { return array( - array('example.com', 'example.com', true, true), + array('example.com', 'example.com', true, true), array('example.com', 'www.example.com', false, true), - array('example.com', 'example.net', false, false), + array('example.com', 'example.net', false, false), // Leading period - array('.example.com', 'example.com', true, true), + array('.example.com', 'example.com', true, true), array('.example.com', 'www.example.com', false, true), - array('.example.com', 'example.net', false, false), + array('.example.com', 'example.net', false, false), // Prefix, but not subdomain - array('example.com', 'notexample.com', false, false), - array('example.com', 'notexample.net', false, false), + array('example.com', 'notexample.com', false, false), + array('example.com', 'notexample.net', false, false), // Reject IP address prefixes - array('127.0.0.1', '127.0.0.1', true, true), - array('127.0.0.1', 'abc.127.0.0.1', false, false), - array('127.0.0.1', 'example.com', false, false), + array('127.0.0.1', '127.0.0.1', true, true), + array('127.0.0.1', 'abc.127.0.0.1', false, false), + array('127.0.0.1', 'example.com', false, false), // Check that we're checking the actual length array('127.com', 'test.127.com', false, true), @@ -239,21 +247,21 @@ public function testDomainMatch($original, $check, $matches, $domain_matches) { public function pathMatchProvider() { return array( - array('/', '', true), - array('/', '/', true), + array('/', '', true), + array('/', '/', true), - array('/', '/test', true), - array('/', '/test/', true), + array('/', '/test', true), + array('/', '/test/', true), - array('/test', '/', false), - array('/test', '/test', true), - array('/test', '/testing', false), - array('/test', '/test/', true), - array('/test', '/test/ing', true), - array('/test', '/test/ing/', true), + array('/test', '/', false), + array('/test', '/test', true), + array('/test', '/testing', false), + array('/test', '/test/', true), + array('/test', '/test/ing', true), + array('/test', '/test/ing/', true), array('/test/', '/test/', true), - array('/test/', '/', false), + array('/test/', '/', false), ); } @@ -270,27 +278,27 @@ public function testPathMatch($original, $check, $matches) { public function urlMatchProvider() { return array( // Domain handling - array( 'example.com', '/', 'http://example.com/', true, true ), - array( 'example.com', '/', 'http://www.example.com/', false, true ), - array( 'example.com', '/', 'http://example.net/', false, false ), - array( 'example.com', '/', 'http://www.example.net/', false, false ), + array('example.com', '/', 'http://example.com/', true, true), + array('example.com', '/', 'http://www.example.com/', false, true), + array('example.com', '/', 'http://example.net/', false, false), + array('example.com', '/', 'http://www.example.net/', false, false), // /test - array( 'example.com', '/test', 'http://example.com/', false, false ), - array( 'example.com', '/test', 'http://www.example.com/', false, false ), + array('example.com', '/test', 'http://example.com/', false, false), + array('example.com', '/test', 'http://www.example.com/', false, false), - array( 'example.com', '/test', 'http://example.com/test', true, true ), - array( 'example.com', '/test', 'http://www.example.com/test', false, true ), + array('example.com', '/test', 'http://example.com/test', true, true), + array('example.com', '/test', 'http://www.example.com/test', false, true), - array( 'example.com', '/test', 'http://example.com/testing', false, false ), - array( 'example.com', '/test', 'http://www.example.com/testing', false, false ), + array('example.com', '/test', 'http://example.com/testing', false, false), + array('example.com', '/test', 'http://www.example.com/testing', false, false), - array( 'example.com', '/test', 'http://example.com/test/', true, true ), - array( 'example.com', '/test', 'http://www.example.com/test/', false, true ), + array('example.com', '/test', 'http://example.com/test/', true, true), + array('example.com', '/test', 'http://www.example.com/test/', false, true), // /test/ - array( 'example.com', '/test/', 'http://example.com/', false, false ), - array( 'example.com', '/test/', 'http://www.example.com/', false, false ), + array('example.com', '/test/', 'http://example.com/', false, false), + array('example.com', '/test/', 'http://www.example.com/', false, false), ); } @@ -381,69 +389,69 @@ public static function parseResultProvider() { // RFC 822, updated by RFC 1123 array( 'foo=bar; Expires=Thu, 5-Dec-2013 04:50:12 GMT', - array( 'expired' => true ), - array( 'expires' => gmmktime( 4, 50, 12, 12, 5, 2013 ) ), + array('expired' => true), + array('expires' => gmmktime(4, 50, 12, 12, 5, 2013)), ), array( 'foo=bar; Expires=Fri, 5-Dec-2014 04:50:12 GMT', - array( 'expired' => false ), - array( 'expires' => gmmktime( 4, 50, 12, 12, 5, 2014 ) ), + array('expired' => false), + array('expires' => gmmktime(4, 50, 12, 12, 5, 2014)), ), // RFC 850, obsoleted by RFC 1036 array( 'foo=bar; Expires=Thursday, 5-Dec-2013 04:50:12 GMT', - array( 'expired' => true ), - array( 'expires' => gmmktime( 4, 50, 12, 12, 5, 2013 ) ), + array('expired' => true), + array('expires' => gmmktime(4, 50, 12, 12, 5, 2013)), ), array( 'foo=bar; Expires=Friday, 5-Dec-2014 04:50:12 GMT', - array( 'expired' => false ), - array( 'expires' => gmmktime( 4, 50, 12, 12, 5, 2014 ) ), + array('expired' => false), + array('expires' => gmmktime(4, 50, 12, 12, 5, 2014)), ), // asctime() array( 'foo=bar; Expires=Thu Dec 5 04:50:12 2013', - array( 'expired' => true ), - array( 'expires' => gmmktime( 4, 50, 12, 12, 5, 2013 ) ), + array('expired' => true), + array('expires' => gmmktime(4, 50, 12, 12, 5, 2013)), ), array( 'foo=bar; Expires=Fri Dec 5 04:50:12 2014', - array( 'expired' => false ), - array( 'expires' => gmmktime( 4, 50, 12, 12, 5, 2014 ) ), + array('expired' => false), + array('expires' => gmmktime(4, 50, 12, 12, 5, 2014)), ), array( // Invalid 'foo=bar; Expires=never', array(), - array( 'expires' => null ), + array('expires' => null), ), // Max-Age array( 'foo=bar; Max-Age=10', - array( 'expired' => false ), - array( 'max-age' => gmmktime( 0, 0, 10, 1, 1, 2014 ) ), + array('expired' => false), + array('max-age' => gmmktime(0, 0, 10, 1, 1, 2014)), ), array( 'foo=bar; Max-Age=3660', - array( 'expired' => false ), - array( 'max-age' => gmmktime( 1, 1, 0, 1, 1, 2014 ) ), + array('expired' => false), + array('max-age' => gmmktime(1, 1, 0, 1, 1, 2014)), ), array( 'foo=bar; Max-Age=0', - array( 'expired' => true ), - array( 'max-age' => 0 ), + array('expired' => true), + array('max-age' => 0), ), array( 'foo=bar; Max-Age=-1000', - array( 'expired' => true ), - array( 'max-age' => 0 ), + array('expired' => true), + array('max-age' => 0), ), array( // Invalid (non-digit character) 'foo=bar; Max-Age=1e6', - array( 'expired' => false ), - array( 'max-age' => null ), + array('expired' => false), + array('max-age' => null), ) ); } @@ -475,7 +483,7 @@ protected function check_parsed_cookie($cookie, $expected, $expected_attributes, */ public function testParsingHeader($header, $expected, $expected_attributes = array(), $expected_flags = array()) { // Set the reference time to 2014-01-01 00:00:00 - $reference_time = gmmktime( 0, 0, 0, 1, 1, 2014 ); + $reference_time = gmmktime(0, 0, 0, 1, 1, 2014); $cookie = Requests_Cookie::parse($header, null, $reference_time); $this->check_parsed_cookie($cookie, $expected, $expected_attributes); @@ -488,7 +496,7 @@ public function testParsingHeader($header, $expected, $expected_attributes = arr */ public function testParsingHeaderDouble($header, $expected, $expected_attributes = array(), $expected_flags = array()) { // Set the reference time to 2014-01-01 00:00:00 - $reference_time = gmmktime( 0, 0, 0, 1, 1, 2014 ); + $reference_time = gmmktime(0, 0, 0, 1, 1, 2014); $cookie = Requests_Cookie::parse($header, null, $reference_time); @@ -506,7 +514,7 @@ public function testParsingHeaderObject($header, $expected, $expected_attributes $headers['Set-Cookie'] = $header; // Set the reference time to 2014-01-01 00:00:00 - $reference_time = gmmktime( 0, 0, 0, 1, 1, 2014 ); + $reference_time = gmmktime(0, 0, 0, 1, 1, 2014); $parsed = Requests_Cookie::parse_from_headers($headers, null, $reference_time); $this->assertCount(1, $parsed); @@ -522,36 +530,36 @@ public function parseFromHeadersProvider() { 'name=value', 'http://example.com/', array(), - array( 'path' => '/' ), - array( 'host-only' => true ), + array('path' => '/'), + array('host-only' => true), ), array( 'name=value', 'http://example.com/test', array(), - array( 'path' => '/' ), - array( 'host-only' => true ), + array('path' => '/'), + array('host-only' => true), ), array( 'name=value', 'http://example.com/test/', array(), - array( 'path' => '/test' ), - array( 'host-only' => true ), + array('path' => '/test'), + array('host-only' => true), ), array( 'name=value', 'http://example.com/test/abc', array(), - array( 'path' => '/test' ), - array( 'host-only' => true ), + array('path' => '/test'), + array('host-only' => true), ), array( 'name=value', 'http://example.com/test/abc/', array(), - array( 'path' => '/test/abc' ), - array( 'host-only' => true ), + array('path' => '/test/abc'), + array('host-only' => true), ), # With specified path @@ -559,22 +567,22 @@ public function parseFromHeadersProvider() { 'name=value; path=/', 'http://example.com/', array(), - array( 'path' => '/' ), - array( 'host-only' => true ), + array('path' => '/'), + array('host-only' => true), ), array( 'name=value; path=/test', 'http://example.com/', array(), - array( 'path' => '/test' ), - array( 'host-only' => true ), + array('path' => '/test'), + array('host-only' => true), ), array( 'name=value; path=/test/', 'http://example.com/', array(), - array( 'path' => '/test/' ), - array( 'host-only' => true ), + array('path' => '/test/'), + array('host-only' => true), ), # Invalid path @@ -582,22 +590,22 @@ public function parseFromHeadersProvider() { 'name=value; path=yolo', 'http://example.com/', array(), - array( 'path' => '/' ), - array( 'host-only' => true ), + array('path' => '/'), + array('host-only' => true), ), array( 'name=value; path=yolo', 'http://example.com/test/', array(), - array( 'path' => '/test' ), - array( 'host-only' => true ), + array('path' => '/test'), + array('host-only' => true), ), # Cross-origin cookies, reject! array( 'name=value; domain=example.org', 'http://example.com/', - array( 'invalid' => false ), + array('invalid' => false), ), # Empty Domain @@ -612,15 +620,15 @@ public function parseFromHeadersProvider() { 'name=value; domain=test.example.com', 'http://test.example.com/', array(), - array( 'domain' => 'test.example.com' ), - array( 'host-only' => false ) + array('domain' => 'test.example.com'), + array('host-only' => false) ), array( 'name=value; domain=example.com', 'http://test.example.com/', array(), - array( 'domain' => 'example.com' ), - array( 'host-only' => false ) + array('domain' => 'example.com'), + array('host-only' => false) ), ); } @@ -634,7 +642,7 @@ public function testParsingHeaderWithOrigin($header, $origin, $expected, $expect $headers['Set-Cookie'] = $header; // Set the reference time to 2014-01-01 00:00:00 - $reference_time = gmmktime( 0, 0, 0, 1, 1, 2014 ); + $reference_time = gmmktime(0, 0, 0, 1, 1, 2014); $parsed = Requests_Cookie::parse_from_headers($headers, $origin, $reference_time); if (isset($expected['invalid'])) { diff --git a/tests/Encoding.php b/tests/Encoding.php index 7e2f13849..da8f1a3fc 100644 --- a/tests/Encoding.php +++ b/tests/Encoding.php @@ -87,8 +87,8 @@ public function testCompatibleInflate($original, $encoded) { protected function bin2hex($field) { $field = bin2hex($field); - $field = chunk_split($field,2,"\\x"); - $field = "\\x" . substr($field,0,-2); + $field = chunk_split($field, 2, "\\x"); + $field = "\\x" . substr($field, 0, -2); return $field; } } diff --git a/tests/IDNAEncoder.php b/tests/IDNAEncoder.php index 24df2deff..071fdf54c 100644 --- a/tests/IDNAEncoder.php +++ b/tests/IDNAEncoder.php @@ -99,4 +99,4 @@ public function testUnfinishedMultibyte() { public function testPartialMultibyte() { $result = Requests_IDNAEncoder::encode("\xc2\xc2\xb6"); } -} \ No newline at end of file +} diff --git a/tests/Requests.php b/tests/Requests.php index 0ebdfe46e..a95d3e809 100644 --- a/tests/Requests.php +++ b/tests/Requests.php @@ -19,16 +19,16 @@ public function testDefaultTransport() { public function testHeaderParsing() { $transport = new RawTransport(); $transport->data = - "HTTP/1.0 200 OK\r\n". - "Host: localhost\r\n". - "Host: ambiguous\r\n". - "Nospace:here\r\n". - "Muchspace: there \r\n". - "Empty:\r\n". - "Empty2: \r\n". - "Folded: one\r\n". - "\ttwo\r\n". - " three\r\n\r\n". + "HTTP/1.0 200 OK\r\n" . + "Host: localhost\r\n" . + "Host: ambiguous\r\n" . + "Nospace:here\r\n" . + "Muchspace: there \r\n" . + "Empty:\r\n" . + "Empty2: \r\n" . + "Folded: one\r\n" . + "\ttwo\r\n" . + " three\r\n\r\n" . "stop\r\n"; $options = array( @@ -54,7 +54,7 @@ public function testHeaderParsing() { public function testProtocolVersionParsing() { $transport = new RawTransport(); $transport->data = - "HTTP/1.0 200 OK\r\n". + "HTTP/1.0 200 OK\r\n" . "Host: localhost\r\n\r\n"; $options = array( @@ -68,8 +68,8 @@ public function testProtocolVersionParsing() { public function testRawAccess() { $transport = new RawTransport(); $transport->data = - "HTTP/1.0 200 OK\r\n". - "Host: localhost\r\n\r\n". + "HTTP/1.0 200 OK\r\n" . + "Host: localhost\r\n\r\n" . "Test"; $options = array( diff --git a/tests/Response/Headers.php b/tests/Response/Headers.php index 7541f374a..c779af665 100644 --- a/tests/Response/Headers.php +++ b/tests/Response/Headers.php @@ -52,4 +52,4 @@ public function testMultipleHeaders() { $this->assertEquals('text/html;q=1.0,*/*;q=0.1', $headers['Accept']); } -} \ No newline at end of file +} diff --git a/tests/SSL.php b/tests/SSL.php index 62bb998df..364484ee6 100644 --- a/tests/SSL.php +++ b/tests/SSL.php @@ -100,7 +100,7 @@ public function testInvalidCNFallback() { * @link http://tools.ietf.org/html/rfc2818#section-3.1 */ public function testIgnoreCNWithSAN() { - $certificate = $this->fakeCertificate('example.net', 'example.com'); + $certificate = $this->fakeCertificate('example.net', 'example.com'); $this->assertTrue(Requests_SSL::verify_certificate('example.com', $certificate), 'Checking SAN validation'); $this->assertFalse(Requests_SSL::verify_certificate('example.net', $certificate), 'Checking CN non-validation'); diff --git a/tests/Transport/Base.php b/tests/Transport/Base.php index a26c9473d..8321cbf66 100644 --- a/tests/Transport/Base.php +++ b/tests/Transport/Base.php @@ -24,16 +24,17 @@ public function setUp() { * @param string $message * @param int|string $code */ - public function setExpectedException( $exception, $message = '', $code = null ) { - if ( method_exists( 'PHPUnit_Framework_TestCase', 'setExpectedException' ) ) { - parent::setExpectedException( $exception, $message, $code ); - } else { - $this->expectException( $exception ); - if ( null !== $message ) { - $this->expectExceptionMessage( $message ); + public function setExpectedException($exception, $message = '', $code = null) { + if (method_exists('PHPUnit_Framework_TestCase', 'setExpectedException')) { + parent::setExpectedException($exception, $message, $code); + } + else { + $this->expectException($exception); + if (null !== $message) { + $this->expectExceptionMessage($message); } - if ( null !== $code ) { - $this->expectExceptionCode( $code ); + if (null !== $code) { + $this->expectExceptionCode($code); } } } @@ -446,7 +447,7 @@ public function testStatusCodeThrowAllowRedirects($code, $success) { $request->throw_for_status(true); } - public function testStatusCodeUnknown(){ + public function testStatusCodeUnknown() { $transport = new MockTransport(); $transport->code = 599; @@ -462,7 +463,7 @@ public function testStatusCodeUnknown(){ /** * @expectedException Requests_Exception_HTTP_Unknown */ - public function testStatusCodeThrowUnknown(){ + public function testStatusCodeThrowUnknown() { $transport = new MockTransport(); $transport->code = 599; @@ -776,11 +777,13 @@ public function testMultipleToFile() { public function testAlternatePort() { try { $request = Requests::get('http://portquiz.net:8080/', array(), $this->getOptions()); - } catch( Requests_Exception $e ) { + } + catch (Requests_Exception $e) { // Retry the request as it often times-out. try { $request = Requests::get('http://portquiz.net:8080/', array(), $this->getOptions()); - } catch( Requests_Exception $e ) { + } + catch (Requests_Exception $e) { // If it still times out, mark the test as skipped. $this->markTestSkipped( $e->getMessage() @@ -854,7 +857,7 @@ public function testQueryDataFormat() { $this->assertEquals(200, $request->status_code); $result = json_decode($request->body, true); - $this->assertEquals(httpbin('/post').'?test=true&test2=test', $result['url']); + $this->assertEquals(httpbin('/post') . '?test=true&test2=test', $result['url']); $this->assertEquals('', $result['data']); } diff --git a/tests/Transport/cURL.php b/tests/Transport/cURL.php index 55390adc2..f01b7fdcc 100644 --- a/tests/Transport/cURL.php +++ b/tests/Transport/cURL.php @@ -2,4 +2,4 @@ class RequestsTest_Transport_cURL extends RequestsTest_Transport_Base { protected $transport = 'Requests_Transport_cURL'; -} \ No newline at end of file +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 3aac4d170..b13335d84 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -3,8 +3,8 @@ /** * Compatibility with PHPUnit 6+ */ -if ( class_exists( 'PHPUnit\Runner\Version' ) ) { - require_once dirname( __FILE__ ) . '/phpunit6-compat.php'; +if (class_exists('PHPUnit\Runner\Version')) { + require_once dirname(__FILE__) . '/phpunit6-compat.php'; } date_default_timezone_set('UTC'); @@ -47,7 +47,7 @@ function autoload_tests($class) { function httpbin($suffix = '', $ssl = false) { $host = $ssl ? 'https://' . REQUESTS_TEST_HOST_HTTPS : 'http://' . REQUESTS_TEST_HOST_HTTP; - return rtrim( $host, '/' ) . '/' . ltrim( $suffix, '/' ); + return rtrim($host, '/') . '/' . ltrim($suffix, '/'); } class MockTransport implements Requests_Transport { diff --git a/tests/phpunit6-compat.php b/tests/phpunit6-compat.php index 409afb1bb..8eb119583 100644 --- a/tests/phpunit6-compat.php +++ b/tests/phpunit6-compat.php @@ -1,17 +1,16 @@ =' ) ) { - - class_alias( 'PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase' ); - class_alias( 'PHPUnit\Framework\Exception', 'PHPUnit_Framework_Exception' ); - class_alias( 'PHPUnit\Framework\ExpectationFailedException', 'PHPUnit_Framework_ExpectationFailedException' ); - class_alias( 'PHPUnit\Framework\Error\Notice', 'PHPUnit_Framework_Error_Notice' ); - class_alias( 'PHPUnit\Framework\Error\Warning', 'PHPUnit_Framework_Error_Warning' ); - class_alias( 'PHPUnit\Framework\Test', 'PHPUnit_Framework_Test' ); - class_alias( 'PHPUnit\Framework\Warning', 'PHPUnit_Framework_Warning' ); - class_alias( 'PHPUnit\Framework\AssertionFailedError', 'PHPUnit_Framework_AssertionFailedError' ); - class_alias( 'PHPUnit\Framework\TestSuite', 'PHPUnit_Framework_TestSuite' ); - class_alias( 'PHPUnit\Framework\TestListener', 'PHPUnit_Framework_TestListener' ); - class_alias( 'PHPUnit\Util\GlobalState', 'PHPUnit_Util_GlobalState' ); - class_alias( 'PHPUnit\Util\Getopt', 'PHPUnit_Util_Getopt' ); +if (class_exists('PHPUnit\Runner\Version') && version_compare(PHPUnit\Runner\Version::id(), '6.0', '>=')) { + class_alias('PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase'); + class_alias('PHPUnit\Framework\Exception', 'PHPUnit_Framework_Exception'); + class_alias('PHPUnit\Framework\ExpectationFailedException', 'PHPUnit_Framework_ExpectationFailedException'); + class_alias('PHPUnit\Framework\Error\Notice', 'PHPUnit_Framework_Error_Notice'); + class_alias('PHPUnit\Framework\Error\Warning', 'PHPUnit_Framework_Error_Warning'); + class_alias('PHPUnit\Framework\Test', 'PHPUnit_Framework_Test'); + class_alias('PHPUnit\Framework\Warning', 'PHPUnit_Framework_Warning'); + class_alias('PHPUnit\Framework\AssertionFailedError', 'PHPUnit_Framework_AssertionFailedError'); + class_alias('PHPUnit\Framework\TestSuite', 'PHPUnit_Framework_TestSuite'); + class_alias('PHPUnit\Framework\TestListener', 'PHPUnit_Framework_TestListener'); + class_alias('PHPUnit\Util\GlobalState', 'PHPUnit_Util_GlobalState'); + class_alias('PHPUnit\Util\Getopt', 'PHPUnit_Util_Getopt'); }