hoaproject / Http

The Hoa\Http library.

Home Page:https://hoa-project.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trying to access array offset on value of type bool on Response destruction

syl20b opened this issue · comments

Hello,

I'm using the HTTP (v1.17.01.13) component through the Websocket library (v3.17.01.09), and I've got an issue when the \Hoa\Http\Response\Response::__destruct() method is called :

Trying to access array offset on value of type bool in /XXX/hoa/http/Response/Response.php on line 947

It seems to be because the response is initialized with the parameter $newBuffer = false, and the self::$_stack is empty.

This is the line the error occurred in the __destruct method :

$last = current(self::$_stack);

Change the line above with this seems to fix the bug:

if (false === $last = current(self::$_stack)) {
    return;
}