/** * @param type $expr * @return type */ protected function evaluateFuncCall($expr) { if (isset($expr->name->parts)) { if (count($expr->name->parts) != 1) { return $this->error("Unsupported FuncCall expression", $expr); } $functionName = $expr->name->parts[0]; $map = ['help' => [$this, 'fnHelp']]; $isFunctionAllowed = in_array($functionName, $this->allowedFunctions) || in_array($functionName, array_keys($map)); if (method_exists($this->callbackHandler, $functionName . 'Callback')) { $functionName = [$this->callbackHandler, $functionName . 'Callback']; } else { if (!$isFunctionAllowed && function_exists($functionName)) { return $this->error("Unauthorized function '{$functionName}'", $expr); } elseif (!$isFunctionAllowed) { return $this->error("Unknown function '{$functionName}'", $expr); } if (isset($map[$functionName])) { $functionName = $map[$functionName]; } } $args = $this->evaluateArgs($expr); $result = $this->callFunction($functionName, $args); return $this->debug($expr, $result); } elseif ($expr->name instanceof \PhpParser\Node\Expr\Variable) { $variable = $this->registry->get($expr->name->name); if (!isset($variable)) { return $this->error("Unsupported FuncCall expression - Unkown function", $expr); } if (!is_callable($variable)) { return $this->error("Unsupported FuncCall expression - Variable is not a function", $expr); } $args = $this->evaluateArgs($expr); $result = $this->callFunction($variable, $args); return $this->debug($expr, $result); } else { return $this->error("Unsupported FuncCall expression", $expr); } }
public function initRegistry(RateRequest $request = null) { $this->registryHelper->init($request); $this->registryHelper->register('info', $this->registryHelper->create('Info', ['carrierCode' => $this->getCarrierCode()])); }
/** * @param mixed $data * @return mixed */ protected function wrap($data) { return $this->registry->wrap($data); }