@param string $handlerClass

@return iterable

@throws ReflectionException
321112
private function selectEvenHandlers(string $handlerClass): iterable
    {
        $reflection = new ReflectionClass($handlerClass);
        foreach ($reflection->getMethods(ReflectionMethod::IS_STATIC | ReflectionMethod::IS_PUBLIC) as $method) {
            if ($this->isEventHandlerMethod($method) === true) {
                $eventClass = $method->getParameters()[0]->getClass()->getName();
                $subscriber = [$handlerClass, $method->getName()];
                yield $eventClass => $subscriber;
            }
        }
    }
197585
public function getClass($class)
    {
        $cacheKey = self::CACHE_KEY_CLASSES . strtolower($class);

        if (! $reflectionClass = $this->cache->fetch($cacheKey)) {
            $reflectionClass = new ReflectionClass($class);
            $this->cache->store($cacheKey, $reflectionClass);
        }

        return $reflectionClass;
    }
1200656
public function toClass($class)
    {
        if (count($this->traitReflections) == 0) {
            throw new BadMethodCallException("No traits to add were found. Call 'addTrait' first.");
        }

        $classReflection = new ReflectionClass($class);

        $filePath = $classReflection->getFileName();

        $content = file($filePath);

        foreach ($this->traitReflections as $traitReflection) {
            $handler = new AbstractTreeHandler(
                $content,
                $traitReflection->getName(),
                $classReflection->getName()
            );

            $content = $handler->handle()->toArray();
        }

        file_put_contents($filePath, implode($content));

        return $this;
    }
421203
private function fetchParametersForHandlerFactoryMethod(string $handlerClassName): array
    {
        if (! isset($this->tagHandlerParameterCache[$handlerClassName])) {
            $methodReflection = new \ReflectionMethod($handlerClassName, 'create');
            $this->tagHandlerParameterCache[$handlerClassName] = $methodReflection->getParameters();
        }

        return $this->tagHandlerParameterCache[$handlerClassName];
    }
307878
public function setHandler($handlerName, $handlerCallback)
    {
        $this->checkHandlerName($handlerName);

        if (!is_callable($handlerCallback))
        {
            throw new RuntimeException("Handler callback must be callable");
        }

        $this->handlers[$handlerName] = $handlerCallback;

        return $this;
    }
1018825
public static function getInstance($class = null)
    {
        $reflector = null;

        if (class_exists($class)) {
            throw new \Exception(sprintf('Class %s not found', $class));
        }

        $reflector = new ReflectionClass('\\'.$class);

        return new $reflector->name();
    }
733092
public function instanceApp(string $applicationClass): ApplicationInterface
    {
        if (!$this->applicationConfig->isApplicationClassValid($applicationClass)) {
            throw new \RuntimeException('Invalid application class: ' . $applicationClass);
        }
        try {
            $arguments = $this->applicationConfig->getApplicationArguments(
                $this->applicationConfig->getApplicationIdByClass($applicationClass)
            );
        } catch (\RuntimeException $e) {
            $arguments = [];
        }

        $appId = $this->applicationConfig->getApplicationIdByClass($applicationClass);

        return $this->instanceAppWith(
            $applicationClass,
            $arguments,
            ['appId' => $appId]
        );
    }
308617
protected function getClassProviders(\ReflectionClass $class) {
		$annotations = Omocha::getAnnotations($class);
		
		//get class providers
		$providers = $annotations->find('Provider', Filter::TYPE_STRING);
		
		if (!empty($providers)) {
			$classes = [];
			
			foreach ($providers as $provider) {
				$classes[] = $provider->getValue();
			}
			
			return $classes;
		}
		
		//if no providers are specified try getting them from parent class
		if ($annotations->has('ExtendInject')) {
			$extend = $annotations->get('ExtendInject')->getValue();
			
			if ($extend) {
				$parent = $class->getParentClass();
				return $parent instanceof \ReflectionClass ? $this->getClassProviders($parent) : [];
			}
		}
		
		return [];
	}
565415
public static function newInstance($class) {
		$className = str_replace(':', '\\', $class);
		$reflectedClass = new ReflectionClass($className);

		if ($reflectedClass->isInstantiable()) {
			$constructor = $reflectedClass->getConstructor();

			if ($constructor) {
				$parameters = $constructor->getParameters();
				$constructorParameters = array();

				foreach ($parameters as $parameter) {
					if ($parameter->getClass()) {
						$constructorParameters[] = self::newInstance($parameter->getClass()->getName());
					} else {
						$constructorParameters[] = $parameter->getDefaultValue();
					}
				}

				return $reflectedClass->newInstanceArgs($constructorParameters);
			} else {
				return $reflectedClass->newInstance();
			}

		} else {
			throw new Exception($class." is not instantiable Class");
		}
	}
