function __destruct() { if (isset($this->events['disconnect']) && is_callable($func = $this->events['disconnect'])) { $func($this); } }