@param array $classConfig
@param \ReflectionClass $classReflection
@param callable $instanceConstructor

@return object
519034
private function createNewInstance(array $classConfig, \ReflectionClass $classReflection, $instanceConstructor) {
        if ($this->supportsLazyLoading && $this->config->isLazyLoading() && $this->isConfiguredAsLazy($classConfig, $classReflection)) {
            return $this->wrapInstanceWithLazyProxy($classReflection->getName(), $instanceConstructor);
        } else {
            return $instanceConstructor();
        }
    }
277663
private function createMethods(ClassReflection $classReflection, ClassReflection $queryBuilder): array
    {
        $methods = [];
        foreach ($queryBuilder->getNativeReflection()->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
            if ($method->isStatic()) {
                continue;
            }

            $methods[$method->getName()] = $this->methodReflectionFactory->create($classReflection, $method);
        }

        return $methods;
    }
683762
public function generate($instance) : AccessInterceptorInterface
    {
        $class = new ReflectionClass($instance);
        $proxy = $this->proxyFactory->createProxy($instance);

        foreach ($this->collectCacheMethods($class) as $method => $annotations) {
            $this->registerPrefixInterceptor($proxy, $method, $annotations);
            $this->registerSuffixInterceptor($proxy, $method, $annotations);
        }

        return $proxy;
    }
1110868
public function create(ClassReflection $classReflection, \ReflectionMethod $methodReflection, string $methodWrapper = null): MethodReflection
    {
        $phpDocParameterTypes = [];
        $phpDocReturnType = null;
        if ($methodReflection->getDocComment() !== false) {
            $phpDocBlock = PhpDocBlock::resolvePhpDocBlockForMethod(
                Broker::getInstance(),
                $methodReflection->getDocComment(),
                $methodReflection->getDeclaringClass()->getName(),
                $methodReflection->getName(),
                $methodReflection->getFileName()
            );

            $resolvedPhpDoc = $this->fileTypeMapper->getResolvedPhpDoc(
                $phpDocBlock->getFile(),
                $phpDocBlock->getClass(),
                $phpDocBlock->getDocComment()
            );
            $phpDocParameterTypes = array_map(function (ParamTag $tag): Type {
                return $tag->getType();
            }, $resolvedPhpDoc->getParamTags());
            $phpDocReturnType = $resolvedPhpDoc->getReturnTag() !== null ? $resolvedPhpDoc->getReturnTag()->getType() : null;
        }

        if ($methodWrapper) {
            $methodReflection = new $methodWrapper($methodReflection);
        }

        return $this->methodReflectionFactory->create(
            $classReflection,
            $methodReflection,
            $phpDocParameterTypes,
            $phpDocReturnType
        );
    }
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");
		}
	}
406397
private function createWithReflection($className)
    {
        $class = new ReflectionClass($className);
        $prototypeInstance = $class->newInstanceWithoutConstructor();

        /**
         * @var IPrototype $prototype
         */
        $prototype = new $this->prototypeClass(
            $prototypeInstance,
            $class->getInterfaceNames(),
            $this->getClassConstructorInfo($class),
            $this->getClassOptions($class, $prototypeInstance)
        );

        if (!$prototype instanceof IPrototype) {
            throw new RuntimeException(sprintf(
                'Prototype class "%s" should implement IPrototype.',
                $this->prototypeClass
            ));
        }

        return $prototype;
    }
54026
static KryoInstantiator reflect(Class<? extends KryoInstantiator> instClass, Config optConf)
    throws ConfigurationException {
    try {
      try {
        return instClass.getConstructor(Config.class).newInstance(optConf);
      } catch (NoSuchMethodException ex3) {
        return instClass.newInstance();
      }
    }
    catch(InstantiationException x) {
      throw new ConfigurationException(x);
    }
    catch(IllegalAccessException x) {
      throw new ConfigurationException(x);
    }
    catch(InvocationTargetException x) {
      throw new ConfigurationException(x);
    }
  }
300998
private function getReflectionProperty($className, $property)
    {
        if (!isset(self::$properties[$className])) {
            self::$properties[$className] = array();
        }

        if (!isset(self::$properties[$className][$property])) {
            try {
                $rflProperty = new ReflectionProperty($className, $property);
                $rflProperty->setAccessible(true);
            } catch (ReflectionException $e) {
                if (($parentClass = get_parent_class($className)) !== false) {
                    $rflProperty = $this->getReflectionProperty($parentClass, $property);
                } else {
                    throw $e;
                }
            }

            self::$properties[$className][$property] = $rflProperty;
        }

        return self::$properties[$className][$property];
    }
237589
static function createFromReflection($name, \ReflectionClass $reflectionClass, ClassIndexInterface $classIndex) {

    $declaration = Declaration::createFromReflection($reflectionClass);

    $header = new ClassLikeHeader_Native($reflectionClass);

    $extends = ($parentReflectionClass = $reflectionClass->getParentClass())
      ? new ClassExtends_ByName($classIndex, $parentReflectionClass->getName())
      : new ClassExtends_None();

    $ownInterfaceNames = $reflectionClass->getInterfaceNames();
    $allInterfaceNames = $ownInterfaceNames;
    $interfacesAll = new AllInterfaces_FromNames($classIndex, $allInterfaceNames);
    if ($reflectionClass->isInterface()) {
      $interfacesAll = $interfacesAll->withSelfInterfaceName($name, $classIndex);
    }
    $ownInterfaces = new OwnInterfaces_FromNames($classIndex, $ownInterfaceNames);

    $ownBody = new OwnBody_Native($reflectionClass, $classIndex);
    $body = ClassLikeBody_Composite::createFromOwnBody($extends, $interfacesAll, $ownBody);

    return new ClassLikeReflection_Composite($declaration, $header, $extends, $interfacesAll, $ownInterfaces, $body, $classIndex);
  }
