Skip to content

Commit

Permalink
Requests: Fix style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pprkut authored and SMillerDev committed Aug 8, 2022
1 parent ff956ae commit 7f44b05
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 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
8 changes: 4 additions & 4 deletions tests/Requests/RequestsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
use WpOrg\Requests\Iri;
use WpOrg\Requests\Requests;
use WpOrg\Requests\Response\Headers;
use WpOrg\Requests\Tests\Fixtures\RawTransportMock;
use WpOrg\Requests\Tests\Fixtures\StringableObject;
use WpOrg\Requests\Tests\Fixtures\TransportMock;
use WpOrg\Requests\Tests\Fixtures\RawTransportMock;
use WpOrg\Requests\Tests\Fixtures\TestTransportMock;
use WpOrg\Requests\Tests\Fixtures\TransportFailedMock;
use WpOrg\Requests\Tests\Fixtures\TransportInvalidArgumentMock;
use WpOrg\Requests\Tests\Fixtures\TransportMock;
use WpOrg\Requests\Tests\TestCase;
use WpOrg\Requests\Tests\TypeProviderHelper;
use WpOrg\Requests\Tests\Fixtures\TransportRedirectMock;
Expand Down Expand Up @@ -410,7 +410,7 @@ public function testRedirectToExceptionTriggersRequestsFailedCallbackOnce() {
$transport = new TransportRedirectMock();
$transport->redirected_transport = new TransportFailedMock();

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

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

0 comments on commit 7f44b05

Please sign in to comment.