varspool / Wrench

A simple PHP WebSocket implementation for PHP 7.1
Do What The F*ck You Want To Public License
596 stars 210 forks source link

Runtime Notice: Resource ID#144 used as offset, casting to integer (144) in WebSocket/Server.php line 38 (also, line 45) #7

Closed dominics closed 12 years ago

dominics commented 12 years ago

The line in question:

$this->clients[$ressource] = $client;

where:

$ressource = socket_accept($this->master)

From the PHP manual:

is_scalar() does not consider resource type values to be scalar as resources are abstract datatypes which are currently based on integers. This implementation detail should not be relied upon, as it may change.

Casting to int quietens the notice, and make the assumption about the resource type explicit.