mirror of
https://github.com/fenom-template/fenom.git
synced 2023-08-10 21:13:07 +03:00
More test, reformat code to PSR-0
This commit is contained in:
@@ -302,7 +302,7 @@ class Fenom
|
||||
*/
|
||||
public function setCompileDir($dir)
|
||||
{
|
||||
if(!is_writable($dir)) {
|
||||
if (!is_writable($dir)) {
|
||||
throw new LogicException("Cache directory $dir is not writable");
|
||||
}
|
||||
$this->_compile_dir = $dir;
|
||||
@@ -630,7 +630,7 @@ class Fenom
|
||||
public function addProvider($scm, \Fenom\ProviderInterface $provider, $compile_path = null)
|
||||
{
|
||||
$this->_providers[$scm] = $provider;
|
||||
if($compile_path) {
|
||||
if ($compile_path) {
|
||||
$this->_compiles[$scm] = $compile_path;
|
||||
}
|
||||
return $this;
|
||||
@@ -738,7 +738,7 @@ class Fenom
|
||||
public function getTemplate($template, $options = 0)
|
||||
{
|
||||
$options |= $this->_options;
|
||||
if(is_array($template)) {
|
||||
if (is_array($template)) {
|
||||
$key = dechex($options) . "@" . implode(",", $template);
|
||||
} else {
|
||||
$key = dechex($options) . "@" . $template;
|
||||
@@ -805,12 +805,12 @@ class Fenom
|
||||
*/
|
||||
private function _getCacheName($tpl, $options)
|
||||
{
|
||||
if(is_array($tpl)) {
|
||||
if (is_array($tpl)) {
|
||||
$hash = implode(".", $tpl) . ":" . $options;
|
||||
foreach($tpl as &$t) {
|
||||
foreach ($tpl as &$t) {
|
||||
$t = str_replace(":", "_", basename($t));
|
||||
}
|
||||
return implode("~", $tpl).".".sprintf("%x.%x.php", crc32($hash), strlen($hash));
|
||||
return implode("~", $tpl) . "." . sprintf("%x.%x.php", crc32($hash), strlen($hash));
|
||||
} else {
|
||||
$hash = $tpl . ":" . $options;
|
||||
return sprintf("%s.%x.%x.php", str_replace(":", "_", basename($tpl)), crc32($hash), strlen($hash));
|
||||
@@ -829,12 +829,12 @@ class Fenom
|
||||
public function compile($tpl, $store = true, $options = 0)
|
||||
{
|
||||
$options = $this->_options | $options;
|
||||
if(is_string($tpl)) {
|
||||
if (is_string($tpl)) {
|
||||
$template = $this->getRawTemplate()->load($tpl);
|
||||
} else {
|
||||
$template = $this->getRawTemplate()->load($tpl[0], false);
|
||||
unset($tpl[0]);
|
||||
foreach($tpl as $t) {
|
||||
foreach ($tpl as $t) {
|
||||
$template->extend($t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Fenom;
|
||||
|
||||
use Fenom\Error\InvalidUsageException;
|
||||
use Fenom\Error\UnexpectedTokenException;
|
||||
use Fenom\Tokenizer;
|
||||
@@ -36,20 +37,20 @@ class Compiler
|
||||
$cname = $tpl->parsePlainArg($tokens, $name);
|
||||
$p = $tpl->parseParams($tokens);
|
||||
if ($name) {
|
||||
if($tpl->getStorage()->getOptions() & \Fenom::FORCE_INCLUDE) {
|
||||
if ($tpl->getStorage()->getOptions() & \Fenom::FORCE_INCLUDE) {
|
||||
$inc = $tpl->getStorage()->compile($name, false);
|
||||
$tpl->addDepend($inc);
|
||||
$var = $tpl->tmpVar();
|
||||
if($p) {
|
||||
return $var.' = $var; $var = ' . self::toArray($p) . ' + $var; ?>' . $inc->getBody() . '<?php $var = '.$var.'; unset('.$var.');';
|
||||
if ($p) {
|
||||
return $var . ' = $var; $var = ' . self::toArray($p) . ' + $var; ?>' . $inc->getBody() . '<?php $var = ' . $var . '; unset(' . $var . ');';
|
||||
} else {
|
||||
return $var.' = $var; ?>' . $inc->getBody() . '<?php $var = '.$var.'; unset('.$var.');';
|
||||
return $var . ' = $var; ?>' . $inc->getBody() . '<?php $var = ' . $var . '; unset(' . $var . ');';
|
||||
}
|
||||
} elseif(!$tpl->getStorage()->templateExists($name)) {
|
||||
} elseif (!$tpl->getStorage()->templateExists($name)) {
|
||||
throw new \LogicException("Template $name not found");
|
||||
}
|
||||
}
|
||||
if($p) {
|
||||
if ($p) {
|
||||
return '$tpl->getStorage()->getTemplate(' . $cname . ')->display(' . self::toArray($p) . ' + $var);';
|
||||
} else {
|
||||
return '$tpl->getStorage()->getTemplate(' . $cname . ')->display($var);';
|
||||
@@ -339,7 +340,7 @@ class Compiler
|
||||
$scope["last"] = array();
|
||||
$scope["default"] = '';
|
||||
$scope["var"] = $scope->tpl->tmpVar();
|
||||
$scope["expr"] = $scope["var"].' = strval('.$expr.')';
|
||||
$scope["expr"] = $scope["var"] . ' = strval(' . $expr . ')';
|
||||
// lazy init
|
||||
return '';
|
||||
}
|
||||
@@ -414,15 +415,15 @@ class Compiler
|
||||
{
|
||||
self::_caseResort($scope);
|
||||
$expr = $scope["var"];
|
||||
$code = $scope["expr"].";\n";
|
||||
$code = $scope["expr"] . ";\n";
|
||||
$default = $scope["default"];
|
||||
foreach ($scope["case"] as $case => $content) {
|
||||
if(is_numeric($case)) {
|
||||
if (is_numeric($case)) {
|
||||
$case = "'$case'";
|
||||
}
|
||||
$code .= "if($expr == $case) {\n?>$content<?php\n} else";
|
||||
}
|
||||
$code .= " {\n?>$default<?php\n}\nunset(".$scope["var"].")";
|
||||
$code .= " {\n?>$default<?php\n}\nunset(" . $scope["var"] . ")";
|
||||
return $code;
|
||||
}
|
||||
|
||||
@@ -478,12 +479,12 @@ class Compiler
|
||||
throw new InvalidUsageException("Tags {extends} can not be nested");
|
||||
}
|
||||
$cname = $tpl->parsePlainArg($tokens, $name);
|
||||
if($name) {
|
||||
if ($name) {
|
||||
$tpl->extends = $name;
|
||||
} else {
|
||||
$tpl->dynamic_extends = $cname;
|
||||
}
|
||||
if(!$tpl->extend_body) {
|
||||
if (!$tpl->extend_body) {
|
||||
$tpl->addPostCompile(__CLASS__ . "::extendBody");
|
||||
$tpl->extend_body = true;
|
||||
}
|
||||
@@ -496,18 +497,18 @@ class Compiler
|
||||
*/
|
||||
public static function extendBody($tpl, &$body)
|
||||
{
|
||||
if($tpl->dynamic_extends) {
|
||||
if(!$tpl->ext_stack) {
|
||||
if ($tpl->dynamic_extends) {
|
||||
if (!$tpl->ext_stack) {
|
||||
$tpl->ext_stack[] = $tpl->getName();
|
||||
}
|
||||
foreach($tpl->ext_stack as &$t) {
|
||||
foreach ($tpl->ext_stack as &$t) {
|
||||
$stack[] = "'$t'";
|
||||
}
|
||||
$stack[] = $tpl->dynamic_extends;
|
||||
$body = '<?php $tpl->getStorage()->display(array('.implode(', ', $stack).'), $var); ?>';
|
||||
$body = '<?php $tpl->getStorage()->display(array(' . implode(', ', $stack) . '), $var); ?>';
|
||||
} else {
|
||||
$child = $tpl;
|
||||
while($child && $child->extends) {
|
||||
while ($child && $child->extends) {
|
||||
$parent = $tpl->extend($child->extends);
|
||||
$child = $parent->extends ? $parent : false;
|
||||
}
|
||||
@@ -549,7 +550,7 @@ class Compiler
|
||||
$scope->tpl->_compatible = true;
|
||||
}
|
||||
$scope["cname"] = $scope->tpl->parsePlainArg($tokens, $name);
|
||||
if(!$name) {
|
||||
if (!$name) {
|
||||
throw new \RuntimeException("Only static names for blocks allowed");
|
||||
}
|
||||
$scope["name"] = $name;
|
||||
@@ -565,27 +566,27 @@ class Compiler
|
||||
$tpl = $scope->tpl;
|
||||
$name = $scope["name"];
|
||||
|
||||
if(isset($tpl->blocks[$name])) { // block defined
|
||||
$block = &$tpl->blocks[$name];
|
||||
if($block['use_parent']) {
|
||||
if (isset($tpl->blocks[$name])) { // block defined
|
||||
$block = & $tpl->blocks[$name];
|
||||
if ($block['use_parent']) {
|
||||
$parent = $scope->getContent();
|
||||
|
||||
$block['block'] = str_replace($block['use_parent']." ?>", "?>".$parent, $block['block']);
|
||||
$block['block'] = str_replace($block['use_parent'] . " ?>", "?>" . $parent, $block['block']);
|
||||
}
|
||||
if(!$block["import"]) { // not from {use} - redefine block
|
||||
if (!$block["import"]) { // not from {use} - redefine block
|
||||
$scope->replaceContent($block["block"]);
|
||||
return;
|
||||
} elseif($block["import"] != $tpl->getName()) { // tag {use} was in another template
|
||||
} elseif ($block["import"] != $tpl->getName()) { // tag {use} was in another template
|
||||
$tpl->blocks[$scope["name"]]["import"] = false;
|
||||
$scope->replaceContent($block["block"]);
|
||||
}
|
||||
}
|
||||
|
||||
$tpl->blocks[$scope["name"]] = array(
|
||||
"from" => $tpl->getName(),
|
||||
"import" => false,
|
||||
"use_parent" => $scope["use_parent"],
|
||||
"block" => $scope->getContent()
|
||||
"from" => $tpl->getName(),
|
||||
"import" => false,
|
||||
"use_parent" => $scope["use_parent"],
|
||||
"block" => $scope->getContent()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -599,8 +600,8 @@ class Compiler
|
||||
public static function tagParent($tokens, Scope $scope)
|
||||
{
|
||||
$block_scope = $scope->tpl->getParentScope('block');
|
||||
if(!$block_scope['use_parent']) {
|
||||
$block_scope['use_parent'] = "/* %%parent#".mt_rand(0, 1e6)."%% */";
|
||||
if (!$block_scope['use_parent']) {
|
||||
$block_scope['use_parent'] = "/* %%parent#" . mt_rand(0, 1e6) . "%% */";
|
||||
}
|
||||
return $block_scope['use_parent'];
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
namespace Fenom\Error;
|
||||
|
||||
use Fenom\Tokenizer;
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Fenom;
|
||||
|
||||
use Fenom;
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
namespace Fenom;
|
||||
|
||||
use Fenom;
|
||||
use Fenom\Error\UnexpectedTokenException;
|
||||
use Fenom\Error\CompileException;
|
||||
@@ -154,9 +155,9 @@ class Template extends Render
|
||||
*/
|
||||
public function __construct(Fenom $fenom, $options)
|
||||
{
|
||||
$this->_fenom = $fenom;
|
||||
$this->_options = $options;
|
||||
$this->_filters = $this->_fenom->getFilters();
|
||||
$this->_fenom = $fenom;
|
||||
$this->_options = $options;
|
||||
$this->_filters = $this->_fenom->getFilters();
|
||||
$this->_tag_filters = $this->_fenom->getTagFilters();
|
||||
}
|
||||
|
||||
@@ -175,8 +176,8 @@ class Template extends Render
|
||||
*/
|
||||
public function getParentScope($tag)
|
||||
{
|
||||
for($i = count($this->_stack) - 1; $i>=0; $i--) {
|
||||
if($this->_stack[$i]->name == $tag) {
|
||||
for ($i = count($this->_stack) - 1; $i >= 0; $i--) {
|
||||
if ($this->_stack[$i]->name == $tag) {
|
||||
return $this->_stack[$i];
|
||||
}
|
||||
}
|
||||
@@ -279,8 +280,8 @@ class Template extends Render
|
||||
$this->_appendText($tag);
|
||||
}
|
||||
} else {
|
||||
if($this->_tag_filters) {
|
||||
foreach($this->_tag_filters as $filter) {
|
||||
if ($this->_tag_filters) {
|
||||
foreach ($this->_tag_filters as $filter) {
|
||||
$_tag = call_user_func($filter, $_tag, $this);
|
||||
}
|
||||
}
|
||||
@@ -510,10 +511,10 @@ class Template extends Render
|
||||
public function importBlocks($tpl)
|
||||
{
|
||||
$donor = $this->_fenom->compile($tpl, false);
|
||||
foreach($donor->blocks as $name => $block) {
|
||||
if(!isset($this->blocks[ $name ])) {
|
||||
foreach ($donor->blocks as $name => $block) {
|
||||
if (!isset($this->blocks[$name])) {
|
||||
$block['import'] = $this->getName();
|
||||
$this->blocks[ $name ] = $block;
|
||||
$this->blocks[$name] = $block;
|
||||
}
|
||||
}
|
||||
$this->addDepend($donor);
|
||||
@@ -526,13 +527,13 @@ class Template extends Render
|
||||
*/
|
||||
public function extend($tpl)
|
||||
{
|
||||
if(!$this->_body) {
|
||||
if (!$this->_body) {
|
||||
$this->compile();
|
||||
}
|
||||
$parent = $this->_fenom->getRawTemplate()->load($tpl, false);
|
||||
$parent->blocks = &$this->blocks;
|
||||
$parent->blocks = & $this->blocks;
|
||||
$parent->extended = $this->getName();
|
||||
if(!$this->ext_stack) {
|
||||
if (!$this->ext_stack) {
|
||||
$this->ext_stack[] = $this->getName();
|
||||
}
|
||||
$this->ext_stack[] = $parent->getName();
|
||||
@@ -540,7 +541,7 @@ class Template extends Render
|
||||
$parent->ext_stack = $this->ext_stack;
|
||||
$parent->compile();
|
||||
$this->_body = $parent->_body;
|
||||
$this->_src = $parent->_src;
|
||||
$this->_src = $parent->_src;
|
||||
$this->addDepend($parent);
|
||||
return $parent;
|
||||
}
|
||||
@@ -634,11 +635,11 @@ class Template extends Render
|
||||
$name = $action . "." . $name;
|
||||
}
|
||||
return $this->parseMacroCall($tokens, $name);
|
||||
} elseif($tokens->is(T_DOUBLE_COLON, T_NS_SEPARATOR)) { // static method call
|
||||
} elseif ($tokens->is(T_DOUBLE_COLON, T_NS_SEPARATOR)) { // static method call
|
||||
$tokens->back();
|
||||
$p = $tokens->p;
|
||||
$static = $this->parseStatic($tokens);
|
||||
if($tokens->is("(")) {
|
||||
if ($tokens->is("(")) {
|
||||
return $this->out($this->parseExpr($tokens->seek($p)));
|
||||
} else {
|
||||
return $this->out(Compiler::smartFuncParser($static, $tokens, $this));
|
||||
@@ -678,7 +679,7 @@ class Template extends Render
|
||||
if ($tags = $this->_fenom->getTagOwners($action)) { // unknown template tag
|
||||
throw new TokenizeException("Unexpected tag '$action' (this tag can be used with '" . implode("', '", $tags) . "')");
|
||||
} else {
|
||||
throw new TokenizeException("Unexpected tag $action");
|
||||
throw new TokenizeException("Unexpected tag '$action'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -699,8 +700,8 @@ class Template extends Render
|
||||
// parse term
|
||||
$term = $this->parseTerm($tokens, $var); // term of the expression
|
||||
if ($term !== false) {
|
||||
if($this->_options & Fenom::FORCE_VERIFY) {
|
||||
$term = '(isset('.$term.') ? '.$term.' : null)';
|
||||
if ($this->_options & Fenom::FORCE_VERIFY) {
|
||||
$term = '(isset(' . $term . ') ? ' . $term . ' : null)';
|
||||
$var = false;
|
||||
}
|
||||
if ($tokens->is('|')) {
|
||||
@@ -806,13 +807,13 @@ class Template extends Render
|
||||
throw new \LogicException("Forbidden to call methods");
|
||||
}
|
||||
do { // parse call-chunks: $var->func()->func()->prop->func()->...
|
||||
if($tokens->is('(')) {
|
||||
if ($tokens->is('(')) {
|
||||
$code .= $this->parseArgs($tokens);
|
||||
}
|
||||
if($tokens->is(T_OBJECT_OPERATOR) && $tokens->isNext(T_STRING)) {
|
||||
$code .= '->'.$tokens->next()->getAndNext();
|
||||
if ($tokens->is(T_OBJECT_OPERATOR) && $tokens->isNext(T_STRING)) {
|
||||
$code .= '->' . $tokens->next()->getAndNext();
|
||||
}
|
||||
} while($tokens->is('(', T_OBJECT_OPERATOR));
|
||||
} while ($tokens->is('(', T_OBJECT_OPERATOR));
|
||||
} elseif ($tokens->is(Tokenizer::MACRO_INCDEC)) {
|
||||
$code .= $tokens->getAndNext();
|
||||
} else {
|
||||
@@ -836,7 +837,7 @@ class Template extends Render
|
||||
throw new \Exception("Function " . $tokens->getAndNext() . " not found");
|
||||
}
|
||||
$code = $unary . $func . $this->parseArgs($tokens->next());
|
||||
} elseif($tokens->isNext(T_NS_SEPARATOR, T_DOUBLE_COLON)) {
|
||||
} elseif ($tokens->isNext(T_NS_SEPARATOR, T_DOUBLE_COLON)) {
|
||||
$method = $this->parseStatic($tokens);
|
||||
$args = $this->parseArgs($tokens);
|
||||
$code = $unary . $method . $args;
|
||||
@@ -874,8 +875,8 @@ class Template extends Render
|
||||
*/
|
||||
public function parseVariable(Tokenizer $tokens, $var = null)
|
||||
{
|
||||
if(!$var) {
|
||||
$var = '$var["' . substr( $tokens->get(T_VARIABLE), 1) . '"]';
|
||||
if (!$var) {
|
||||
$var = '$var["' . substr($tokens->get(T_VARIABLE), 1) . '"]';
|
||||
$tokens->next();
|
||||
}
|
||||
while ($t = $tokens->key()) {
|
||||
@@ -952,14 +953,14 @@ class Template extends Render
|
||||
$tokens->need('.')->next();
|
||||
$var = $this->parseName($tokens);
|
||||
if (!defined($var)) {
|
||||
$var = 'constant(' . var_export($var, true) . ')';
|
||||
$var = '@constant(' . var_export($var, true) . ')';
|
||||
}
|
||||
break;
|
||||
case 'version':
|
||||
$var = '\Fenom::VERSION';
|
||||
break;
|
||||
default:
|
||||
throw new UnexpectedTokenException($tokens);
|
||||
throw new UnexpectedTokenException($tokens->back());
|
||||
}
|
||||
|
||||
return $var;
|
||||
@@ -981,13 +982,13 @@ class Template extends Render
|
||||
if ($tokens->is(":")) {
|
||||
$tokens->next();
|
||||
if ($empty) {
|
||||
if($is_var) {
|
||||
if ($is_var) {
|
||||
return '(empty(' . $var . ') ? (' . $this->parseExpr($tokens) . ') : ' . $var . ')';
|
||||
} else {
|
||||
return '(' . $var . ' ?: (' . $this->parseExpr($tokens) . ')';
|
||||
return '(' . $var . ' ?: (' . $this->parseExpr($tokens) . '))';
|
||||
}
|
||||
} else {
|
||||
if($is_var) {
|
||||
if ($is_var) {
|
||||
return '(isset(' . $var . ') ? ' . $var . ' : (' . $this->parseExpr($tokens) . '))';
|
||||
} else {
|
||||
return '((' . $var . ' !== null) ? ' . $var . ' : (' . $this->parseExpr($tokens) . '))';
|
||||
@@ -995,13 +996,13 @@ class Template extends Render
|
||||
}
|
||||
} elseif ($tokens->is(Tokenizer::MACRO_BINARY, Tokenizer::MACRO_BOOLEAN, Tokenizer::MACRO_MATH) || !$tokens->valid()) {
|
||||
if ($empty) {
|
||||
if($is_var) {
|
||||
if ($is_var) {
|
||||
return '!empty(' . $var . ')';
|
||||
} else {
|
||||
return '(' . $var . ')';
|
||||
}
|
||||
} else {
|
||||
if($is_var) {
|
||||
if ($is_var) {
|
||||
return 'isset(' . $var . ')';
|
||||
} else {
|
||||
return '(' . $var . ' !== null)';
|
||||
@@ -1012,13 +1013,13 @@ class Template extends Render
|
||||
$tokens->need(':')->skip();
|
||||
$expr2 = $this->parseExpr($tokens);
|
||||
if ($empty) {
|
||||
if($is_var) {
|
||||
if ($is_var) {
|
||||
return '(empty(' . $var . ') ? ' . $expr2 . ' : ' . $expr1 . ')';
|
||||
} else {
|
||||
return '(' . $var . ' ? ' . $expr1 . ' : ' . $expr2 . ')';
|
||||
}
|
||||
} else {
|
||||
if($is_var) {
|
||||
if ($is_var) {
|
||||
return '(isset(' . $var . ') ? ' . $expr1 . ' : ' . $expr2 . ')';
|
||||
} else {
|
||||
return '((' . $var . ' !== null) ? ' . $expr1 . ' : ' . $expr2 . ')';
|
||||
@@ -1169,7 +1170,7 @@ class Template extends Render
|
||||
break;
|
||||
case '$':
|
||||
$tokens->next()->need('.')->next()->need(T_CONST)->next();
|
||||
return 'constant('.$this->parseName($tokens).')';
|
||||
return @constant($this->parseName($tokens));
|
||||
default:
|
||||
throw new UnexpectedTokenException($tokens);
|
||||
}
|
||||
@@ -1254,7 +1255,7 @@ class Template extends Render
|
||||
{
|
||||
while ($tokens->is("|")) {
|
||||
$modifier = $tokens->getNext(Tokenizer::MACRO_STRING);
|
||||
if($tokens->isNext(T_DOUBLE_COLON, T_NS_SEPARATOR)) {
|
||||
if ($tokens->isNext(T_DOUBLE_COLON, T_NS_SEPARATOR)) {
|
||||
$mods = $this->parseStatic($tokens);
|
||||
} else {
|
||||
$mods = $this->_fenom->getModifier($modifier, $this);
|
||||
@@ -1369,11 +1370,11 @@ class Template extends Render
|
||||
}
|
||||
if ($recursive) {
|
||||
$recursive['recursive'] = true;
|
||||
return '$tpl->getMacro("' . $name . '")->__invoke('.Compiler::toArray($args).', $tpl);';
|
||||
return '$tpl->getMacro("' . $name . '")->__invoke(' . Compiler::toArray($args) . ', $tpl);';
|
||||
} else {
|
||||
$vars = $this->tmpVar();
|
||||
return $vars . ' = $var; $var = ' . Compiler::toArray($args) . ';' . PHP_EOL . '?>' .
|
||||
$macro["body"] . '<?php' . PHP_EOL . '$var = '.$vars.'; unset(' . $vars . ');';
|
||||
return $vars . ' = $var; $var = ' . Compiler::toArray($args) . ';' . PHP_EOL . '?>' .
|
||||
$macro["body"] . '<?php' . PHP_EOL . '$var = ' . $vars . '; unset(' . $vars . ');';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1385,7 +1386,7 @@ class Template extends Render
|
||||
*/
|
||||
public function parseStatic(Tokenizer $tokens)
|
||||
{
|
||||
if($this->_options & Fenom::DENY_STATICS) {
|
||||
if ($this->_options & Fenom::DENY_STATICS) {
|
||||
throw new \LogicException("Static methods are disabled");
|
||||
}
|
||||
$tokens->skipIf(T_NS_SEPARATOR);
|
||||
@@ -1399,7 +1400,7 @@ class Template extends Render
|
||||
}
|
||||
$tokens->need(T_DOUBLE_COLON)->next()->need(T_STRING);
|
||||
$static = $name . "::" . $tokens->getAndNext();
|
||||
if(!is_callable($static)) {
|
||||
if (!is_callable($static)) {
|
||||
throw new \RuntimeException("Method $static doesn't exist");
|
||||
}
|
||||
return $static;
|
||||
|
||||
@@ -594,6 +594,8 @@ class Tokenizer
|
||||
public function end()
|
||||
{
|
||||
$this->p = $this->_max;
|
||||
unset($this->prev, $this->curr, $this->next);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user