Gets an evaluation context for function with the resolved parameters.

@param IResolvedParameterRegistry|null $parameters

@return O\IEvaluationContext
164339
public function getEvaluationContext(IResolvedParameterRegistry $parameters = null)
    {
        $thisObject    = null;
        $variableTable = array_fill_keys($this->parameterScopedVariableMap, null);
        unset($variableTable['this']);

        if ($parameters !== null) {
            foreach ($this->parameterScopedVariableMap as $parameter => $variableName) {
                if ($variableName === 'this') {
                    $thisObject = $parameters[$parameter];
                } else {
                    $variableTable[$variableName] = $parameters[$parameter];
                }
            }
        }

        foreach ($this->unusedParameterDefaultMap as $name => $evaluator) {
            $variableTable[$name] = $evaluator->evaluate();
        }

        return new O\EvaluationContext($this->namespace, $this->scopeType, $thisObject, $variableTable);
    }
504459
public function resolve(Parameter $parameter, ParameterBag $unresolvedParameters, ParameterBag $resolvedParameters): ParameterBag
    {
        return $resolvedParameters->with($parameter);
    }
767130
public function getParameter($parameter)
    {
        return $this->container->hasParameter($parameter) ? $this->container->getParameter($parameter) : null;
    }
422522
protected function getPageNumber(EncodingParametersInterface $parameters)
    {
        $paging = $parameters->getPaginationParameters();
        return isset($paging[self::PARAM_PAGING_NUMBER]) ? $paging[self::PARAM_PAGING_NUMBER] : null;
    }
112732
protected function getDependentAttributes($parameters)
    {
        $dependencies = [];

        foreach ($parameters as $parameter) {
            if (isset($this->requirements[$parameter]) && !in_array($parameter, $this->resolvedParameters)) {
                $dependencies[] = $parameter;
            }
        }

        return $dependencies;
    }
213449
private function resolveParameters(string $id, array $parameters, ContainerInterface $container): array
    {
        $resolved = [];
        foreach ($parameters as $parameter) {
            $resolved[] = $this->getParameterValue($id, $parameter, $container);
        }
        return $resolved;
    }
416427
public function resolveRequestHandler(
        $resource,
        array $parameters = [],
        $version = null,
        $resolveDefaultRequestHandler = true
    )
    {
        try {
            return $this->resolve('requestHandler', $resource, $parameters, $version);
        } catch (ResourceNotDefinedException $e) {
            if ($resolveDefaultRequestHandler) {
                return $this->app->make(DefaultRequestHandler::class, $parameters);
            }
            throw $e;
        }
    }
247499
protected function resolvePrimitive(ReflectionParameter $parameter)
    {
        if ($parameter->isDefaultValueAvailable()) {
            return $parameter->getDefaultValue();
        }

        return $this->unresolvablePrimitive($parameter);
    }
167733
public function getParameterClass(ReflectionParameter $parameter)
    {
        // Use reflection
        $parameterClass = $parameter->getClass();
        if ($parameterClass !== null) {
            return $parameterClass->name;
        }

        $parameterName = $parameter->name;
        // Get the content of the @param annotation
        $method = $parameter->getDeclaringFunction();
        if (preg_match('/@param\s+([^\s]+)\s+\$' . $parameterName . '/', $method->getDocComment(), $matches)) {
            list(, $type) = $matches;
        } else {
            return null;
        }

        // Ignore primitive types
        if (in_array($type, $this->ignoredTypes)) {
            return null;
        }

        // Ignore types containing special characters ([], <> ...)
        if (! preg_match('/^[a-zA-Z0-9\\\\_]+$/', $type)) {
            return null;
        }

        $class = $parameter->getDeclaringClass();

        // If the class name is not fully qualified (i.e. doesn't start with a \)
        if ($type[0] !== '\\') {
            // Try to resolve the FQN using the class context
            $resolvedType = $this->tryResolveFqn($type, $class, $parameter);
         
            if (!$resolvedType && !$this->ignorePhpDocErrors) {
                throw new AnnotationException(sprintf(
                    'The @param annotation for parameter "%s" of %s::%s contains a non existent class "%s". '
                        . 'Did you maybe forget to add a "use" statement for this annotation?',
                    $parameterName,
                    $class->name,
                    $method->name,
                    $type
                ));
            }
            
            $type = $resolvedType;
        }

        if (!$this->classExists($type) && !$this->ignorePhpDocErrors) {
            throw new AnnotationException(sprintf(
                'The @param annotation for parameter "%s" of %s::%s contains a non existent class "%s"',
                $parameterName,
                $class->name,
                $method->name,
                $type
            ));
        }

        // Remove the leading \ (FQN shouldn't contain it)
        $type = ltrim($type, '\\');

        return $type;
    }
