diff --git a/src/Builder/ResponseBuilder.php b/src/Builder/ResponseBuilder.php index e6933a0..de2e882 100644 --- a/src/Builder/ResponseBuilder.php +++ b/src/Builder/ResponseBuilder.php @@ -104,7 +104,7 @@ public function setHeadersFromString($headers) public function setStatus($statusLine) { $parts = explode(' ', $statusLine, 3); - if (count($parts) < 2 || strpos(strtolower($parts[0]), 'http/') !== 0) { + if (count($parts) < 2 || 0 !== strpos(strtolower($parts[0]), 'http/')) { throw new \InvalidArgumentException( sprintf('"%s" is not a valid HTTP status line', $statusLine) ); @@ -130,7 +130,7 @@ public function setStatus($statusLine) public function addHeader($headerLine) { $parts = explode(':', $headerLine, 2); - if (count($parts) !== 2) { + if (2 !== count($parts)) { throw new \InvalidArgumentException( sprintf('"%s" is not a valid HTTP header line', $headerLine) ); diff --git a/src/Cookie.php b/src/Cookie.php index 5f61b90..962ac72 100644 --- a/src/Cookie.php +++ b/src/Cookie.php @@ -295,7 +295,7 @@ public function withDomain($domain) public function matchDomain($domain) { // Domain is not set or exact match - if (!$this->hasDomain() || strcasecmp($domain, $this->domain) === 0) { + if (!$this->hasDomain() || 0 === strcasecmp($domain, $this->domain)) { return true; } @@ -343,7 +343,7 @@ public function withPath($path) */ public function matchPath($path) { - return $this->path === $path || (strpos($path, rtrim($this->path, '/').'/') === 0); + return $this->path === $path || (0 === strpos($path, rtrim($this->path, '/').'/')); } /** @@ -405,7 +405,7 @@ public function withHttpOnly($httpOnly) * * @return bool */ - public function match(Cookie $cookie) + public function match(self $cookie) { return $this->name === $cookie->name && $this->domain === $cookie->domain and $this->path === $cookie->path; } @@ -517,7 +517,7 @@ private function normalizePath($path) { $path = rtrim($path, '/'); - if (empty($path) or substr($path, 0, 1) !== '/') { + if (empty($path) or '/' !== substr($path, 0, 1)) { $path = '/'; } diff --git a/src/Encoding/FilteredStream.php b/src/Encoding/FilteredStream.php index a32554b..4b296ed 100644 --- a/src/Encoding/FilteredStream.php +++ b/src/Encoding/FilteredStream.php @@ -98,7 +98,7 @@ public function read($length) */ public function eof() { - return $this->stream->eof() && $this->buffer === ''; + return $this->stream->eof() && '' === $this->buffer; } /** @@ -128,7 +128,7 @@ public function getContents() while (!$this->eof()) { $buf = $this->read(self::BUFFER_SIZE); // Using a loose equality here to match on '' and false. - if ($buf == null) { + if (null == $buf) { break; } diff --git a/src/Formatter/CurlCommandFormatter.php b/src/Formatter/CurlCommandFormatter.php index a0fe7e5..f0375fd 100644 --- a/src/Formatter/CurlCommandFormatter.php +++ b/src/Formatter/CurlCommandFormatter.php @@ -19,9 +19,9 @@ class CurlCommandFormatter implements Formatter public function formatRequest(RequestInterface $request) { $command = sprintf('curl %s', escapeshellarg((string) $request->getUri()->withFragment(''))); - if ($request->getProtocolVersion() === '1.0') { + if ('1.0' === $request->getProtocolVersion()) { $command .= ' --http1.0'; - } elseif ($request->getProtocolVersion() === '2.0') { + } elseif ('2.0' === $request->getProtocolVersion()) { $command .= ' --http2'; } @@ -69,6 +69,7 @@ private function getHeadersAsCommandOptions(RequestInterface $request) if ('user-agent' === strtolower($name)) { $command .= sprintf(' -A %s', escapeshellarg($values[0])); + continue; } diff --git a/src/Formatter/FullHttpMessageFormatter.php b/src/Formatter/FullHttpMessageFormatter.php index 3fa1029..1918c59 100644 --- a/src/Formatter/FullHttpMessageFormatter.php +++ b/src/Formatter/FullHttpMessageFormatter.php @@ -78,7 +78,7 @@ public function formatResponse(ResponseInterface $response) private function addBody(MessageInterface $request, $message) { $stream = $request->getBody(); - if (!$stream->isSeekable() || $this->maxBodyLength === 0) { + if (!$stream->isSeekable() || 0 === $this->maxBodyLength) { // Do not read the stream $message .= "\n"; } else {