Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Builder/ResponseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
Expand All @@ -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)
);
Expand Down
8 changes: 4 additions & 4 deletions src/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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, '/').'/'));
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 = '/';
}

Expand Down
4 changes: 2 additions & 2 deletions src/Encoding/FilteredStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function read($length)
*/
public function eof()
{
return $this->stream->eof() && $this->buffer === '';
return $this->stream->eof() && '' === $this->buffer;
}

/**
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions src/Formatter/CurlCommandFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down Expand Up @@ -69,6 +69,7 @@ private function getHeadersAsCommandOptions(RequestInterface $request)

if ('user-agent' === strtolower($name)) {
$command .= sprintf(' -A %s', escapeshellarg($values[0]));

continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Formatter/FullHttpMessageFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down