847982
protected function getBridgedInterfaceReflection(array $classMethods): ?ReflectionClass
    {
        foreach ($classMethods as $classMethod) {
            if ($classMethod->getName() === '__construct') {
                $constructorComment = $classMethod->getNode()->getComment();

                if (!$constructorComment) {
                    return null;
                }

                $firstParameter = $classMethod->getNode()->getParameters()[0];

                if (!$firstParameter) {
                    return null;
                }

                $pattern = '#@param[\s]+(?<interfaceName>.*)[\s]+' . preg_quote($firstParameter->getName()) . '#is';

                if (preg_match($pattern, $constructorComment, $matches) === 0) {
                    return null;
                }

                //todo: Spryker\Zed\Ratepay\Dependency\Facade\RatepayToSalesAggregatorBridge - need to fix
                return new ReflectionClass($matches['interfaceName']);
            }
        }

        return null;
    }
841024
private function getReflectionProperty($classOrObject, string $attribute): \ReflectionProperty
    {
        $reflectionClass = new \ReflectionClass($classOrObject);
        while (true) {
            try {
                return $reflectionClass->getProperty($attribute);
            } catch (\ReflectionException $e) {
                if (!$reflectionClass = $reflectionClass->getParentClass()) {
                    throw $e;
                }
            }
        }
    }
944266
protected static function getHTTPClientInstance(array $instanceConfig)
    {
        $username = ((isset($instanceConfig['Instance']['user']) === true) ? $instanceConfig['Instance']['user'] : '');
        $password = ((isset($instanceConfig['Instance']['pass']) === true) ? $instanceConfig['Instance']['pass'] : '');

        // Bootstrap the REST client
        $curlClient = new Curl();
        $curlClient->setVerifyPeer(false);
        $restClient = new Browser($curlClient);

        if ($username && $password) {
            $authListener = new BasicAuthListener($username, $password);
            $restClient->addListener($authListener);
        }

        return $restClient;
    }
540281
private function buildReflectionFunction($className, $functionName)
    {
        return (empty($className))
            ? new ReflectionFunction($this->getFullFunctionName($className, $functionName))
            : new ReflectionMethod($className, $functionName);
    }
1109305
private static function getReflectionMethod(string $method, $objectOrClass, $classOverride = null): ReflectionMethod
    {
        $class = $classOverride;
        if ($class === null) {
            if (is_object($objectOrClass)) {
                $class = get_class($objectOrClass);
            } else {
                $class = $objectOrClass;
            }
        }
        return new ReflectionMethod($class, $method);
    }
292643
public function findInstances($instanceType) {
		
		$instancesArray = array();

		$reflectionInstanceType = new \ReflectionClass($instanceType);
		$isInterface = $reflectionInstanceType->isInterface();

		foreach ($this->declaredInstances as $instanceName=>$classDesc) {
			if (!isset($classDesc['class'])) {
				continue;			
			}
			$className = $classDesc['class'];
			
			// Silently ignore any non existing class.
			if (!class_exists($className)) {
				continue;
			}
			
			
			$reflectionClass = new \ReflectionClass($className);
			if ($isInterface) {
				if ($reflectionClass->implementsInterface($instanceType)) {
					$instancesArray[] = $instanceName;
				}
			} else {
				if ($reflectionClass->isSubclassOf($instanceType) || $reflectionClass->getName() == $instanceType) {
					$instancesArray[] = $instanceName;
				}
			}
		}
		return $instancesArray;
	}
546978
private function createCloner(ClassMetadata $classMetadata, ReflectionProperty $reflectionId = null)
    {
        $className = $classMetadata->getName();
        $documentManager = $this->documentManager;

        return function (Proxy $cloned) use ($className, $classMetadata, $documentManager, $reflectionId) {
            if ($cloned->__isInitialized()) {
                return;
            }

            $cloned->__setInitialized(true);
            $cloned->__setInitializer(null);

            if (!$reflectionId) {
                return;
            }

            $original = $documentManager->find($className, $reflectionId->getValue($cloned));

            if (null === $original) {
                throw new UnexpectedValueException(sprintf(
                    'Proxy with ID "%s" could not be loaded',
                    $reflectionId->getValue($cloned)
                ));
            }

            foreach ($classMetadata->getReflectionClass()->getProperties() as $reflectionProperty) {
                $propertyName = $reflectionProperty->getName();

                if ($classMetadata->hasField($propertyName) || $classMetadata->hasAssociation($propertyName)) {
                    $reflectionProperty->setAccessible(true);
                    $reflectionProperty->setValue($cloned, $reflectionProperty->getValue($original));
                }
            }
        };
    }
1270645
function javaClassConstructorProxy() {
    var args = [name];
    for (var i = 0; i < arguments.length; i++) {
      args.push(arguments[i]);
    }
    return java.newInstanceSync.apply(java, args);
  }