From b769763a8a1ca9b0b3a639b11defbf4d456db105 Mon Sep 17 00:00:00 2001 From: Natan Felles Date: Wed, 27 Sep 2023 17:31:27 -0300 Subject: [PATCH] Upgrade Coding Standard --- composer.json | 2 +- src/Client.php | 4 ++-- src/Request.php | 15 ++++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 3b595ec..d034813 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ }, "require-dev": { "ext-xdebug": "*", - "aplus/coding-standard": "^1.14", + "aplus/coding-standard": "^2.0", "ergebnis/composer-normalize": "^2.25", "jetbrains/phpstorm-attributes": "^1.0", "phpmd/phpmd": "^2.13", diff --git a/src/Client.php b/src/Client.php index afef8d6..d83c75d 100644 --- a/src/Client.php +++ b/src/Client.php @@ -105,7 +105,7 @@ public function runMulti(array $requests) : Generator $info = (array) \curl_getinfo($handle); } $objectId = \spl_object_id($handle); - if ( ! isset($this->parsed[$objectId])) { + if (!isset($this->parsed[$objectId])) { unset($handles[$id]); break; } @@ -144,7 +144,7 @@ protected function parseHeaderLine(CurlHandle $curlHandle, string $line) : int return $lineLength; } $id = \spl_object_id($curlHandle); - if ( ! \str_contains($trimmedLine, ':')) { + if (!\str_contains($trimmedLine, ':')) { if (\str_starts_with($trimmedLine, 'HTTP/')) { $parts = \explode(' ', $trimmedLine, 3); $this->parsed[$id]['protocol'] = $parts[0]; diff --git a/src/Request.php b/src/Request.php index a247928..eb6b23f 100644 --- a/src/Request.php +++ b/src/Request.php @@ -86,13 +86,13 @@ public function __toString() : string if ($this->parseContentType() === 'multipart/form-data') { $this->setBody($this->getMultipartBody()); } - if ( ! $this->hasHeader(RequestHeader::ACCEPT)) { + if (!$this->hasHeader(RequestHeader::ACCEPT)) { $accept = '*/*'; $this->setHeader(RequestHeader::ACCEPT, $accept); } $options = $this->getOptions(); if (isset($options[\CURLOPT_ENCODING]) - && ! $this->hasHeader(RequestHeader::ACCEPT_ENCODING) + && !$this->hasHeader(RequestHeader::ACCEPT_ENCODING) ) { $encoding = $options[\CURLOPT_ENCODING] === '' ? 'deflate, gzip, br, zstd' @@ -198,7 +198,7 @@ protected function getFileInfo(CURLFile | CURLStringFile | string $file) : array */ public function setUrl(string | URL $url) : static { - if ( ! $url instanceof URL) { + if (!$url instanceof URL) { $url = new URL($url); } $this->setHeader(RequestHeader::HOST, $url->getHost()); @@ -316,7 +316,7 @@ public function setPost(array $data) : static #[Pure] public function hasFiles() : bool { - return ! empty($this->files); + return !empty($this->files); } /** @@ -479,7 +479,8 @@ public function removeHeaders() : static */ public function setBasicAuth( string $username, - #[SensitiveParameter] string $password + #[SensitiveParameter] + string $password ) : static { return $this->setHeader( RequestHeader::AUTHORIZATION, @@ -633,7 +634,7 @@ public function getOption(int $option) : mixed */ public function getPostAndFiles() : array | string { - if ( ! $this->hasFiles()) { + if (!$this->hasFiles()) { return $this->getBody(); } \parse_str($this->getBody(), $post); @@ -648,7 +649,7 @@ public function getPostAndFiles() : array | string if ($file instanceof CURLFile || $file instanceof CURLStringFile) { continue; } - if ( ! \is_file($file)) { + if (!\is_file($file)) { throw new InvalidArgumentException( "Field '{$field}' does not match a file: {$file}" );