Browse Source

Remove PHP version checks no longer needed.

ADmad 4 years ago
parent
commit
664463dfee

+ 1 - 1
src/Error/Middleware/ErrorHandlerMiddleware.php

@@ -93,7 +93,7 @@ class ErrorHandlerMiddleware implements MiddlewareInterface
             $errorHandler = func_get_arg(1);
         }
 
-        if (PHP_VERSION_ID >= 70400 && Configure::read('debug')) {
+        if (Configure::read('debug')) {
             ini_set('zend.exception_ignore_args', '0');
         }
 

+ 1 - 21
src/Http/ResponseEmitter.php

@@ -231,27 +231,7 @@ class ResponseEmitter implements EmitterInterface
             $cookie = Cookie::createFromHeaderString($cookie, ['path' => '']);
         }
 
-        if (PHP_VERSION_ID >= 70300) {
-            return setcookie($cookie->getName(), $cookie->getScalarValue(), $cookie->getOptions());
-        }
-
-        $path = $cookie->getPath();
-        $sameSite = $cookie->getSameSite();
-        if ($sameSite !== null) {
-            // Temporary hack for PHP 7.2 to set "SameSite" attribute
-            // https://stackoverflow.com/questions/39750906/php-setcookie-samesite-strict
-            $path .= '; samesite=' . $sameSite;
-        }
-
-        return setcookie(
-            $cookie->getName(),
-            $cookie->getScalarValue(),
-            $cookie->getExpiresTimestamp() ?: 0,
-            $path,
-            $cookie->getDomain(),
-            $cookie->isSecure(),
-            $cookie->isHttpOnly()
-        );
+        return setcookie($cookie->getName(), $cookie->getScalarValue(), $cookie->getOptions());
     }
 
     /**

+ 1 - 4
src/Http/Session.php

@@ -174,10 +174,7 @@ class Session
         ];
 
         if (isset($defaults[$name])) {
-            if (
-                PHP_VERSION_ID >= 70300
-                && ($name !== 'php' || empty(ini_get('session.cookie_samesite')))
-            ) {
+            if ($name !== 'php' || empty(ini_get('session.cookie_samesite'))) {
                 $defaults['php']['ini']['session.cookie_samesite'] = 'Lax';
             }
 

+ 0 - 1
tests/TestCase/Error/DebuggerTest.php

@@ -395,7 +395,6 @@ TEXT;
 
     public function testExportVarTypedProperty(): void
     {
-        $this->skipIf(version_compare(PHP_VERSION, '7.4.0', '<'), 'typed properties require PHP7.4');
         // This is gross but was simpler than adding a fixture file.
         // phpcs:ignore
         eval('class MyClass { private string $field; }');

+ 11 - 49
tests/TestCase/Error/ErrorHandlerTest.php

@@ -120,15 +120,10 @@ class ErrorHandlerTest extends TestCase
         $result = ob_get_clean();
 
         $this->assertMatchesRegularExpression('/<pre class="cake-error">/', $result);
-        if (version_compare(PHP_VERSION, '8.0.0-dev', '<')) {
-            $this->assertMatchesRegularExpression('/<b>Notice<\/b>/', $result);
-            $this->assertMatchesRegularExpression('/variable:\s+wrong/', $result);
-        } else {
-            $this->assertMatchesRegularExpression('/<b>Warning<\/b>/', $result);
-            $this->assertMatchesRegularExpression('/variable \$wrong/', $result);
-        }
+        $this->assertMatchesRegularExpression('/<b>Warning<\/b>/', $result);
+        $this->assertMatchesRegularExpression('/variable \$wrong/', $result);
         $this->assertStringContainsString(
-            'ErrorHandlerTest.php, line ' . (__LINE__ - 12),
+            'ErrorHandlerTest.php, line ' . (__LINE__ - 7),
             $result,
             'Should contain file and line reference'
         );
@@ -191,25 +186,6 @@ class ErrorHandlerTest extends TestCase
     }
 
     /**
-     * test error prepended by @
-     */
-    public function testErrorSuppressed(): void
-    {
-        $this->skipIf(version_compare(PHP_VERSION, '8.0.0-dev', '>='));
-
-        $errorHandler = new ErrorHandler();
-        $errorHandler->register();
-        $this->_restoreError = true;
-
-        ob_start();
-        // phpcs:disable
-        @include 'invalid.file';
-        // phpcs:enable
-        $result = ob_get_clean();
-        $this->assertEmpty($result);
-    }
-
-    /**
      * Test that errors go into Cake Log when debug = 0.
      */
     public function testHandleErrorDebugOff(): void
@@ -224,17 +200,10 @@ class ErrorHandlerTest extends TestCase
         $messages = $this->logger->read();
         $this->assertMatchesRegularExpression('/^(notice|debug|warning)/', $messages[0]);
 
-        if (version_compare(PHP_VERSION, '8.0.0-dev', '<')) {
-            $this->assertStringContainsString(
-                'Notice (8): Undefined variable: out in [' . __FILE__ . ', line ' . (__LINE__ - 7) . ']',
-                $messages[0]
-            );
-        } else {
-            $this->assertStringContainsString(
-                'Warning (2): Undefined variable $out in [' . __FILE__ . ', line ' . (__LINE__ - 12) . ']',
-                $messages[0]
-            );
-        }
+        $this->assertStringContainsString(
+            'Warning (2): Undefined variable $out in [' . __FILE__ . ', line ' . (__LINE__ - 6) . ']',
+            $messages[0]
+        );
     }
 
     /**
@@ -251,17 +220,10 @@ class ErrorHandlerTest extends TestCase
 
         $messages = $this->logger->read();
         $this->assertMatchesRegularExpression('/^(notice|debug|warning)/', $messages[0]);
-        if (version_compare(PHP_VERSION, '8.0.0-dev', '<')) {
-            $this->assertStringContainsString(
-                'Notice (8): Undefined variable: out in [' . __FILE__ . ', line ' . (__LINE__ - 6) . ']',
-                $messages[0]
-            );
-        } else {
-            $this->assertStringContainsString(
-                'Warning (2): Undefined variable $out in [' . __FILE__ . ', line ' . (__LINE__ - 11) . ']',
-                $messages[0]
-            );
-        }
+        $this->assertStringContainsString(
+            'Warning (2): Undefined variable $out in [' . __FILE__ . ', line ' . (__LINE__ - 5) . ']',
+            $messages[0]
+        );
         $this->assertStringContainsString('Trace:', $messages[0]);
         $this->assertStringContainsString(__NAMESPACE__ . '\ErrorHandlerTest::testHandleErrorLoggingTrace()', $messages[0]);
         $this->assertStringContainsString('Request URL:', $messages[0]);

+ 0 - 2
tests/TestCase/Error/Middleware/ErrorHandlerMiddlewareTest.php

@@ -350,8 +350,6 @@ class ErrorHandlerMiddlewareTest extends TestCase
      */
     public function testExceptionArgs(): void
     {
-        $this->skipIf(PHP_VERSION_ID < 70400);
-
         // Force exception_ignore_args to true for test
         ini_set('zend.exception_ignore_args', '1');
 

+ 1 - 5
tests/TestCase/View/ViewTest.php

@@ -1807,11 +1807,7 @@ TEXT;
 
     protected function checkException(string $message): void
     {
-        if (version_compare(PHP_VERSION, '7.4', '>=')) {
-            $this->expectException(\Error::class);
-        } else {
-            $this->expectException(\PHPUnit\Framework\Error\Error::class);
-        }
+        $this->expectException(\Error::class);
         $this->expectExceptionMessage($message);
     }
 }