Skip to content

Commit

Permalink
pretty fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnpdlk committed Nov 28, 2018
1 parent d0166ec commit 8ee278e
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 31 deletions.
2 changes: 1 addition & 1 deletion lib/Auth/AWS.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions lib/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public function __construct()
* @param \Sabre\HTTP\RequestInterface $request
*
* @return \Sabre\HTTP\ResponseInterface
*
* @throws \Sabre\HTTP\ClientException
* @throws \Sabre\HTTP\ClientHttpException
*/
Expand All @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions lib/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)) {
Expand All @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/MessageDecoratorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 1 addition & 6 deletions lib/MessageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public function getHeaderAsArray(string $name): array;
*
* @param string $name
* @param string|string[] $value
*
*/
public function setHeader(string $name, $value);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down
6 changes: 0 additions & 6 deletions lib/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public function getMethod(): string;
* Sets the HTTP method.
*
* @param string $method
*
*/
public function setMethod(string $method);

Expand All @@ -35,7 +34,6 @@ public function getUrl(): string;
* Sets the request url.
*
* @param string $url
*
*/
public function setUrl(string $url);

Expand All @@ -48,7 +46,6 @@ public function getAbsoluteUrl(): string;
* Sets the absolute url.
*
* @param string $url
*
*/
public function setAbsoluteUrl(string $url);

Expand All @@ -65,7 +62,6 @@ public function getBaseUrl(): string;
* The base url should default to /
*
* @param string $url
*
*/
public function setBaseUrl(string $url);

Expand Down Expand Up @@ -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);

Expand All @@ -128,7 +123,6 @@ public function getRawServerValue(string $valueName);
* Sets the _SERVER array.
*
* @param array $data
*
*/
public function setRawServerData(array $data);
}
10 changes: 5 additions & 5 deletions lib/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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');
Expand Down
6 changes: 3 additions & 3 deletions lib/Sapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static function sendResponse(ResponseInterface $response)
}

$body = $response->getBody();
if ($body === null) {
if (null === $body) {
return;
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function negotiateContentType($acceptHeaderValue, array $availableOptions)

foreach ($proposals as $proposal) {
// Ignoring broken values.
if ($proposal === null) {
if (null === $proposal) {
continue;
}

Expand Down

0 comments on commit 8ee278e

Please sign in to comment.