diff --git a/src/ChromeDevtoolsProtocol/DevtoolsClient.php b/src/ChromeDevtoolsProtocol/DevtoolsClient.php index 749dea4d..31e83934 100644 --- a/src/ChromeDevtoolsProtocol/DevtoolsClient.php +++ b/src/ChromeDevtoolsProtocol/DevtoolsClient.php @@ -111,9 +111,9 @@ public function awaitEvent(ContextInterface $ctx, string $method) $this->handleMessage($message); } - if (!empty($this->eventBuffers[$method])) { - return array_shift($this->eventBuffers[$method])->params; - } + if (!empty($this->eventBuffers[$method])) { + return array_shift($this->eventBuffers[$method])->params; + } } } @@ -129,10 +129,10 @@ private function handleMessage($message) } } - if (!isset($this->eventBuffers[$message->method])) { - $this->eventBuffers[$message->method] = []; - } - array_push($this->eventBuffers[$message->method], $message); + if (!isset($this->eventBuffers[$message->method])) { + $this->eventBuffers[$message->method] = []; + } + array_push($this->eventBuffers[$message->method], $message); } else if (isset($message->id)) { $this->commandResults[$message->id] = $message->result ?? new \stdClass(); diff --git a/src/ChromeDevtoolsProtocol/Session.php b/src/ChromeDevtoolsProtocol/Session.php index 502ac1fa..cbc2cee4 100644 --- a/src/ChromeDevtoolsProtocol/Session.php +++ b/src/ChromeDevtoolsProtocol/Session.php @@ -121,9 +121,9 @@ public function awaitEvent(ContextInterface $ctx, string $method) $this->handleMessage(json_decode($receivedMessage->message)); } - if (!empty($this->eventBuffers[$method])) { - return array_shift($this->eventBuffers[$method])->params; - } + if (!empty($this->eventBuffers[$method])) { + return array_shift($this->eventBuffers[$method])->params; + } } } @@ -142,10 +142,10 @@ private function handleMessage($message) } } - if (!isset($this->eventBuffers[$message->method])) { - $this->eventBuffers[$message->method] = []; - } - array_push($this->eventBuffers[$message->method], $message); + if (!isset($this->eventBuffers[$message->method])) { + $this->eventBuffers[$message->method] = []; + } + array_push($this->eventBuffers[$message->method], $message); } else if (isset($message->id)) { $this->commandResults[$message->id] = $message->result ?? new \stdClass();