583913
public function fromReflection(ReflectionClass $reflectionClass) : array
    {
        $class      = new Class_($reflectionClass->getShortName());
        $statements = array($class);

        if ($parentClass = $reflectionClass->getParentClass()) {
            $class->extends = new FullyQualified($parentClass->getName());
        }

        $interfaces = array();

        foreach ($reflectionClass->getInterfaces() as $reflectionInterface) {
            $interfaces[] = new FullyQualified($reflectionInterface->getName());
        }

        $class->implements = $interfaces;

        foreach ($reflectionClass->getConstants() as $constant => $value) {
            $class->stmts[] = new ClassConst(
                array(new Const_($constant, BuilderHelpers::normalizeValue($value)))
            );
        }

        foreach ($reflectionClass->getProperties() as $reflectionProperty) {
            $class->stmts[] = $this->buildProperty($reflectionProperty);
        }

        foreach ($reflectionClass->getMethods() as $reflectionMethod) {
            $class->stmts[] = $this->buildMethod($reflectionMethod);
        }

        if (! $namespace = $reflectionClass->getNamespaceName()) {
            return $statements;
        }

        return array(new Namespace_(new Name(explode('\\', $namespace)), $statements));
    }
621710
public static function callback($handler)
    {
        if ($handler instanceof Closure) {
            return $handler;
        }
        if (is_object($handler[0])) {
            return $handler;
        }

        // If the first argument is a class name string,
        // then create the controller object.
        if (is_string($handler[0])) {

            // If users define the constructor arguments in options array.
            $constructArgs = [];
            $rc = new ReflectionClass($handler[0]);
            if (isset($options['constructor_args'])) {
                $con = $handler[0] = $rc->newInstanceArgs($constructArgs);
            } else {
                $con = $handler[0] = $rc->newInstance();
            }

            return $handler;
        }

        throw new LogicException('Unsupported handler type');
    }
904542
protected function buildClassEventCallback( $class, $prefix )
	{
		list( $class, $method ) = $this->parseClassEvent( $class, $prefix );

		// Once we have the class and method name, we can build the Closure to resolve
		// the instance out of the IoC container and call the method on it with the
		// given arguments that are passed to the Closure as the composer's data.
		return function () use ( $class, $method )
		{
			$callable = [UniversalBuilder::resolveClass( $class ), $method];

			return call_user_func_array( $callable, func_get_args() );
		};
	}
1141870
public static function get($class)
    {
        $key = strtolower($class);

        if (isset(static::$instances[$key])) {
            return static::$instances[$key];
        }

        static::override($class);

        if (!class_exists($class)) {
            throw new ReflectionException("Class $class does not exist");
        }

        $instance = static::getInstance($class);
        static::register($class, $instance);
        return $instance;
    }
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;
                }
            }
        }
    }
319040
public function staticHandle($class): StaticHandle
    {
        if ($class instanceof StaticHandle) {
            return $class;
        }

        if ($class instanceof Handle) {
            $class = $class->class();
        } elseif ($class instanceof Mock) {
            $class = new ReflectionClass($class);
        } elseif (is_string($class)) {
            try {
                $class = new ReflectionClass($class);
            } catch (ReflectionException $e) {
                throw new NonMockClassException($class, $e);
            }
        } elseif (!$class instanceof ReflectionClass) {
            throw new InvalidMockClassException($class);
        }

        if (!$class->isSubclassOf(Mock::class)) {
            throw new NonMockClassException($class->getName());
        }

        $handleProperty = $class->getProperty('_staticHandle');
        $handleProperty->setAccessible(true);

        if ($handle = $handleProperty->getValue(null)) {
            return $handle;
        }

        $handle = new StaticHandle(
            $class,
            (object) [
                'defaultAnswerCallback' =>
                    [StubData::class, 'forwardsAnswerCallback'],
                'stubs' => (object) [],
                'isRecording' => true,
            ],
            $this->stubFactory,
            $this->stubVerifierFactory,
            $this->emptyValueFactory,
            $this->assertionRenderer,
            $this->assertionRecorder,
            $this->invoker
        );

        $handleProperty->setValue(null, $handle);

        return $handle;
    }
792250
public function setModel($modelClass) {
		$reflection = new ReflectionClass($modelClass);
		if (! $reflection->implementsInterface('ZExt\Model\ModelInterface')) {
			throw new Exception('Class of a model must implements "ModelInterface"');
		}
		
		$this->_modelClass = $modelClass;
		
		if (! empty($this->_models)) {
			$currentModels = $this->_models;
			$this->_models = [];

			foreach ($currentModels as $key => $model) {
				if ($model instanceof $modelClass) {
					$this->_models[$key] = $model;
				} else {
					$model->uninitialize();
				}
			}
		}
				
		return $this;
	}
998860
public static function get($controllerClass) {
        if (!isset(self::$controllers[$controllerClass])) {
            if (class_exists($controllerClass)) {
                $reflectionClass = new ReflectionClass($controllerClass);
                self::$controllers[$controllerClass] = $reflectionClass->isAbstract()? $controllerClass : (new $controllerClass);
            }
            else {
                self::$controllers[$controllerClass] = null;
            }
        }
        return self::$controllers[$controllerClass];
    }