988248
private function getParameterNamesForDecoratedCall(array $parameters) : array
    {
        return array_map(
            static function (ReflectionParameter $parameter) {
                $name = '';

                if (method_exists($parameter, 'isVariadic')) {
                    if ($parameter->isVariadic()) {
                        $name .= '...';
                    }
                }

                return $name . '$' . $parameter->name;
            },
            $parameters
        );
    }
942082
public function resolveCallable(?string $name, callable $closure, ?array $parameters = null)
    {
        $definitions = isset($name) && $this->container->isDefined($name)
            ? $this->container->getDefiniition($name) : null;

        $callable = $this->getCallable($closure);
        $parameters = $parameters ?? $this->resolveParameters($callable->getParameters() ?? null, $definitions);

        return $callable->invokeArgs($parameters);
    }
344195
static function resolveCallableWithArgs(callable $callable, $parameters)
    {
        if ($parameters instanceof \Traversable)
            $parameters = \Poirot\Std\cast($parameters)->toArray();


        $reflection       = self::makeReflectFromCallable($callable);
        $matchedArguments = self::resolveArgsForReflection($reflection, $parameters);

        if (!empty($parameters) && empty($matchedArguments))
            // In Case That Fun Has No Any Argument.
            // exp. func() { $args = func_get_args() ..
            $matchedArguments = $parameters;

        $callbackResolved = function() use ($callable, $matchedArguments) {
            return call_user_func_array($callable, $matchedArguments);
        };

        return $callbackResolved;
    }
992605
protected function resolveArgumentValue(\ReflectionParameter $param)
    {
        $paramClass = null;

        try {
            $paramClass = $param->getClass();
        }
        catch (\ReflectionException $e) {
        }

        if (!($paramClass instanceof ReflectionClass) || $param->isDefaultValueAvailable()) {
            return $this->resolveArgumentDefaultValue($param);
        }

        if (!($this->manager instanceof Manager)) {
            throw new RuntimeException("Unable to retrieve descriptor for class '{$paramClass->getName(
                                       )}' " . "because the manager has not been set. Please use Descriptor::setManager to resolve this.");
        }

        return $this->manager->describe($paramClass->getName(), null, null, $paramClass);
    }
356520
private function bind($key, $parameter)
    {
        if (is_null($parameter->getClass())) {
            return $this->arguments[$key] ?? null;
        }

        $class = $parameter->getClass()->name;

        $object = Arr::first($this->arguments, function ($value) use ($class) {
            return is_subclass_of($value, $class) || is_a($value, $class);
        });

        if (is_null($object)) {
            $object = app()->make($class);

            if (method_exists($object, 'resolveRouteBinding') && isset($this->arguments[$key])) {
                $object = $object->resolveRouteBinding($this->arguments[$key]);
            }
        }

        return $object;
    }
292825
public function resolve($factory=false, $parameters=[]) {
        if (!$factory && $this->instance)
            return $this->instance;

        $instance   = null;
        $definition = $this->definition;
        !$factory && $parameters = [];

        if (is_string($definition)) {                       // plain strings are class names without parameters
            if (!is_class($definition)) throw new ClassNotFoundException('Cannot resolve service "'.$this->name.'" (unknown class "'.$definition.'")');
            $instance = new $definition(...$parameters);
        }
        else if (is_object($definition)) {                  // objects may be a \Closure or an already resolved instance
            $instance = $definition instanceof \Closure ? $definition(...$parameters) : $definition;
        }
        else throw new IllegalTypeException('Cannot resolve service "'.$this->name.'" (illegal definition type: '.gettype($definition).')');

        if (!$factory)
            $this->instance = $instance;
        return $instance;
    }
930031
public function findPageByParameters($parameters)
    {
        if (!empty($parameters['id']) && !preg_match('/^ref_/', $parameters['id'])) {
            $page = $this->entityManager->getRepository('VictoireCoreBundle:View')->findOneBy([
                'id' => $parameters['id'],
            ]);

            $this->checkPageValidity($page, $parameters);
        } else {
            if (isset($parameters['id']) && isset($parameters['locale'])) {
                //if locale is missing, we add append locale
                if (preg_match('/^ref_[0-9]*$/', $parameters['id'])) {
                    $parameters['id'] .= '_'.$parameters['locale'];
                }
            }
            $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters);
            if ($viewReference === null && !empty($parameters['viewId'])) {
                $parameters['templateId'] = $parameters['viewId'];
                unset($parameters['viewId']);
                $viewReference = $this->viewReferenceRepository->getOneReferenceByParameters($parameters);
            }

            if ($viewReference instanceof ViewReference) {
                $page = $this->findPageByReference($viewReference);
            } else {
                throw new ViewReferenceNotFoundException($parameters);
            }
            $page->setReference($viewReference, $viewReference->getLocale());
        }

        return $page;
    }
1051904
public function resolve(
        DefinitionInterface $definition, array $parameters = [])
    {
        /** @var CallableDefinition $definition */
        $args = (empty($parameters)) ? $definition->getArgs(): $parameters;
        return call_user_func_array($definition->getCallable(), $args);
    }