@param iterable $eventClasses
@param iterable $handlerClasses

@return iterable

@throws ReflectionException
771637
private function getEventSubscribers(iterable $eventClasses, iterable $handlerClasses): iterable
    {
        foreach ($handlerClasses as $handlerClass) {
            foreach ($this->selectEvenHandlers($handlerClass) as $eventClass => $subscriber) {
                foreach ($this->getChildEvents($eventClass, $eventClasses) as $childEventClass) {
                    yield $childEventClass => $subscriber;
                }
            }
        }
    }
248184
public function withDefaultThrowableEvent(string $eventClass): self
    {
        if (false === \is_a($eventClass, ExecutionFailedEvent::class, true))
        {
            throw new InvalidEventType(
                \sprintf(
                    'Event class "%s" must implement "%s" interface',
                    $eventClass,
                    ExecutionFailedEvent::class
                )
            );
        }

        $defaultValidationFailedEvent = $this->defaultValidationFailedEvent;

        /**
         * @psalm-var class-string $eventClass
         * @psalm-var class-string|null $defaultValidationFailedEvent
         */

        return new self(
            $this->isEventListener,
            $this->isCommandHandler,
            $this->validationEnabled,
            $this->validationGroups,
            $defaultValidationFailedEvent,
            $eventClass
        );
    }
1080240
public function addListenerCollection( EventListenerCollection $listenerCollection ) {

		$collection = $listenerCollection->getCollection();

		 if( !is_array( $collection ) && !$collection instanceof Traversable ) {
		 	throw new RuntimeException( "Expected a traversable object" );
		 }

		foreach ( $collection as $event => $listeners ) {
			foreach ( $listeners as $listener ) {
				$this->addListener( $event, $listener );
			}
		}
	}
132869
def get_handler_classes(self):
        """"""

        handler_classes = [import_string(handler_cls) for handler_cls in settings.MODERNRPC_HANDLERS]

        if self.protocol == ALL:
            return handler_classes
        else:
            return [cls for cls in handler_classes if cls.protocol in ensure_sequence(self.protocol)]
1316138
public function addHandlers(array $handlers)
    {
        foreach ($handlers as $handler) {
            if (isset($this->know[$handler->getName()])) {
                throw new \RuntimeException(sprintf(
                    'Cannot add handler "%s", handler exists.',
                    $handler->getName()
                ));
            }
            if (!class_exists($handler->getClass())) {
                throw new \RuntimeException(sprintf(
                    'Cannot add handler "%s", command class not exists.',
                    $handler->getName()
                ));
            }
            $this->know[$handler->getName()] = $handler;
        }
    }
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;
    }
1234639
private function getChildEvents(string $eventClass, iterable $eventClasses): iterable
    {
        $reflection = new ReflectionClass($eventClass);
        foreach ($eventClasses as $curEventClass) {
            $curReflection = new ReflectionClass($curEventClass);
            if ($curReflection->isAbstract() === false) {
                if ($eventClass === $curEventClass ||
                    $curReflection->isSubclassOf($eventClass) === true ||
                    ($reflection->isInterface() === true && $curReflection->implementsInterface($eventClass))
                ) {
                    yield $curEventClass;
                }
            }
        }
    }
539179
public function setHandlers($handlers)
    {
        $this->handlers = $handlers;
        $this->setKey($this->getKey());

        return $this;
    }
80880
private static function methodsOf(\ReflectionClass $class): \Iterator
    {
        return new \CallbackFilterIterator(
                new \ArrayIterator($class->getMethods()),
                function(\ReflectionMethod $method)
                {
                    return !$method->isPrivate()
                            && !$method->isFinal()
                            && !$method->isStatic()
                            && !$method->isConstructor()
                            && !$method->isDestructor();
                }
        );
    }
1274108
public T withManagedEntityClasses(Class<?>... entityClasses) {
        configMap.put(MANAGED_ENTITIES, Arrays.asList(entityClasses));
        return getThis();
    }
