Pārlūkot izejas kodu

test: fix PHP 8.5 deprecations in tests

- ArrayIterator must not take an object as backing array; materialize
  the ZipFile iterator first.
- declare the $context property on the DummyFileSystemStream wrapper:
  PHP assigns it on registration and a missing property now triggers a
  dynamic property deprecation.
Ne-Lexa 3 nedēļas atpakaļ
vecāks
revīzija
7af9d2c9ab
2 mainītis faili ar 9 papildinājumiem un 1 dzēšanām
  1. 8 0
      tests/Internal/DummyFileSystemStream.php
  2. 1 1
      tests/ZipFileTest.php

+ 8 - 0
tests/Internal/DummyFileSystemStream.php

@@ -18,6 +18,14 @@ namespace PhpZip\Tests\Internal;
  */
 class DummyFileSystemStream
 {
+    /**
+     * Stream context, assigned by PHP when the wrapper is registered.
+     * Declaring it prevents a dynamic property deprecation on PHP 8.2+.
+     *
+     * @var resource|null
+     */
+    public $context = null;
+
     /** @var resource */
     private $fp;
 

+ 1 - 1
tests/ZipFileTest.php

@@ -1583,7 +1583,7 @@ class ZipFileTest extends ZipTestCase
 
         // Test \Iterator
         reset($files);
-        $iterator = new \ArrayIterator($zipFile);
+        $iterator = new \ArrayIterator(iterator_to_array($zipFile));
         $iterator->rewind();
 
         while ($iterator->valid()) {