Pinq\Queries\Functions\FunctionEvaluationContextFactory::getEvaluationContext PHP Метод

getEvaluationContext() публичный Метод

Gets an evaluation context for function with the resolved parameters.
public getEvaluationContext ( Pinq\Queries\IResolvedParameterRegistry $parameters = null ) : Pinq\Expressions\IEvaluationContext
$parameters Pinq\Queries\IResolvedParameterRegistry
Результат Pinq\Expressions\IEvaluationContext
    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);
    }

Usage Example

Пример #1
0
 public function doEvaluate(IResolvedParameterRegistry $parameters)
 {
     if ($this->contextFactory === null) {
         return $this->evaluator->evaluate();
     }
     $resolvedContext = $this->contextFactory->getEvaluationContext($parameters);
     return $this->evaluator->evaluateWithNewThis($resolvedContext->getThis(), $resolvedContext->getVariableTable());
 }