diff --git a/src/Exception.php b/src/Exception.php index af92e19b1..f7b20ec93 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -34,7 +34,7 @@ class Exception extends PHPException { * * @var boolean */ - public $failed_hook_handled = FALSE; + public $failed_hook_handled = false; /** * Create a new exception diff --git a/src/Exception/InvalidArgument.php b/src/Exception/InvalidArgument.php index 2536bea77..f6d69ee81 100644 --- a/src/Exception/InvalidArgument.php +++ b/src/Exception/InvalidArgument.php @@ -17,7 +17,7 @@ final class InvalidArgument extends InvalidArgumentException { * * @var boolean */ - public $failed_hook_handled = FALSE; + public $failed_hook_handled = false; /** * Create a new invalid argument exception with a standardized text. diff --git a/src/Requests.php b/src/Requests.php index bc4757f24..206d73502 100644 --- a/src/Requests.php +++ b/src/Requests.php @@ -474,16 +474,16 @@ public static function request($url, $headers = [], $data = [], $type = self::GE $parsed_response = self::parse_response($response, $url, $headers, $data, $options); } catch (Exception $e) { - if ($e->failed_hook_handled === FALSE) { + if ($e->failed_hook_handled === false) { $options['hooks']->dispatch('requests.failed', [&$e, $url, $headers, $data, $type, $options]); - $e->failed_hook_handled = TRUE; + $e->failed_hook_handled = true; } throw $e; } catch (InvalidArgument $e) { - if ($e->failed_hook_handled === FALSE) { + if ($e->failed_hook_handled === false) { $options['hooks']->dispatch('requests.failed', [&$e, $url, $headers, $data, $type, $options]); - $e->failed_hook_handled = TRUE; + $e->failed_hook_handled = true; } throw $e; diff --git a/tests/Fixtures/TransportRedirectMock.php b/tests/Fixtures/TransportRedirectMock.php index 6cc689e78..2fead036c 100644 --- a/tests/Fixtures/TransportRedirectMock.php +++ b/tests/Fixtures/TransportRedirectMock.php @@ -12,7 +12,7 @@ final class TransportRedirectMock implements Transport { private $redirected = []; - public $redirected_transport = NULL; + public $redirected_transport = null; private static $messages = [ 100 => '100 Continue', @@ -64,12 +64,11 @@ final class TransportRedirectMock implements Transport { ]; public function request($url, $headers = [], $data = [], $options = []) { - if (array_key_exists($url, $this->redirected)) - { + if (array_key_exists($url, $this->redirected)) { return $this->redirected_transport->request($url, $headers, $data, $options); } - $redirect_url = "https://example.com/redirected?url=" . urlencode($url); + $redirect_url = 'https://example.com/redirected?url=' . urlencode($url); $status = isset(self::$messages[$this->code]) ? self::$messages[$this->code] : $this->code . ' unknown'; $response = "HTTP/1.0 $status\r\n"; @@ -77,13 +76,14 @@ public function request($url, $headers = [], $data = [], $options = []) { if ($this->chunked) { $response .= "Transfer-Encoding: chunked\r\n"; } + $response .= "Location: $redirect_url\r\n"; $response .= $this->raw_headers; $response .= "Connection: close\r\n\r\n"; $response .= $this->body; - $this->redirected[$url] = TRUE; - $this->redirected[$redirect_url] = TRUE; + $this->redirected[$url] = true; + $this->redirected[$redirect_url] = true; return $response; } diff --git a/tests/Requests/RequestsTest.php b/tests/Requests/RequestsTest.php index bf80d5e3e..58b6b3ab4 100644 --- a/tests/Requests/RequestsTest.php +++ b/tests/Requests/RequestsTest.php @@ -408,7 +408,7 @@ public function testRedirectToExceptionTriggersRequestsFailedCallbackOnce() { $transport = new TransportRedirectMock(); $transport->redirected_transport = new TransportFailedMock(); - $options = [ + $options = [ 'hooks' => $hooks, 'transport' => $transport, ]; @@ -431,7 +431,7 @@ public function testRedirectToInvalidArgumentTriggersRequestsFailedCallbackOnce( $transport = new TransportRedirectMock(); $transport->redirected_transport = new TransportInvalidArgumentMock(); - $options = [ + $options = [ 'hooks' => $hooks, 'transport' => $transport, ];