diff -up ./PHPUnit/Extensions/TestDecorator.php.php8 ./PHPUnit/Extensions/TestDecorator.php
--- ./PHPUnit/Extensions/TestDecorator.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./PHPUnit/Extensions/TestDecorator.php	2023-03-31 09:15:03.023678618 +0200
@@ -61,6 +61,7 @@ class PHPUnit_Extensions_TestDecorator e
      *
      * @return int
      */
+    #[\ReturnTypeWillChange]
     public function count()
     {
         return count($this->test);
diff -up ./PHPUnit/Framework/Constraint/IsType.php.php8 ./PHPUnit/Framework/Constraint/IsType.php
--- ./PHPUnit/Framework/Constraint/IsType.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./PHPUnit/Framework/Constraint/IsType.php	2023-03-31 09:15:03.023678618 +0200
@@ -116,7 +116,20 @@ class PHPUnit_Framework_Constraint_IsTyp
                 return is_object($other);
 
             case 'resource':
-                return is_resource($other) || is_string(@get_resource_type($other));
+                if (is_resource($other)) {
+                    return true;
+                }
+
+                try {
+                    $resource = @get_resource_type($other);
+
+                    if (is_string($resource)) {
+                        return true;
+                    }
+                } catch (\TypeError $e) {
+                }
+
+                return false;
 
             case 'scalar':
                 return is_scalar($other);
diff -up ./PHPUnit/Framework/Constraint.php.php8 ./PHPUnit/Framework/Constraint.php
--- ./PHPUnit/Framework/Constraint.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./PHPUnit/Framework/Constraint.php	2023-03-31 09:15:03.023678618 +0200
@@ -77,6 +77,7 @@ abstract class PHPUnit_Framework_Constra
      *
      * @return int
      */
+    #[\ReturnTypeWillChange]
     public function count()
     {
         return 1;
diff -up ./PHPUnit/Framework/TestCase.php.php8 ./PHPUnit/Framework/TestCase.php
--- ./PHPUnit/Framework/TestCase.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./PHPUnit/Framework/TestCase.php	2023-03-31 09:15:03.023678618 +0200
@@ -324,6 +324,7 @@ abstract class PHPUnit_Framework_TestCas
      *
      * @return int
      */
+    #[\ReturnTypeWillChange]
     public function count()
     {
         return 1;
@@ -1059,7 +1060,7 @@ abstract class PHPUnit_Framework_TestCas
         $this->registerMockObjectsFromTestArguments($testArguments);
 
         try {
-            $testResult = $method->invokeArgs($this, $testArguments);
+            $testResult = $method->invokeArgs($this, array_values($testArguments));
         } catch (Throwable $_e) {
             $e = $_e;
         } catch (Exception $_e) {
diff -up ./PHPUnit/Framework/TestResult.php.php8 ./PHPUnit/Framework/TestResult.php
--- ./PHPUnit/Framework/TestResult.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./PHPUnit/Framework/TestResult.php	2023-03-31 09:15:03.024678616 +0200
@@ -894,6 +894,7 @@ class PHPUnit_Framework_TestResult imple
      *
      * @return int
      */
+    #[\ReturnTypeWillChange]
     public function count()
     {
         return $this->runTests;
diff -up ./PHPUnit/Framework/TestSuite.php.php8 ./PHPUnit/Framework/TestSuite.php
--- ./PHPUnit/Framework/TestSuite.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./PHPUnit/Framework/TestSuite.php	2023-03-31 09:15:03.024678616 +0200
@@ -401,6 +401,7 @@ class PHPUnit_Framework_TestSuite implem
      *
      * @return int
      */
+    #[\ReturnTypeWillChange]
     public function count($preferCache = false)
     {
         if ($preferCache && $this->cachedNumTests !== null) {
@@ -961,6 +962,7 @@ class PHPUnit_Framework_TestSuite implem
      *
      * @return RecursiveIteratorIterator
      */
+    #[\ReturnTypeWillChange]
     public function getIterator()
     {
         $iterator = new PHPUnit_Util_TestSuiteIterator($this);
diff -up ./PHPUnit/Util/Configuration.php.php8 ./PHPUnit/Util/Configuration.php
--- ./PHPUnit/Util/Configuration.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./PHPUnit/Util/Configuration.php	2023-03-31 09:15:03.024678616 +0200
@@ -159,7 +159,7 @@ class PHPUnit_Util_Configuration
         $this->xpath    = new DOMXPath($this->document);
     }
 
-    final private function __clone()
+    private function __clone()
     {
     }
 
@@ -501,21 +501,23 @@ class PHPUnit_Util_Configuration
             // See https://github.com/sebastianbergmann/phpunit/issues/277
             switch ($array) {
                 case 'var':
-                    $target = &$GLOBALS;
+                    foreach ($configuration[$array] as $name => $value) {
+                        $GLOBALS[$name] = $value;
+                    }
                     break;
 
                 case 'server':
-                    $target = &$_SERVER;
+                    foreach ($configuration[$array] as $name => $value) {
+                        $_SERVER[$name] = $value;
+                    }
                     break;
 
                 default:
-                    $target = &$GLOBALS['_' . strtoupper($array)];
+                    foreach ($configuration[$array] as $name => $value) {
+                        $GLOBALS['_' . strtoupper($array)][$name] = $value;
+                    }
                     break;
             }
-
-            foreach ($configuration[$array] as $name => $value) {
-                $target[$name] = $value;
-            }
         }
 
         foreach ($configuration['env'] as $name => $value) {
diff -up ./PHPUnit/Util/PHP/Template/TestCaseMethod.tpl.dist.php8 ./PHPUnit/Util/PHP/Template/TestCaseMethod.tpl.dist
--- ./PHPUnit/Util/PHP/Template/TestCaseMethod.tpl.dist.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./PHPUnit/Util/PHP/Template/TestCaseMethod.tpl.dist	2023-03-31 09:15:03.024678616 +0200
@@ -81,7 +81,7 @@ if ('' !== $configurationFilePath) {
     unset($configuration);
 }
 
-function __phpunit_error_handler($errno, $errstr, $errfile, $errline, $errcontext)
+function __phpunit_error_handler($errno, $errstr, $errfile, $errline, $errcontext=null)
 {
    return true;
 }
diff -up ./PHPUnit/Util/TestSuiteIterator.php.php8 ./PHPUnit/Util/TestSuiteIterator.php
--- ./PHPUnit/Util/TestSuiteIterator.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./PHPUnit/Util/TestSuiteIterator.php	2023-03-31 09:15:03.024678616 +0200
@@ -34,6 +34,7 @@ class PHPUnit_Util_TestSuiteIterator imp
     /**
      * Rewinds the Iterator to the first element.
      */
+    #[\ReturnTypeWillChange]
     public function rewind()
     {
         $this->position = 0;
@@ -44,6 +45,7 @@ class PHPUnit_Util_TestSuiteIterator imp
      *
      * @return bool
      */
+    #[\ReturnTypeWillChange]
     public function valid()
     {
         return $this->position < count($this->tests);
@@ -54,6 +56,7 @@ class PHPUnit_Util_TestSuiteIterator imp
      *
      * @return int
      */
+    #[\ReturnTypeWillChange]
     public function key()
     {
         return $this->position;
@@ -64,6 +67,7 @@ class PHPUnit_Util_TestSuiteIterator imp
      *
      * @return PHPUnit_Framework_Test
      */
+    #[\ReturnTypeWillChange]
     public function current()
     {
         return $this->valid() ? $this->tests[$this->position] : null;
@@ -72,6 +76,7 @@ class PHPUnit_Util_TestSuiteIterator imp
     /**
      * Moves forward to next element.
      */
+    #[\ReturnTypeWillChange]
     public function next()
     {
         $this->position++;
@@ -82,6 +87,7 @@ class PHPUnit_Util_TestSuiteIterator imp
      *
      * @return PHPUnit_Util_TestSuiteIterator
      */
+    #[\ReturnTypeWillChange]
     public function getChildren()
     {
         return new self(
@@ -94,6 +100,7 @@ class PHPUnit_Util_TestSuiteIterator imp
      *
      * @return bool
      */
+    #[\ReturnTypeWillChange]
     public function hasChildren()
     {
         return $this->tests[$this->position] instanceof PHPUnit_Framework_TestSuite;
diff -up ./tests/_files/DoubleTestCase.php.php8 ./tests/_files/DoubleTestCase.php
--- ./tests/_files/DoubleTestCase.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./tests/_files/DoubleTestCase.php	2023-03-31 09:15:03.024678616 +0200
@@ -8,6 +8,7 @@ class DoubleTestCase implements PHPUnit_
         $this->testCase = $testCase;
     }
 
+    #[\ReturnTypeWillChange]
     public function count()
     {
         return 2;
diff -up ./tests/_files/SampleArrayAccess.php.php8 ./tests/_files/SampleArrayAccess.php
--- ./tests/_files/SampleArrayAccess.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./tests/_files/SampleArrayAccess.php	2023-03-31 09:15:03.024678616 +0200
@@ -13,6 +13,7 @@ class SampleArrayAccess implements Array
     {
         $this->container = [];
     }
+    #[\ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
         if (is_null($offset)) {
@@ -21,14 +22,17 @@ class SampleArrayAccess implements Array
             $this->container[$offset] = $value;
         }
     }
+    #[\ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         return isset($this->container[$offset]);
     }
+    #[\ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
         unset($this->container[$offset]);
     }
+    #[\ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         return isset($this->container[$offset]) ? $this->container[$offset] : null;
diff -up ./tests/_files/Singleton.php.php8 ./tests/_files/Singleton.php
--- ./tests/_files/Singleton.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./tests/_files/Singleton.php	2023-03-31 09:15:03.024678616 +0200
@@ -7,7 +7,7 @@ class Singleton
     {
     }
 
-    final private function __clone()
+    private function __clone()
     {
     }
 
diff -up ./tests/_files/TestIterator2.php.php8 ./tests/_files/TestIterator2.php
--- ./tests/_files/TestIterator2.php.php8	2023-03-31 09:15:29.899608396 +0200
+++ ./tests/_files/TestIterator2.php	2023-03-31 09:15:40.714579720 +0200
@@ -8,26 +8,31 @@ class TestIterator2 implements Iterator
         $this->data = $array;
     }
 
+    #[\ReturnTypeWillChange]
     public function current()
     {
         return current($this->data);
     }
 
+    #[\ReturnTypeWillChange]
     public function next()
     {
         next($this->data);
     }
 
+    #[\ReturnTypeWillChange]
     public function key()
     {
         return key($this->data);
     }
 
+    #[\ReturnTypeWillChange]
     public function valid()
     {
         return key($this->data) !== null;
     }
 
+    #[\ReturnTypeWillChange]
     public function rewind()
     {
         reset($this->data);
diff -up ./tests/_files/TestIterator.php.php8 ./tests/_files/TestIterator.php
--- ./tests/_files/TestIterator.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./tests/_files/TestIterator.php	2023-03-31 09:15:03.024678616 +0200
@@ -9,26 +9,31 @@ class TestIterator implements Iterator
         $this->array = $array;
     }
 
+    #[\ReturnTypeWillChange]
     public function rewind()
     {
         $this->position = 0;
     }
 
+    #[\ReturnTypeWillChange]
     public function valid()
     {
         return $this->position < count($this->array);
     }
 
+    #[\ReturnTypeWillChange]
     public function key()
     {
         return $this->position;
     }
 
+    #[\ReturnTypeWillChange]
     public function current()
     {
         return $this->array[$this->position];
     }
 
+    #[\ReturnTypeWillChange]
     public function next()
     {
         $this->position++;
diff -up ./tests/Framework/Constraint/JsonMatches/ErrorMessageProviderTest.php.php8 ./tests/Framework/Constraint/JsonMatches/ErrorMessageProviderTest.php
--- ./tests/Framework/Constraint/JsonMatches/ErrorMessageProviderTest.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./tests/Framework/Constraint/JsonMatches/ErrorMessageProviderTest.php	2023-03-31 09:15:03.024678616 +0200
@@ -39,7 +39,7 @@ class Framework_Constraint_JsonMatches_E
     {
         return [
             'JSON_ERROR_NONE'  => [
-                null, 'json_error_none', ''
+                null, JSON_ERROR_NONE, ''
             ],
             'JSON_ERROR_DEPTH' => [
                 'Maximum stack depth exceeded', JSON_ERROR_DEPTH, ''
diff -up ./tests/Framework/ConstraintTest.php.php8 ./tests/Framework/ConstraintTest.php
--- ./tests/Framework/ConstraintTest.php.php8	2018-02-01 06:50:59.000000000 +0100
+++ ./tests/Framework/ConstraintTest.php	2023-03-31 09:15:03.025678613 +0200
@@ -1233,7 +1233,7 @@ EOF
 
         $this->assertTrue($constraint->evaluate($resource, '', true));
 
-        @fclose($resource);
+        if (is_resource($resource)) @fclose($resource);
     }
 
     public function testConstraintIsNotType()
@@ -2547,7 +2547,6 @@ EOF
         // Default case.
         $constraint = new PHPUnit_Framework_Constraint_TraversableContains('foo');
 
-        $this->assertTrue($constraint->evaluate([0], '', true));
         $this->assertTrue($constraint->evaluate([true], '', true));
     }