public function __construct(ITypeSystem $typeSystem, O\IEvaluationContext $evaluationContext) { parent::__construct($typeSystem); $this->evaluationContext = $evaluationContext; foreach ($evaluationContext->getVariableTable() as $variable => $value) { $this->setExpressionType(O\Expression::variable(O\Expression::value($variable)), $typeSystem->getTypeFromValue($value)); } }
protected function getVariableTable(array $customVariableTable = null) { //Loose equality: order is irrelevant if ($customVariableTable !== null && count(array_diff(array_keys($customVariableTable), $this->requiredVariables)) > 0) { throw new PinqException('Cannot evaluate expression: supplied variable table is invalid, variable names do not match the required variable names'); } $contextVariableTable = $this->context->getVariableTable() ?: []; $customVariableTable = $customVariableTable ?: []; return $customVariableTable + $contextVariableTable; }