移除事件处理器.
@param array $event 事件.
@param string $name 事件名.
@param string $class 类名.
@param callable $handler 匿名函数.
@return bool
187362
private static function remove(
        array &$event,
        string $name,
        string $class,
        ? callable $handler
    ): bool {
        $removed = false;
        if (isset($event[$name][$class])) {
            foreach ($event[$name][$class] as $i => $item) {
                if ($item[0] === $handler) {
                    unset($event[$name][$class][$i]);
                    $removed = true;
                }
            }
            if ($removed) {
                $event[$name][$class] = array_values($event[$name][$class]);
                if (empty($event[$name][$class])) {
                    unset($event[$name][$class]);
                    if (empty($event[$name])) {
                        unset($event[$name]);
                    }
                }
            }
        }
        return $removed;
    }
561866
public function hasEventHandlers($name)
    {
        $this->ensureBehaviors();
        return !empty($this->__events__[$name]) || Event::hasHandlers($this, $name);
    }
354739
public static function trigger(
        $class,
        string $name,
        self $event = null
    ): void {
        $wildcardEventHandlers = [];
        foreach (static::$_eventWildcards as
            $nameWildcard => $classHandlers) {
            if (!StringHelper::matchWildcard($nameWildcard, $name)) {
                continue;
            }
            $wildcardEventHandlers = array_merge(
                $wildcardEventHandlers,
                $classHandlers
            );
        }

        if (
            empty(static::$_events[$name])
            && empty($wildcardEventHandlers)
        ) {
            return;
        }

        $event === null && $event = new static;
        $event->handled = false;
        $event->name = $name;

        if (is_object($class)) {
            $event->sender === null && $event->sender = $class;
            $class = get_class($class);
        } else {
            $class = ltrim($class, '\\');
        }

        $classes = array_merge(
            [$class],
            class_parents($class, true),
            class_implements($class, true)
        );

        foreach ($classes as $class) {
            $eventHandlers = [];
            foreach ($wildcardEventHandlers as $classWildcard => $handlers) {
                if (StringHelper::matchWildcard($classWildcard, $class)) {
                    $eventHandlers = array_merge($eventHandlers, $handlers);
                    unset($wildcardEventHandlers[$classWildcard]);
                }
            }

            if (!empty(static::$_events[$name][$class])) {
                $eventHandlers = array_merge(
                    $eventHandlers,
                    static::$_events[$name][$class]
                );
            }

            foreach ($eventHandlers as $handler) {
                $event->data = $handler[1];
                call_user_func($handler[0], $event);
                if ($event->handled) {
                    return;
                }
            }
        }
    }
844420
protected function trigger($event, &$params)
    {
        if (isset(self::$event[$this->class][$event])) {
            foreach (self::$event[$this->class][$event] as $callback) {
                if (is_callable($callback)) {
                    $result = call_user_func_array($callback, [ & $params]);
                    if (false === $result) {
                        return false;
                    }
                }
            }
        }
        return true;
    }
142190
function(event, name) {

            var eventListeners = this.__getEventListeners(event);

            if (!(name in eventListeners)) {
                throw new Error('Event listener for event "' + event + '" with name "' + name + '" does not exist!');
            }

            return eventListeners[event][name];
        }
271196
function register(string $name, string $class) {
        if(!\in_array('CharlotteDunois\Yasmin\Interfaces\WSEventInterface', \class_implements($class))) {
            throw new \RuntimeException('Specified event class does not implement interface');
        }
        
        $this->wsevents[$name] = new $class($this->wshandler->wsmanager->client, $this->wshandler->wsmanager);
    }
1190439
public function handler($handler)
    {

        if ($this->isNumber($handler) || $this->isBoolean($handler) || $this->isEmpty($handler)) {
            throw new EventManagerException(EventManagerException::INVALID_EVENT_HANDLER);
        }

        if ($this->isString($handler) || $this->isStringObject($handler)) {
            $handler = StdObjectWrapper::toString($handler);
            if (!class_exists($handler)) {
                throw new EventManagerException(EventManagerException::INVALID_EVENT_HANDLER);
            }
            $handler = new $handler;
        }
        $this->handler = $handler;

        return $this;
    }
