From 8ee278e1eb5f5fe4eeba9dcae223207d810accd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Pude=C5=82ek?= Date: Wed, 28 Nov 2018 21:52:49 +0100 Subject: [PATCH] pretty fix --- lib/Auth/AWS.php | 2 +- lib/Client.php | 8 +++++--- lib/Message.php | 10 +++++----- lib/MessageDecoratorTrait.php | 2 +- lib/MessageInterface.php | 7 +------ lib/RequestInterface.php | 6 ------ lib/Response.php | 10 +++++----- lib/Sapi.php | 6 +++--- lib/functions.php | 2 +- 9 files changed, 22 insertions(+), 31 deletions(-) diff --git a/lib/Auth/AWS.php b/lib/Auth/AWS.php index 174b4f1..4b16ec8 100644 --- a/lib/Auth/AWS.php +++ b/lib/Auth/AWS.php @@ -55,7 +55,7 @@ public function init(): bool { $authHeader = $this->request->getHeader('Authorization'); - if ($authHeader === null) { + if (null === $authHeader) { $this->errorCode = self::ERR_NOAWSHEADER; return false; diff --git a/lib/Client.php b/lib/Client.php index cfa63ef..9d487b9 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -85,6 +85,7 @@ public function __construct() * @param \Sabre\HTTP\RequestInterface $request * * @return \Sabre\HTTP\ResponseInterface + * * @throws \Sabre\HTTP\ClientException * @throws \Sabre\HTTP\ClientHttpException */ @@ -109,7 +110,7 @@ public function send(RequestInterface $request): ResponseInterface // open_basedir. // // https://github.com/fruux/sabre-http/issues/12 - if ( $redirects < $this->maxRedirects && \in_array($code, [301, 302, 307, 308])) { + if ($redirects < $this->maxRedirects && \in_array($code, [301, 302, 307, 308])) { $oldLocation = $request->getUrl(); // Creating a new instance of the request object. @@ -206,7 +207,7 @@ public function poll(): bool ); if ($status && CURLMSG_DONE === $status['msg']) { - $resourceId = (int)$status['handle']; + $resourceId = (int) $status['handle']; list( $request, $successCallback, @@ -307,6 +308,7 @@ public function addCurlSetting(int $name, $value) * @param \Sabre\HTTP\RequestInterface $request * * @return \Sabre\HTTP\ResponseInterface + * * @throws \Sabre\HTTP\ClientException */ protected function doRequest(RequestInterface $request): ResponseInterface @@ -517,7 +519,7 @@ protected function sendAsyncInternal(RequestInterface $request, callable $succes $this->createCurlSettingsArray($request) ); curl_multi_add_handle($this->curlMultiHandle, $curl); - $this->curlMultiMap[(int)$curl] = [ + $this->curlMultiMap[(int) $curl] = [ $request, $success, $error, diff --git a/lib/Message.php b/lib/Message.php index 2e5d454..6d52aa6 100644 --- a/lib/Message.php +++ b/lib/Message.php @@ -52,7 +52,7 @@ public function getBodyAsStream() if (\is_callable($this->body)) { $body = $this->getBodyAsString(); } - if (\is_string($body) || $body === null) { + if (\is_string($body) || null === $body) { $stream = fopen('php://temp', 'r+'); fwrite($stream, (string) $body); rewind($stream); @@ -75,7 +75,7 @@ public function getBodyAsString(): string if (\is_string($body)) { return $body; } - if ($body === null) { + if (null === $body) { return ''; } if (\is_callable($body)) { @@ -85,11 +85,11 @@ public function getBodyAsString(): string return ob_get_clean(); } /** - * @var string|int|null $contentLength + * @var string|int|null */ $contentLength = $this->getHeader('Content-Length'); if (\is_int($contentLength) || ctype_digit($contentLength)) { - return stream_get_contents($body, (int)$contentLength); + return stream_get_contents($body, (int) $contentLength); } return stream_get_contents($body); @@ -234,7 +234,7 @@ public function setHeaders(array $headers) * another value. Individual values can be retrieved with * getHeadersAsArray. * - * @param string $name + * @param string $name * @param string|string[] $value */ public function addHeader(string $name, $value) diff --git a/lib/MessageDecoratorTrait.php b/lib/MessageDecoratorTrait.php index 0eb9f57..8aafecb 100644 --- a/lib/MessageDecoratorTrait.php +++ b/lib/MessageDecoratorTrait.php @@ -170,7 +170,7 @@ public function setHeaders(array $headers) * another value. Individual values can be retrieved with * getHeadersAsArray. * - * @param string $name + * @param string $name * @param string|string[] $value */ public function addHeader(string $name, $value) diff --git a/lib/MessageInterface.php b/lib/MessageInterface.php index e2d68fc..f74bfbe 100644 --- a/lib/MessageInterface.php +++ b/lib/MessageInterface.php @@ -108,7 +108,6 @@ public function getHeaderAsArray(string $name): array; * * @param string $name * @param string|string[] $value - * */ public function setHeader(string $name, $value); @@ -121,7 +120,6 @@ public function setHeader(string $name, $value); * Any header that already existed will be overwritten. * * @param array $headers - * */ public function setHeaders(array $headers); @@ -132,9 +130,8 @@ public function setHeaders(array $headers); * another value. Individual values can be retrieved with * getHeadersAsArray. * - * @param string $name + * @param string $name * @param string|string[] $value - * */ public function addHeader(string $name, $value); @@ -144,7 +141,6 @@ public function addHeader(string $name, $value); * Any existing headers will not be overwritten. * * @param array $headers - * */ public function addHeaders(array $headers); @@ -167,7 +163,6 @@ public function removeHeader(string $name): bool; * Should be 1.0, 1.1 or 2.0. * * @param string $version - * */ public function setHttpVersion(string $version); diff --git a/lib/RequestInterface.php b/lib/RequestInterface.php index 90c349b..b46a346 100644 --- a/lib/RequestInterface.php +++ b/lib/RequestInterface.php @@ -22,7 +22,6 @@ public function getMethod(): string; * Sets the HTTP method. * * @param string $method - * */ public function setMethod(string $method); @@ -35,7 +34,6 @@ public function getUrl(): string; * Sets the request url. * * @param string $url - * */ public function setUrl(string $url); @@ -48,7 +46,6 @@ public function getAbsoluteUrl(): string; * Sets the absolute url. * * @param string $url - * */ public function setAbsoluteUrl(string $url); @@ -65,7 +62,6 @@ public function getBaseUrl(): string; * The base url should default to / * * @param string $url - * */ public function setBaseUrl(string $url); @@ -109,7 +105,6 @@ public function getPostData(): array; * php://input, but unfortunately we need to special case it. * * @param array $postData - * */ public function setPostData(array $postData); @@ -128,7 +123,6 @@ public function getRawServerValue(string $valueName); * Sets the _SERVER array. * * @param array $data - * */ public function setRawServerData(array $data); } diff --git a/lib/Response.php b/lib/Response.php index 05f03a0..dec95db 100644 --- a/lib/Response.php +++ b/lib/Response.php @@ -105,13 +105,13 @@ class Response extends Message implements ResponseInterface */ public function __construct($status = 500, array $headers = null, $body = null) { - if ($status !== null) { + if (null !== $status) { $this->setStatus($status); } - if ($headers !== null) { + if (null !== $headers) { $this->setHeaders($headers); } - if ($body !== null) { + if (null !== $body) { $this->setBody($body); } } @@ -150,14 +150,14 @@ public function getStatusText(): string public function setStatus($status) { if (\is_int($status) || ctype_digit($status)) { - $statusCode = (int)$status; + $statusCode = (int) $status; $statusText = self::$statusCodes[$status] ?? 'Unknown'; } else { list( $statusCode, $statusText ) = explode(' ', $status, 2); - $statusCode=(int)$statusCode; + $statusCode = (int) $statusCode; } if ($statusCode < 100 || $statusCode > 999) { throw new \InvalidArgumentException('The HTTP status code must be exactly 3 digits'); diff --git a/lib/Sapi.php b/lib/Sapi.php index 57b6a31..6575338 100644 --- a/lib/Sapi.php +++ b/lib/Sapi.php @@ -77,7 +77,7 @@ public static function sendResponse(ResponseInterface $response) } $body = $response->getBody(); - if ($body === null) { + if (null === $body) { return; } @@ -205,11 +205,11 @@ public static function createFromServerArray(array $serverArray): Request } } - if ($url === null) { + if (null === $url) { throw new InvalidArgumentException('The _SERVER array must have a REQUEST_URI key'); } - if ($method === null) { + if (null === $method) { throw new InvalidArgumentException('The _SERVER array must have a REQUEST_METHOD key'); } $r = new Request($method, $url, $headers); diff --git a/lib/functions.php b/lib/functions.php index 8fc97cc..3cdf4b5 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -138,7 +138,7 @@ function negotiateContentType($acceptHeaderValue, array $availableOptions) foreach ($proposals as $proposal) { // Ignoring broken values. - if ($proposal === null) { + if (null === $proposal) { continue; }