Skip to content

Commit

Permalink
[HttpFoundation] Resolve some Psalm issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Appriou committed Feb 3, 2023
1 parent 36cc5d9 commit 54c1bbb
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 23 deletions.
Expand Up @@ -17,7 +17,7 @@
final class ResponseIsRedirected extends Constraint
{
/**
* @param booll $verbose If true, the entire response is printed on failure. If false, the response body is omitted.
* @param bool $verbose If true, the entire response is printed on failure. If false, the response body is omitted.
*/
public function __construct(private readonly bool $verbose = true)
{
Expand All @@ -44,11 +44,12 @@ protected function failureDescription($response): string
return 'the Response '.$this->toString();
}

/**
* @param Response $response
*/
protected function additionalFailureDescription($response): string
protected function additionalFailureDescription($other): string
{
return $this->verbose ? (string) $response : $response->getCommandString()."\r\n".$response->headers;
if ($this->verbose || !($other instanceof Response)) {
return (string) $other;
} else {
return $other->getCommandString()."\r\n".$other->headers;
}
}
}
Expand Up @@ -17,7 +17,7 @@
final class ResponseIsSuccessful extends Constraint
{
/**
* @param booll $verbose If true, the entire response is printed on failure. If false, the response body is omitted.
* @param bool $verbose If true, the entire response is printed on failure. If false, the response body is omitted.
*/
public function __construct(private readonly bool $verbose = true)
{
Expand All @@ -44,11 +44,12 @@ protected function failureDescription($response): string
return 'the Response '.$this->toString();
}

/**
* @param Response $response
*/
protected function additionalFailureDescription($response): string
protected function additionalFailureDescription($other): string
{
return $this->verbose ? (string) $response : $response->getCommandString()."\r\n".$response->headers;
if ($this->verbose || !($other instanceof Response)) {
return (string) $other;
} else {
return $other->getCommandString()."\r\n".$other->headers;
}
}
}
Expand Up @@ -16,6 +16,9 @@

final class ResponseIsUnprocessable extends Constraint
{
/**
* @param bool $verbose If true, the entire response is printed on failure. If false, the response body is omitted.
*/
public function __construct(private readonly bool $verbose = true)
{
}
Expand All @@ -26,26 +29,30 @@ public function toString(): string
}

/**
* @param Response $response
* @param Response $other
*/
protected function matches($response): bool
protected function matches($other): bool
{
return Response::HTTP_UNPROCESSABLE_ENTITY === $response->getStatusCode();
return Response::HTTP_UNPROCESSABLE_ENTITY === $other->getStatusCode();
}

/**
* @param Response $response
* @param Response $other
*/
protected function failureDescription($response): string
protected function failureDescription($other): string
{
return 'the Response '.$this->toString();
}

/**
* @param Response $response
* @param mixed $other
*/
protected function additionalFailureDescription($response): string
protected function additionalFailureDescription($other): string
{
return $this->verbose ? (string) $response : $response->getCommandString()."\r\n".$response->headers;
if ($this->verbose || !($other instanceof Response)) {
return (string) $other;
} else {
return $other->getCommandString()."\r\n".$other->headers;
}
}
}
Expand Up @@ -45,10 +45,14 @@ protected function failureDescription($response): string
}

/**
* @param Response $response
* @param mixed $other
*/
protected function additionalFailureDescription($response): string
protected function additionalFailureDescription($other): string
{
return $this->verbose ? (string) $response : $response->getCommandString()."\r\n".$response->headers;
if ($this->verbose || !($other instanceof Response)) {
return (string) $other;
} else {
return $other->getCommandString()."\r\n".$other->headers;
}
}
}

0 comments on commit 54c1bbb

Please sign in to comment.