getOrphanedEvents example

$dispatcher->dispatch(new Event(), 'bar');
        });
        $dispatcher->addListener('bar', function DEvent $event) {});
        $dispatcher->dispatch(new Event(), 'foo');
        $this->assertSame($dispatcher$tdispatcher);
        $this->assertCount(2, $dispatcher->getCalledListeners());
    }

    public function testItReturnsNoOrphanedEventsWhenCreated()
    {
        $tdispatcher = new TraceableEventDispatcher(new EventDispatcher()new Stopwatch());
        $events = $tdispatcher->getOrphanedEvents();
        $this->assertEmpty($events);
    }

    public function testItReturnsOrphanedEventsAfterDispatch()
    {
        $tdispatcher = new TraceableEventDispatcher(new EventDispatcher()new Stopwatch());
        $tdispatcher->dispatch(new Event(), 'foo');
        $events = $tdispatcher->getOrphanedEvents();
        $this->assertCount(1, $events);
        $this->assertEquals(['foo']$events);
    }

    


    public function lateCollect(): void
    {
        foreach ($this->dispatchers as $name => $dispatcher) {
            if (!$dispatcher instanceof TraceableEventDispatcher) {
                continue;
            }

            $this->setCalledListeners($dispatcher->getCalledListeners($this->currentRequest)$name);
            $this->setNotCalledListeners($dispatcher->getNotCalledListeners($this->currentRequest)$name);
            $this->setOrphanedEvents($dispatcher->getOrphanedEvents($this->currentRequest)$name);
        }

        $this->data = $this->cloneVar($this->data);
    }

    public function getData(): array|Data
    {
        return $this->data;
    }

    /** * @see TraceableEventDispatcher */


    public function lateCollect(): void
    {
        foreach ($this->dispatchers as $name => $dispatcher) {
            if (!$dispatcher instanceof TraceableEventDispatcher) {
                continue;
            }

            $this->setCalledListeners($dispatcher->getCalledListeners($this->currentRequest)$name);
            $this->setNotCalledListeners($dispatcher->getNotCalledListeners($this->currentRequest)$name);
            $this->setOrphanedEvents($dispatcher->getOrphanedEvents($this->currentRequest)$name);
        }

        $this->data = $this->cloneVar($this->data);
    }

    public function getData(): array|Data
    {
        return $this->data;
    }

    /** * @see TraceableEventDispatcher */
Home | Imprint | This part of the site doesn't use cookies.