Stops listening to an event

@param string|null   $event    name of the event
@param callable|null $callable callback handler

@return Eden\Core\Base
973727
public function off($event = null, $callable = null)
    {
         Argument::i()
            //argument 1 must be a string or null
            ->test(1, 'string', 'null')
            //argument 2 must be a callable or null
            ->test(2, 'callable', 'null');

        Event::i()->off($event, $callable);

        return $this;
    }
646192
protected function _callListener(callable $listener, Event $event)
    {
        $data = $event->getData();

        return $listener($event, ...array_values($data));
    }
423311
public function off(string $event = null, callable $callback = null): EventInterface
    {
        //if there is no event and not callable
        if (is_null($event) && is_null($callback)) {
            //it means that they want to remove everything
            $this->observers = [];
            return $this;
        }

        //if there are callbacks listening to
        //this and no callback was specified
        if (isset($this->observers[$event]) && is_null($callback)) {
            //it means that they want to remove
            //all callbacks listening to this event
            unset($this->observers[$event]);
            return $this;
        }

        //if there are callbacks listening
        //to this and we have a callback
        if (isset($this->observers[$event]) && is_callable($callback)) {
            return $this->removeObserversByEvent($event, $callback);
        }

        //if no event, but there is a callback
        if (is_null($event) && is_callable($callback)) {
            return $this->removeObserversByCallback($callback);
        }

        // @codeCoverageIgnoreStart
        return $this;
        // @codeCoverageIgnoreEnd
    }
761575
public function subscribe(string $event, string $listener, callable $callback)
    {
        $callbackKey = $event . ' ' . $listener;
        $this->events[$event][] = $callbackKey;
        $this->subscriptions[$callbackKey] = $callback;
    }
571875
public function setCallback(callable $callback): EventObserver
    {
        $this->callback = $callback;
        $this->id = $this->getId($callback);

        return $this;
    }
1170649
public function onBefore($event, callable $listener)
    {

        if (strpos($event, '*') !== false) {
            $this->beforeAnyListeners[] = $this->toWildcardListener($event, $listener);
            return $this;
        }

        self::parentOnBefore($event, $listener);

        return $this;
    }
1180817
public function trigger($event)
    {
        if ($this->has($event)) {
            return call_user_func($this->listeners[$event]);
        } else {
            throw new RuntimeException(sprintf(
                'Cannot trigger non-existing event "%s"', $event
            ));
        }
    }
1003046
public function removeListener( $event, EventListener $listener = null ) {

		$event = strtolower( $event );

		if ( !$this->hasEvent( $event ) ) {
			return;
		}

		if ( $listener !== null ) {
			foreach ( $this->dispatchableListeners[$event] as $key => $dispatchableListener ) {
				if ( $dispatchableListener == $listener ) {
					unset( $this->dispatchableListeners[$event][$key] );
				}
			}
		}

		if ( $listener === null || $this->dispatchableListeners[$event] === array() ) {
			unset( $this->dispatchableListeners[$event] );
		}
	}
73915
public function unlisten($event = null, $listener = null)
    {
        // if event is null, remove all listeners
        if ($event=== null){
            $this->listeners = null;
            return;
        }
        // if listener parameter set null, all event specific listeners are removed
        if (!$listener){
            unset($this->listeners[$event]);
            return;
        }
        // get event specific listeners
        $listers_of_event = isset($this->listeners[$event]) ? $this->listeners[$event] : null;
        // remove all listeners
        if (is_array($listers_of_event)){
            while(($key=array_search($listener,$listers_of_event,true)) !== false){
                unset($listers_of_event[$key]);
                if (!empty($listers_of_event)){
                    // update listener holder, if listeners still exist
                    $this->listeners[$event] = $listers_of_event;
                }
                else{
                    // clean empty listener holder
                    unset($this->listeners[$event]);
                }
            }
        }
    }
774465
protected function removeObserversByEvent(string $event, callable $callback): EventInterface
    {
        //if event isn't set
        if (!isset($this->observers[$event])) {
            //do nothing
            return $this;
        }

        //'foobar' => array(
        foreach ($this->observers[$event] as $i => $observer) {
            //0 => callback
            if ($observer['observer']->assertEquals($callback)) {
                unset($this->observers[$event][$i]);
            }
        }

        return $this;
    }
