Browse Source

PHP 7.3 throws errors when trying to compact undefined vars.

ADmad 7 years ago
parent
commit
249cbc3d3a
1 changed files with 4 additions and 3 deletions
  1. 4 3
      src/Http/Response.php

+ 4 - 3
src/Http/Response.php

@@ -2055,19 +2055,20 @@ class Response implements ResponseInterface
     {
         $etags = preg_split('/\s*,\s*/', (string)$request->getHeaderLine('If-None-Match'), 0, PREG_SPLIT_NO_EMPTY);
         $responseTag = $this->getHeaderLine('Etag');
+        $etagMatches = null;
         if ($responseTag) {
             $etagMatches = in_array('*', $etags) || in_array($responseTag, $etags);
         }
 
         $modifiedSince = $request->getHeaderLine('If-Modified-Since');
+        $timeMatches = null;
         if ($modifiedSince && $this->hasHeader('Last-Modified')) {
             $timeMatches = strtotime($this->getHeaderLine('Last-Modified')) === strtotime($modifiedSince);
         }
-        $checks = compact('etagMatches', 'timeMatches');
-        if (empty($checks)) {
+        if ($etagMatches === null && $timeMatches === null) {
             return false;
         }
-        $notModified = !in_array(false, $checks, true);
+        $notModified = $etagMatches !== false && $timeMatches !== false;
         if ($notModified) {
             $this->notModified();
         }