public function addMacro($name, $begin, $end = NULL, $attr = NULL, $flags = NULL) { if (!$begin && !$end && !$attr) { throw new \InvalidArgumentException("At least one argument must be specified for macro '{$name}'."); } foreach ([$begin, $end, $attr] as $arg) { if ($arg && !is_string($arg)) { Latte\Helpers::checkCallback($arg); } } $this->macros[$name] = [$begin, $end, $attr]; $this->compiler->addMacro($name, $this, $flags); return $this; }
/** * {use class MacroSet} */ public function macroUse(MacroNode $node, PhpWriter $writer) { if ($node->modifiers) { trigger_error("Modifiers are not allowed in {{$node->name}}", E_USER_WARNING); } call_user_func(Latte\Helpers::checkCallback(array($node->tokenizer->fetchWord(), 'install')), $this->getCompiler())->initialize(); }
/** * {use class MacroSet} */ public function macroUse(MacroNode $node, PhpWriter $writer) { if ($node->modifiers) { throw new CompileException("Modifiers are not allowed in {{$node->name}}"); } call_user_func(Latte\Helpers::checkCallback([$node->tokenizer->fetchWord(), 'install']), $this->getCompiler())->initialize(); }
/** * {use class MacroSet} */ public function macroUse(MacroNode $node, PhpWriter $writer) { call_user_func(Latte\Helpers::checkCallback(array($node->tokenizer->fetchWord(), 'install')), $this->getCompiler())->initialize(); }
/** * {use class MacroSet} */ public function macroUse(MacroNode $node, PhpWriter $writer) { trigger_error('Macro {use} is deprecated.', E_USER_DEPRECATED); if ($node->modifiers) { throw new CompileException('Modifiers are not allowed in ' . $node->getNotation()); } call_user_func(Helpers::checkCallback([$node->tokenizer->fetchWord(), 'install']), $this->getCompiler())->initialize(); }
private function prepareFilter($name) { if (!isset($this->_static[$name][1])) { $callback = Helpers::checkCallback($this->_static[$name][0]); if (is_string($callback) && strpos($callback, '::')) { $callback = explode('::', $callback); } elseif (is_object($callback)) { $callback = [$callback, '__invoke']; } $ref = is_array($callback) ? new \ReflectionMethod($callback[0], $callback[1]) : new \ReflectionFunction($callback); $this->_static[$name][1] = ($tmp = $ref->getParameters()) && $tmp[0]->getClass() && $tmp[0]->getClass()->getName() === 'Latte\\Runtime\\FilterInfo'; } return $this->_static[$name]; }