320982
public function triggerEvent($event, $args = [])
    {
        if (!is_string($event) && !$event instanceof Event) {
            throw new \InvalidArgumentException(sprintf(
                '%s::%s only allow Event object or string.',
                get_called_class(),
                __FUNCTION__
            ));
        }

        if (!($event instanceof Event)) {
            if (isset($this->events[$event])) {
                $event = $this->events[$event];
            } else {
                $event = new Event($event);
            }
        }

        $event->mergeArguments($args);

        $listeners = [];

        if (isset($this->listeners[$event->getName()])) {
            foreach ($this->listeners[$event->getName()] as $listener) {
                if ($event->isStopped()) {
                    return $event;
                }

                if (!is_callable($listener)) {
                    $listener = [$listener, $event->getName()];
                }

                if (!is_callable($listener)) {
                    continue;
                }

                $listener($event);

                if ($this->debug) {
                    $listeners[] = $listener;
                }
            }
        }

        if ($this->debug) {
            $executedListeners = [];

            foreach ($listeners as $listener) {
                if ($listener instanceof \Closure) {
                    $ref = new \ReflectionFunction($listener);

                    $listener = ['{Closure}: ' . $ref->getFileName() . ' - Line: ' . $ref->getStartLine()];
                }

                if (is_object($listener[0])) {
                    $listener[0] = get_class($listener[0]);
                }

                $executedListeners[] = $listener;
            }

            $this->collector[] = [
                'event' => $event->getName(),
                'listeners' => $executedListeners,
            ];
        }

        return $event;
    }
886816
public function dispatchUntil(ActionEvent $event, callable $callback): void
    {
        foreach ($this->getListeners($event) as $listenerHandler) {
            $listener = $listenerHandler->getActionEventListener();
            $listener($event);

            if ($event->propagationIsStopped()) {
                return;
            }
            if ($callback($event) === true) {
                return;
            }
        }
    }
509060
public function off(string $eventName, callable $handler = null, int $priority = null): self
    {
        if ($handler === null) {
            return $this->offAll($eventName);
        }

        $priority === null
            ? $this->offHandlerWithoutPriority($eventName, $handler)
            : $this->offHandlerWithPriority($eventName, $handler, $priority);

        if (empty($this->listeners[$eventName])) {
            unset($this->listeners[$eventName], $this->sorted[$eventName]);
        }

        return $this;
    }
1055707
public function on($event, callable $fn) {
        if (!isset($this->events[$event])) {
            $this->events[$event] = [];
        }
        $this->events[$event][] = $fn;
        return $this;
    }
1072347
protected function removeListenerFromEvent(callable $listener, string $event) : interfaces\Emitter
    {
        foreach ($this->listeners[$event] as $priority => $listeners) {
            if (false !== $key = array_search($listener, $listeners, true)) {
                unset($this->listeners[$event][$priority][$key], $this->chain[$event]);
            }
        }

        return $this;
    }
767661
public function unSubscribe(string $eventName, callable $subscriber): self
    {
        if (($subscriber instanceof Closure) === false &&
            ($staticMethod = $this->parseStaticMethod($subscriber)) !== null
        ) {
            $subscriber = $this->getUnifiedStaticMethodRepresentation($staticMethod);
        }

        $eventSubscribers = $this->getEventSubscribers($eventName);
        $eventSubscribers = array_filter($eventSubscribers, function ($curSubscriber) use ($subscriber) {
            return $curSubscriber !== $subscriber;
        });

        return $this->setEventSubscribers($eventName, $eventSubscribers);
    }
649324
public function detach($event, $callback)
    {
        if (null !== $callback) {
            $oid = $this->hashCallable($callback);
            if (isset($this->callable_map[$event][$oid])) {
                $callback = $this->callable_map[$event][$oid];
                unset($this->callable_map[$event][$oid]);
            }
        } else {
            unset($this->callable_map[$event]);
        }
        return parent::detach($event, $callback);
    }