/** * @inheritdoc */ protected function getTokenResultReplacement($token) { $result = null; $matches = array(); if (preg_match('/^([a-zA-Z][a-zA-Z0-9]*?)\\/(.*?\\(.*\\))$/', $token, $matches) && sizeof($matches) > 2) { $target = $this->engine->getModule($matches[1]); $call = $matches[2]; } else { $target = $this->engine; $call = $token; } $parsed = PhpSourceUtilities::parseFunctionCall($call); $method = array($target, $parsed['name']); if (is_callable($method)) { $result = call_user_func_array($method, $parsed['arguments']); } return $result; }
/** * @inheritdoc */ public function activateDecorators() { foreach (func_get_args() as $arg) { if (is_array($arg) && ArrayUtilities::isIndexed($arg)) { // An indexed array, recurse with each element of the array as a separate argument. call_user_func_array(array($this, 'activateDecorators'), $arg); } elseif (is_array($arg)) { // An associative array, ensure it has an 'arguments' key. $this->activeDecorators[] = array_merge(array('arguments' => array()), $arg); } elseif (is_string($arg)) { // A string, use the parseFunctionCall() utility method. $this->activeDecorators[] = PhpSourceUtilities::parseFunctionCall($arg); } else { // Unhandled type. throw new \InvalidArgumentException(sprintf('Cannot use [%s] as decorator specification', TypeUtilities::describe($arg))); } } return $this; }