return; } /** * Build arguments list by replace all references by values of execution context * * @param array $function Function array. See MibewAPI for details. * @return array Arguments list * @throws MibewAPIException */ public function getArgumentsList ($function) { $arguments = $function['arguments']; $references = $function['arguments']['references']; foreach ($references as $variable => $func_num) { // Check target function in context if (! isset($this->functions_results[$func_num - 1])) { // Wrong function num throw new MibewAPIException( "Wrong reference in '{$function['function']}' function. " . "Function #{$func_num} does not call yet.", MibewAPIException::WRONG_FUNCTION_NUM_IN_REFERENCE ); } // Check reference if (empty($arguments[$variable])) { // Empty argument that should contains reference throw new MibewAPIException( "Wrong reference in '{$function['function']}' function. " . "Empty {$variable} argument.", MibewAPIException::EMPTY_VARIABLE_IN_REFERENCE ); } $reference_to = $arguments[$variable]; // Check target value if (! isset($this->functions_results[$func_num - 1][$reference_to])) { // Undefined target value throw new MibewAPIException( "Wrong reference in '{$function['function']}' function. " . "There is no '{$reference_to}' argument in #{$func_num} " . "function results", MibewAPIException::VARIABLE_IS_UNDEFINED_IN_REFERENCE ); } // Replace reference by target value $arguments[$variable] = $this->functions_results[$func_num - 1][$reference_to]; } return $arguments; } /** * Stores functions results in execution context and add values to request result * * @param array $function Function array. See MibewAPI for details. * @param array $results Associative array of the function results. * @throws MibewAPIException */ public function storeFunctionResults ($function, $results) { // Add value to request results foreach ($function['arguments']['return'] as $name => $alias) { if (! isset($results[$name])) { // Value that defined in 'return' argument is undefined throw new MibewAPIException( "Variable with name '{$name}' is undefined in the " . "results of the '{$function['function']}' function", MibewAPIException::VARIABLE_IS_UNDEFINED_IN_RESULT ); } $this->return[$alias] = $results[$name]; } // Store function results in execution context $this->functions_results[] = $results; } } ?>