1268765
public function createInstance($serviceProviderClass, array $serviceClasses)
    {
        if (!class_exists($serviceProviderClass, false)) {
            if (!$this->serviceProviderLoader->canLoad($serviceProviderClass)) {
                $dependencyGraph = $this->dependencyResolver->execute($serviceClasses);
                $source = $this->serviceProviderGenerator->generate($serviceProviderClass, $dependencyGraph);
                $this->serviceProviderLoader->write($serviceProviderClass, $source);
            }

            $this->serviceProviderLoader->load($serviceProviderClass);
        }

        return new $serviceProviderClass();
    }
581323
public function attach(EventManagerInterface $events)
    {
        $options                     = $this->getOptions();
        $configListener              = $this->getConfigListener();

        // High priority, we assume module autoloading (for FooNamespace\Module classes) should be available before anything else
        $this->listeners[] = $events->attach(new ModuleLoaderListener($options));
        $this->listeners[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULE_RESOLVE, new ModuleResolverListener());
        // High priority, because most other loadModule listeners will assume the module's classes are available via autoloading
        $this->listeners[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULE, new AutoloaderListener($options), 9000);

        if ($options->getCheckDependencies()) {
            $this->listeners[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULE, new ModuleDependencyCheckerListener(), 8000);
        }

        $this->listeners[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULE, new InitTrigger($options));
        $this->listeners[] = $events->attach($configListener);

        // This process can be expensive and affect perf if enabled. So we have
        // the flexibility to skip it.
        //if ($options->routingEnabled) {
        $this->listeners[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULE, array($this, 'routesTrigger'), 3000);
        //}

        // @todo - this could be moved to a ZF event, so no need to make this ourselves.
        $this->listeners[] = $events->attach(ModuleEvent::EVENT_LOAD_MODULE, array($this, 'getServicesTrigger'), 3000);

        return $this;
    }
415228
protected static function selectClassInherits(array $classes, string $classOrInterface): iterable
    {
        foreach ($classes as $className) {
            if (static::classInherits($className, $classOrInterface) === true) {
                yield $className;
            }
        }
    }
114528
public function setEventManager( EventManagerInterface $events )
    {
        $events->setEventClass( __NAMESPACE__ . '\ModulesEvent' )
               ->attach(
                    ModulesEvent::EVENT_MODULES,
                    array( $this, 'onModules' ),
                    1000
                );

        return parent::setEventManager( $events );
    }
149935
private function lazyLoadServices(array $eventNames): ContainerMediatorInterface
    {
        foreach ($eventNames as $event) {
            if (!\in_array($event, $this->loadedServices, \true)) {
                $this->loadedServices[] = $event;
            }
            /**
             * @var array $priorities
             * @var int   $priority
             * @var array $listeners
             * @var array $listener
             */
            $priorities = $this->serviceListeners[$event];
            foreach ($priorities as $priority => $listeners) {
                foreach ($listeners as $listener) {
                    $this->addListener($event, [$this->getServiceByName($listener[0]), $listener[1]], $priority);
                }
            }
        }
        return $this;
    }
476683
protected static function selectClassExtends(array $classes, string $parentClass): iterable
    {
        foreach ($classes as $className) {
            if (static::classExtends($className, $parentClass) === true) {
                yield $className;
            }
        }
    }
384925
public function withDefaultValidationFailedEvent(string $eventClass): self
    {
        if (false === \is_a($eventClass, ValidationFailedEvent::class, true))
        {
            throw new InvalidEventType(
                \sprintf(
                    'Event class "%s" must implement "%s" interface',
                    $eventClass,
                    ValidationFailedEvent::class
                )
            );
        }

        $defaultThrowableEvent = $this->defaultThrowableEvent;

        /**
         * @psalm-var class-string $eventClass
         * @psalm-var class-string|null $defaultThrowableEvent
         */

        return new self(
            $this->isEventListener,
            $this->isCommandHandler,
            $this->validationEnabled,
            $this->validationGroups,
            $eventClass,
            $defaultThrowableEvent
        );
    }