986341
public function has_handler( $name ) {

		$name instanceof HandlerInterface and $name = spl_object_hash( $name );

		return is_string( $name ) && array_key_exists( $name, $this->handlers );
	}
711565
public function listen($name, $fn, $context = array())
    {
        $event = new Event($name, $fn, $context);
        if (!isset($this->handlers[$name])) {
            $this->handlers[$name] = array();
        }
        $this->handlers[$name][] = $event;// array('fn' => $fn, 'context' => $context);
        return $event;
    }
181949
public function off($name, $callback)
    {
        if(isset($this->events[$name]))
        {
            // 数据映射
            $this->events[$name]->detach($callback);
            $this->eventChangeRecords[$name] = true;
        }
    }
815099
public static function trigger($event, $data = null)
	{
		if (!is_array($data)) {
			$data = array($data);
		}

		if (empty(self::$events[$event])) {
			return true;
		}
		
		foreach (self::$events[$event] as $callback) {
			if (!is_callable($callback)) {
				continue;
			}
			call_user_func_array($callback, $data);
		}
		
		return true;
	}
509012
public function on($method, $path, $handler, $name = '') {
		if (!$this->result->hasHandler()
			&& $this->prefixMatched
			&& $this->request->isMethod($method)
		) {
			if ($this->matchPartial($path, true)) {
				$handlers = (array)$handler;

				if ($this->namespace) {
					foreach ($handlers as &$handler) {
						$handler = $this->namespace . $handler;
					}
				}

				if ($this->middlewares) {
					$handlers = array_merge($this->middlewares, $handlers);
				}

				$this->result->setHandler($handlers);
				$this->result->setStatus(200);
				$this->result->setParams($this->params);
			}
		}

		if ($name) {
			$this->urlGenerator->add($name, $this->prefix . $path);
		}

		return $this;
	}
408811
public static function countHandlers($class, $name)
    {
        $class = ObjectHelper::getClass($class);
        $count = 0;

        do {
            if (!empty(self::$events[$class][$name])) {
                $count += count(static::$events[$class][$name]);
            }
        } while (($class = get_parent_class($class)) !== false);

        return $count;
    }
719069
public static function trigger($name, Event $data)
    {
        if (self::$dispatcher) {
            if (!is_array($name)) {
                $name=array($name);
            }
            foreach ($name as $n) {
                call_user_func_array(self::$dispatcher, self::$dispatcher_args)->dispatch($n, $data);
            }
        }
    }
1010915
public function on($name, $handler, $data=array(), $append=true)
	{
		$this->ensureEvents();
		
		if ($append || empty($this->_events[$name])) {
		    $this->_events[$name][] = $data ? [$handler, $data] : [$handler];
		} else {
		    array_unshift($this->_events[$name], $data ? [$handler, $data] : [$handler]);
		}
	}
787473
public function fireEvent($name, $params = null)
    {
        $handleList = Utility::get($this->events, $name, null);
        $result = true;
        if ($handleList) {
            foreach ($handleList as $methodName) {
                if (gettype($methodName) == "string") {
                    $return = $this->$methodName($params);
                } else {
                    $return = $methodName($params);
                }
                $result &= ($return !== null) ? $return : true;
            }
        }
        //Allow to write event handle in the report
        if (method_exists($this, $name)) {
            $return = $this->$name($params);
            $result &= ($return !== null) ? $return : true;
        }
        return $result;
    }
177871
public function serializeEvent($name, Event $event)
    {
        $context = SerializationContext::create();

        return serialize(array(
            'name' => $name,
            'class' => get_class($event),
            'event' => $this->serializer->serialize($event, 'json', $context),
        ));
    }