Skip to content

Commit

Permalink
Merge pull request #2800 from RyanNerd/null-comparison-improvement
Browse files Browse the repository at this point in the history
Make null comparisons more clear in ErrorHandler
  • Loading branch information
l0gicgate committed Aug 13, 2019
2 parents fabf552 + 7062a5f commit ed5ecf2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Slim/Handlers/ErrorHandler.php
Expand Up @@ -138,7 +138,7 @@ public function __invoke(
$this->exception = $exception;
$this->method = $request->getMethod();
$this->statusCode = $this->determineStatusCode();
if (is_null($this->contentType)) {
if ($this->contentType === null) {
$this->contentType = $this->determineContentType($request);
}

Expand Down Expand Up @@ -227,7 +227,7 @@ protected function determineContentType(ServerRequestInterface $request): ?strin
*/
protected function determineRenderer(): callable
{
if (!is_null($this->contentType) && array_key_exists($this->contentType, $this->errorRenderers)) {
if ($this->contentType !== null && array_key_exists($this->contentType, $this->errorRenderers)) {
$renderer = $this->errorRenderers[$this->contentType];
} else {
$renderer = $this->defaultErrorRenderer;
Expand Down Expand Up @@ -289,7 +289,7 @@ protected function logError(string $error): void
protected function respond(): ResponseInterface
{
$response = $this->responseFactory->createResponse($this->statusCode);
if (!is_null($this->contentType) && array_key_exists($this->contentType, $this->errorRenderers)) {
if ($this->contentType !== null && array_key_exists($this->contentType, $this->errorRenderers)) {
$response = $response->withHeader('Content-type', $this->contentType);
} else {
$response = $response->withHeader('Content-type', $this->defaultErrorRendererContentType);
Expand Down

0 comments on commit ed5ecf2

Please sign in to comment.