]> git.street.me.uk Git - andy/gpx.git/commitdiff
Fix: PeakStream fails to function correctly after the first file
authorAndy Street <andy@street.me.uk>
Wed, 16 Jan 2019 21:09:32 +0000 (21:09 +0000)
committerAndy Street <andy@street.me.uk>
Wed, 16 Jan 2019 21:09:32 +0000 (21:09 +0000)
src/libgpx/peekstream.php

index 5f481fb4ef18ee1c33888bb8ed558473acb93e67..81400fb3b7a0afbb5636852813cd39ef7d26421d 100644 (file)
@@ -120,10 +120,9 @@ class PeekStream
    */
   public function stream_close()
   {
-    $c = count(self::$instances);
-    for ($i = 0; $i < $c; $i++) {
-      if (self::$instances[$i] === $this) {
-        unset(self::$instances[$i]);
+    foreach (self::$instances as $key => $value) {
+      if ($value === $this) {
+        unset(self::$instances[$key]);
         break;
       }
     }
@@ -178,10 +177,9 @@ class PeekStream
   {
     $result = null;
     $instance = null;
-    $c = count(self::$instances);
-    for ($i = 0; $i < $c; $i++) {
-      if (self::$instances[$i]->path === $path) {
-        $instance = self::$instances[$i];
+    foreach (self::$instances as $i) {
+      if ($i->path == $path) {
+        $instance = $i;
         break;
       }
     }