Commits

Thomas Weinert committed dde3818

Added casting to use resource as identifier

Comments (0)

Files changed (1)

src/Carica/Io/Event/Loop/Libevent.php

       if (!is_resource($stream)) {
         throw new \LogicException('%s needs a valid stream resource.', __METHOD__);
       }
-      if (!isset($this->_streams[$stream])) {
-        $this->_streams[$stream] = $listener = new Libevent\Listener\Stream($this, $stream);
+      $index = (int)$stream;
+      if (!isset($this->_streams[$index])) {
+        $this->_streams[$index] = $listener = new Libevent\Listener\Stream($this, $stream);
       } else {
-        $listener = $this->_streams[$stream];
+        $listener = $this->_streams[$index];
       }
       $result = $listener->onRead($callback);
       return $result;
           $event->remove();
         } elseif ($event instanceOf Libevent\Listener\Stream &&
                   ($stream = $event->getStream())) {
-          if (is_resource($stream) && isset($this->_streams[$stream])) {
-            $listener = $this->_streams[$stream];
+          $index = (int)$stream;
+          if (is_resource($stream) && isset($this->_streams[$index])) {
+            $listener = $this->_streams[$index];
             $listener->cancel();
-            unset($this->_streams[$stream]);
+            unset($this->_streams[$index]);
           }
         }
       }