Remove event listener from event loop.

@param mixed $fd
@param int   $flag
@return bool
1282
public function del($fd, $flag)
    {
        switch ($flag) {
            case EventInterface::EV_READ:
                return $this->removeReadStream($fd);
            case EventInterface::EV_WRITE:
                return $this->removeWriteStream($fd);
            case EventInterface::EV_SIGNAL:
                return $this->removeSignal($fd);
            case EventInterface::EV_TIMER:
            case EventInterface::EV_TIMER_ONCE;
                if (isset($this->_timerIdMap[$fd])){
                    $timer_obj = $this->_timerIdMap[$fd];
                    unset($this->_timerIdMap[$fd]);
                    $this->cancelTimer($timer_obj);
                    return true;
                }
        }
        return false;
    }
312731
public function has($flag)
    {
        $values = $this->getValuesFromFlagOrEnum($flag);

        if (empty($values)) {
            return false;
        }

        foreach ($values as $value) {
            if (!(bool) ($this->value & $value)) {
                return false;
            }
        }

        return true;
    }
1152524
public function setFlag($flag)
	{
		if ( $flag == $this->getFlag() ) { return; }

		$this->_values['flag'] = (int) $flag;
		$this->setModified();
	}
117848
public function removeListener(EventListener $listener)
    {
        if (($i = array_search($listener, $this->listeners)) !== false) {
            unset($this->listeners[$i]);
        }
        return $this;
    }
878952
public function withoutFlag($flag): void
    {
        $flag = $this->parseFlag($flag);

        $this->flags = $this->flags & ~$flag;
    }
465967
public function add($fd, $flag, callable $callback, $args = null )
    {
        switch ($flag) {
            case static::EV_READ:
            case static::EV_WRITE:
                $fd_key    = (int)$fd;
                $eventFlag = $flag === static::EV_READ ? \Event::READ : \Event::WRITE;
                $event = new \Event($this->eventBase, $fd, $eventFlag|\Event::PERSIST, $callback, $args);
                $event->add();
                $this->fdEvents[$fd_key][$flag] = $event;
                break;
            case static::EV_SIGNAL:
                $eventFlag = \Event::SIGNAL | \Event::PERSIST;
                $event = new \Event($this->eventBase, $fd, $eventFlag, $callback, $args);
                $event->add();
                $this->signalEvents[$fd] = $event;
                break;
            case static::EV_INTERVAL:
            case static::EV_TIMEOUT:
                $timerId = static::generateId();
                
                $interval = $fd;
                
                $eventFlag = $flag === static::EV_INTERVAL ? \Event::TIMEOUT|\Event::PERSIST : \Event::TIMEOUT;
                
                $this->timerEvents[$timerId] = new \Event(
                    $this->eventBase, 
                    -1, 
                    $eventFlag, 
                    [$this, 'timeoutCallback'], 
                    [$callback, $timerId, $interval, $flag, $args]
                    );
                
                $this->timerEvents[$timerId]->add($interval/1000);
                return $timerId;
                break;
        }
    }
123113
public function add($fd, $flag, $func, $args = null)
    {
        $callback = function ($event, $socket) use ($fd, $func) {
            try {
                call_user_func($func, $fd);
            } catch (\Exception $e) {
                Worker::log($e);
                exit(250);
            } catch (\Error $e) {
                Worker::log($e);
                exit(250);
            }
        };
        switch ($flag) {
            case self::EV_SIGNAL:
                $event                   = new \EvSignal($fd, $callback);
                $this->_eventSignal[$fd] = $event;
                return true;
            case self::EV_TIMER:
            case self::EV_TIMER_ONCE:
                $repeat                             = $flag == self::EV_TIMER_ONCE ? 0 : $fd;
                $param                              = array($func, (array)$args, $flag, $fd, self::$_timerId);
                $event                              = new \EvTimer($fd, $repeat, array($this, 'timerCallback'), $param);
                $this->_eventTimer[self::$_timerId] = $event;
                return self::$_timerId++;
            default :
                $fd_key                           = (int)$fd;
                $real_flag                        = $flag === self::EV_READ ? \Ev::READ : \Ev::WRITE;
                $event                            = new \EvIo($fd, $real_flag, $callback);
                $this->_allEvents[$fd_key][$flag] = $event;
                return true;
        }

    }
