Skip to content

Commit

Permalink
Requests: Fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pprkut committed Sep 8, 2023
1 parent 773103c commit 2252a18
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Exception extends PHPException {
*
* @var boolean
*/
public $failed_hook_handled = FALSE;
public $failed_hook_handled = false;

/**
* Create a new exception
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidArgument.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions src/Requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions tests/Fixtures/TransportRedirectMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -64,26 +64,26 @@ 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";
$response .= "Content-Type: text/plain\r\n";
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;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Requests/RequestsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public function testRedirectToExceptionTriggersRequestsFailedCallbackOnce() {
$transport = new TransportRedirectMock();
$transport->redirected_transport = new TransportFailedMock();

$options = [
$options = [
'hooks' => $hooks,
'transport' => $transport,
];
Expand All @@ -431,7 +431,7 @@ public function testRedirectToInvalidArgumentTriggersRequestsFailedCallbackOnce(
$transport = new TransportRedirectMock();
$transport->redirected_transport = new TransportInvalidArgumentMock();

$options = [
$options = [
'hooks' => $hooks,
'transport' => $transport,
];
Expand Down

0 comments on commit 2252a18

Please sign in to comment.