Skip to content

Commit

Permalink
Use stream_get_contents() instead of multiple fread() (#45)
Browse files Browse the repository at this point in the history
* Use stream_get_contents()

* Check for failures
  • Loading branch information
deguif authored Oct 1, 2020
1 parent 43d4a2b commit 2ced65b
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,10 @@ public function render($componentName, $propsString, $uuid, $registeredStores =
}
stream_socket_sendto($sock, $this->wrap($componentName, $propsString, $uuid, $registeredStores, $trace)."\0");

$contents = '';

while (!feof($sock)) {
$contents .= fread($sock, 8192);
if (false === $contents = stream_get_contents($sock)) {
throw new \RuntimeException('Failed to read content from external renderer.');
}

fclose($sock);

$result = json_decode($contents, true);
Expand Down

0 comments on commit 2ced65b

Please sign in to comment.