1257375
public function filter(callable $callback = null, int $flag = ARRAY_FILTER_USE_BOTH)
	{
		if ($callback)
		{
			return new self(
				array_filter($this->items, $callback, $flag)
			);
		}
		else
		{
			return new self(array_filter($this->items));
		}
	}
857106
public function detach($event, $callback)
    {
        if ($this->hasEvent($event)) {
            $this->removeEventCallable($event, $callback);
        } elseif ('' === $event) {
            $this->events = []; // remove all events
        }
        return true;
    }
670804
public function toggle($flag, $name)
    {
        switch ($flag) {
            case 'on':
                $onoff = true;
                break;
            case 'off':
                $onoff = false;
                break;
            default:
                throw new \InvalidArgumentException("Flag must be 'on' or 'off'");
        }

        switch ($name) {
            case 'debug':
                $this->debug = $onoff;
                break;
            case 'info':
                $this->info = $onoff;
                break;
            case 'notice':
                $this->notice = $onoff;
                break;
            case 'warn':
                $this->warn = $onoff;
                break;
            case 'error':
                $this->error = $onoff;
                break;
            case 'critical':
                $this->critical = $onoff;
                break;
            case 'alert':
                $this->alert = $onoff;
                break;
            case 'emergency':
                $this->emergency = $onoff;
                break;
            default:
                throw new \InvalidArgumentException("Name must be on (debug|info|notice|warn|error|critical|alert|emergency)");
        }
    }
781346
public function clearFlag(array $mailsIds, $flag) {
		return imap_clearflag_full($this->getImapStream(), implode(',', $mailsIds), $flag, ST_UID);
	}
1039804
public function hasFlag($flag) {
        if (!is_string($flag)) {
            throw new \Console\Exception\InvalidArgument('Parameter must be string.');
        }
        
        return in_array($flag, $this->_flags);
    }
856548
function _off(sel, evt, fn) {
    $each(_bound(sel, evt, fn), (e) => {
        if (`on${e.evt}` in _doc) {
            e.el.removeEventListener(e.evt, e.cb);
        } else if (custom[e.evt]) {
            custom[e.evt][1](e.el, e.cb);
        }

        bound.splice(bound.indexOf(e), 1);
    });
}
363598
public function removeListener($event, $listener)
    {
        if (! $this->hasListener($event)) {
            return;
        }

        $event = $this->getEventName($event);
        $listeners = $this->listeners[$event];

        foreach ($listeners as $priority => $registed) {
            $listeners[$priority] = array_filter($registed, function ($reg) use ($listener) {
                return ! $reg->isListener($listener);
            });
        }

        $this->listeners[$event] = $listeners;

        unset($this->sortedListeners[$event], $listeners, $event);
    }
221551
public function leave($fd)
    {
        if($this->handler->leaveGroup($this->groupName, $fd))
        {
            RequestContext::getServerBean('FdMap')->leaveGroup($fd, $this);
            Event::trigger('IMI.SERVER.GROUP.LEAVE', [
                'server'    => RequestContext::getServer(),
                'groupName' => $this->groupName,
                'fd'        => $fd,
            ]);
        }
    }
923188
public function removeListener(string $eventName, callable $listener) : bool
    {
        if (!isset($this->listeners[$eventName])) {
            return false;
        }
        foreach ($this->listeners[$eventName][2] as $index => $check) {
            if ($check === $listener) {
                unset($this->listeners[$eventName][1][$index]);
                unset($this->listeners[$eventName][2][$index]);
                return true;
            }
        }
        return false;
    }
127091
public function debug($flag)
    {
        $this->debug = (in_array($flag, [true, false])) ? $flag : false;

        return $this;
    }