diff --git a/TODO.txt b/TODO.txt index 9cde6dc58..aabbf6543 100644 --- a/TODO.txt +++ b/TODO.txt @@ -29,5 +29,4 @@ ## Unrelated / other - review (and avoid) use of 'clone' keyword -- compiler->has_code seems silly. Why not have proper return values? - what is 'user literal support', why are unit tests skipped? diff --git a/changelog/918.md b/changelog/918.md new file mode 100644 index 000000000..853fdd12e --- /dev/null +++ b/changelog/918.md @@ -0,0 +1 @@ +- Internal compiler classes always return a string (the internal has_code flag has been removed for simplicity) [#918](https://github.com/smarty-php/smarty/pull/918) diff --git a/src/Compile/Base.php b/src/Compile/Base.php index adee289ab..2d5c0c0ef 100644 --- a/src/Compile/Base.php +++ b/src/Compile/Base.php @@ -226,8 +226,8 @@ protected function convertScope($scope): int { * @param Template $compiler compiler object * @param array $parameter array with compilation parameter * - * @return bool|string compiled code or true if no code has been compiled + * @return string compiled code as a string * @throws \Smarty\CompilerException */ - abstract public function compile($args, Template $compiler, $parameter = array(), $tag = null, $function = null); + abstract public function compile($args, Template $compiler, $parameter = array(), $tag = null, $function = null): string; } diff --git a/src/Compile/BlockCompiler.php b/src/Compile/BlockCompiler.php index 089e618d7..e7a8f310e 100644 --- a/src/Compile/BlockCompiler.php +++ b/src/Compile/BlockCompiler.php @@ -50,7 +50,8 @@ class BlockCompiler extends Base { * @throws CompilerException * @throws Exception */ - public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null): string + { if (!isset($tag[5]) || substr($tag, -5) !== 'close') { $output = $this->compileOpeningTag($compiler, $args, $tag, $function); @@ -77,7 +78,6 @@ public function compileChild(\Smarty\Compiler\Template $compiler) { ); } $compiler->_cache['blockParams'][$compiler->_cache['blockNesting']]['callsChild'] = true; - $compiler->has_code = true; $compiler->suppressNocacheProcessing = true; $output = "getParser()->lex->taglineno ); } - $compiler->has_code = true; $compiler->suppressNocacheProcessing = true; $output = "getAttributes($compiler, $args); unset($_attr['nocache']); diff --git a/src/Compile/FunctionCallCompiler.php b/src/Compile/FunctionCallCompiler.php index 8934c8d7c..107dd98bb 100644 --- a/src/Compile/FunctionCallCompiler.php +++ b/src/Compile/FunctionCallCompiler.php @@ -49,7 +49,8 @@ class FunctionCallCompiler extends Base { * @throws \Smarty\CompilerException * @throws \Smarty\Exception */ - public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null): string + { // check and get attributes $_attr = $this->getAttributes($compiler, $args); diff --git a/src/Compile/ModifierCompiler.php b/src/Compile/ModifierCompiler.php index 765e83768..4e6232244 100644 --- a/src/Compile/ModifierCompiler.php +++ b/src/Compile/ModifierCompiler.php @@ -33,9 +33,8 @@ class ModifierCompiler extends Base { * @throws \Smarty\CompilerException * @throws \Smarty\Exception */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { - - $compiler->has_code = true; + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $output = $parameter['value']; diff --git a/src/Compile/ObjectMethodCallCompiler.php b/src/Compile/ObjectMethodCallCompiler.php index f3ce69605..70855cfc8 100644 --- a/src/Compile/ObjectMethodCallCompiler.php +++ b/src/Compile/ObjectMethodCallCompiler.php @@ -39,7 +39,8 @@ class ObjectMethodCallCompiler extends Base { * @throws \Smarty\CompilerException * @throws \Smarty\Exception */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { // check and get attributes $_attr = $this->getAttributes($compiler, $args); unset($_attr['nocache']); diff --git a/src/Compile/PrintExpressionCompiler.php b/src/Compile/PrintExpressionCompiler.php index 486512d4f..3302254f9 100644 --- a/src/Compile/PrintExpressionCompiler.php +++ b/src/Compile/PrintExpressionCompiler.php @@ -47,9 +47,8 @@ class PrintExpressionCompiler extends Base { * @return string * @throws \Smarty\Exception */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { - - $compiler->has_code = true; + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { // check and get attributes $_attr = $this->getAttributes($compiler, $args); diff --git a/src/Compile/SpecialVariableCompiler.php b/src/Compile/SpecialVariableCompiler.php index 08f9aa69f..2b6cf4330 100644 --- a/src/Compile/SpecialVariableCompiler.php +++ b/src/Compile/SpecialVariableCompiler.php @@ -37,9 +37,8 @@ class SpecialVariableCompiler extends Base { * @return string compiled code * @throws CompilerException */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { - - $compiler->has_code = true; + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $_index = preg_split("/\]\[/", substr($parameter, 1, strlen($parameter) - 2)); $variable = smarty_strtolower_ascii($compiler->getId($_index[0])); @@ -129,5 +128,7 @@ public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = } return $compiled_ref; } + + return ''; } } diff --git a/src/Compile/Tag/Append.php b/src/Compile/Tag/Append.php index 86eda99e9..171f69600 100644 --- a/src/Compile/Tag/Append.php +++ b/src/Compile/Tag/Append.php @@ -35,8 +35,8 @@ class Append extends Assign * @return string compiled code * @throws \Smarty\CompilerException */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null) - { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null): string + { // check and get attributes $_attr = $this->getAttributes($compiler, $args); diff --git a/src/Compile/Tag/Assign.php b/src/Compile/Tag/Assign.php index f53bdf333..8433a97e1 100644 --- a/src/Compile/Tag/Assign.php +++ b/src/Compile/Tag/Assign.php @@ -55,8 +55,8 @@ class Assign extends Base * @return string compiled code * @throws \Smarty\CompilerException */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null) - { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null): string + { $_nocache = false; // check and get attributes diff --git a/src/Compile/Tag/BCPluginWrapper.php b/src/Compile/Tag/BCPluginWrapper.php index 0224250d0..abd89f78f 100644 --- a/src/Compile/Tag/BCPluginWrapper.php +++ b/src/Compile/Tag/BCPluginWrapper.php @@ -24,7 +24,8 @@ public function __construct($callback, bool $cacheable = true) { /** * @inheritDoc */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { return call_user_func($this->callback, $this->getAttributes($compiler, $args), $compiler->getSmarty()); } } \ No newline at end of file diff --git a/src/Compile/Tag/Block.php b/src/Compile/Tag/Block.php index ce6df4f77..d8b301006 100644 --- a/src/Compile/Tag/Block.php +++ b/src/Compile/Tag/Block.php @@ -58,7 +58,7 @@ class Block extends Inheritance { * @param \Smarty\Compiler\Template $compiler compiler object * @param array $parameter array with compilation parameter */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null) + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null): string { if (!isset($compiler->_cache['blockNesting'])) { $compiler->_cache['blockNesting'] = 0; @@ -87,5 +87,6 @@ public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = $compiler->getParser()->current_buffer = new Template(); $compiler->getTemplate()->getCompiled()->setNocacheCode(false); $compiler->suppressNocacheProcessing = true; + return ''; } } diff --git a/src/Compile/Tag/BlockClose.php b/src/Compile/Tag/BlockClose.php index 0c0520016..586c7c050 100644 --- a/src/Compile/Tag/BlockClose.php +++ b/src/Compile/Tag/BlockClose.php @@ -18,7 +18,7 @@ class BlockClose extends Inheritance { * * @return bool true */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null) + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null): string { [$_attr, $_nocache, $_buffer, $_has_nocache_code, $_className] = $this->closeTag($compiler, ['block']); @@ -103,7 +103,6 @@ public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = if ($compiler->_cache['blockNesting'] === 0) { unset($compiler->_cache['blockNesting']); } - $compiler->has_code = true; $compiler->suppressNocacheProcessing = true; return $output; } diff --git a/src/Compile/Tag/BreakTag.php b/src/Compile/Tag/BreakTag.php index 0ec03df2f..b8b554f3b 100644 --- a/src/Compile/Tag/BreakTag.php +++ b/src/Compile/Tag/BreakTag.php @@ -52,7 +52,7 @@ class BreakTag extends Base { * @return string compiled code * @throws \Smarty\CompilerException */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null) + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null): string { [$levels, $foreachLevels] = $this->checkLevels($args, $compiler); $output = "getAttributes($compiler, $args); // save possible attributes diff --git a/src/Compile/Tag/Capture.php b/src/Compile/Tag/Capture.php index fc8804a0a..7b7362f9e 100644 --- a/src/Compile/Tag/Capture.php +++ b/src/Compile/Tag/Capture.php @@ -53,7 +53,8 @@ public static function compileSpecialVariable( * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { // check and get attributes $_attr = $this->getAttributes($compiler, $args); $buffer = $_attr['name'] ?? "'default'"; @@ -66,7 +67,6 @@ public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = $compiler->openTag('nocache'); } - $_output = "getSmarty()->getRuntime('Capture')->open(\$_smarty_tpl, $buffer, $assign, $append);?>"; - return $_output; + return "getSmarty()->getRuntime('Capture')->open(\$_smarty_tpl, $buffer, $assign, $append);?>"; } } \ No newline at end of file diff --git a/src/Compile/Tag/CaptureClose.php b/src/Compile/Tag/CaptureClose.php index 0d553a2b9..c0d779692 100644 --- a/src/Compile/Tag/CaptureClose.php +++ b/src/Compile/Tag/CaptureClose.php @@ -29,7 +29,8 @@ class CaptureClose extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { if (array_pop($compiler->_cache['capture_stack'])) { // pop the virtual {nocache} tag from the stack. diff --git a/src/Compile/Tag/ConfigLoad.php b/src/Compile/Tag/ConfigLoad.php index 6425749ec..d9e67ec92 100644 --- a/src/Compile/Tag/ConfigLoad.php +++ b/src/Compile/Tag/ConfigLoad.php @@ -62,7 +62,8 @@ class ConfigLoad extends Base { * @return string compiled code * @throws \Smarty\CompilerException */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { // check and get attributes $_attr = $this->getAttributes($compiler, $args); if ($_attr['nocache'] === true) { diff --git a/src/Compile/Tag/Debug.php b/src/Compile/Tag/Debug.php index bd8998921..4542bd3cd 100644 --- a/src/Compile/Tag/Debug.php +++ b/src/Compile/Tag/Debug.php @@ -29,7 +29,8 @@ class Debug extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { // check and get attributes, may trigger errors $this->getAttributes($compiler, $args); diff --git a/src/Compile/Tag/ElseIfTag.php b/src/Compile/Tag/ElseIfTag.php index 60b888a86..8e59c3413 100644 --- a/src/Compile/Tag/ElseIfTag.php +++ b/src/Compile/Tag/ElseIfTag.php @@ -22,7 +22,8 @@ class ElseIfTag extends Base { * @return string compiled code * @throws \Smarty\CompilerException */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { [$nesting, $nocache_pushed] = $this->closeTag($compiler, ['if', 'elseif']); diff --git a/src/Compile/Tag/ElseTag.php b/src/Compile/Tag/ElseTag.php index 68a9a0230..a7025da72 100644 --- a/src/Compile/Tag/ElseTag.php +++ b/src/Compile/Tag/ElseTag.php @@ -20,7 +20,8 @@ class ElseTag extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { [$nesting, $compiler->tag_nocache] = $this->closeTag($compiler, ['if', 'elseif']); $this->openTag($compiler, 'else', [$nesting, $compiler->tag_nocache]); return ''; diff --git a/src/Compile/Tag/EvalTag.php b/src/Compile/Tag/EvalTag.php index c6535570e..8396fd097 100644 --- a/src/Compile/Tag/EvalTag.php +++ b/src/Compile/Tag/EvalTag.php @@ -52,7 +52,8 @@ class EvalTag extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { // check and get attributes $_attr = $this->getAttributes($compiler, $args); if (isset($_attr['assign'])) { diff --git a/src/Compile/Tag/ExtendsTag.php b/src/Compile/Tag/ExtendsTag.php index 2e9e0aed5..dcdbbc976 100644 --- a/src/Compile/Tag/ExtendsTag.php +++ b/src/Compile/Tag/ExtendsTag.php @@ -52,7 +52,8 @@ class ExtendsTag extends Inheritance { * @throws \Smarty\CompilerException * @throws \Smarty\Exception */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { // check and get attributes $_attr = $this->getAttributes($compiler, $args); if ($_attr['nocache'] === true) { @@ -86,7 +87,6 @@ public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = } else { $this->compileEndChild($compiler, $_attr['file']); } - $compiler->has_code = false; return ''; } diff --git a/src/Compile/Tag/ForClose.php b/src/Compile/Tag/ForClose.php index bde1a0751..189bcfd93 100644 --- a/src/Compile/Tag/ForClose.php +++ b/src/Compile/Tag/ForClose.php @@ -29,7 +29,8 @@ class ForClose extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $compiler->loopNesting--; [$openTag, $nocache_pushed] = $this->closeTag($compiler, ['for', 'forelse']); diff --git a/src/Compile/Tag/ForElse.php b/src/Compile/Tag/ForElse.php index a754a0d50..d939a72ab 100644 --- a/src/Compile/Tag/ForElse.php +++ b/src/Compile/Tag/ForElse.php @@ -21,7 +21,8 @@ class ForElse extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { [$tagName, $nocache_pushed] = $this->closeTag($compiler, ['for']); $this->openTag($compiler, 'forelse', ['forelse', $nocache_pushed]); return ""; diff --git a/src/Compile/Tag/ForTag.php b/src/Compile/Tag/ForTag.php index 8066d83e7..fdf71b681 100644 --- a/src/Compile/Tag/ForTag.php +++ b/src/Compile/Tag/ForTag.php @@ -28,7 +28,8 @@ class ForTag extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $compiler->loopNesting++; if ($parameter === 0) { $this->required_attributes = ['start', 'to']; diff --git a/src/Compile/Tag/ForeachClose.php b/src/Compile/Tag/ForeachClose.php index 805991493..e657c1d84 100644 --- a/src/Compile/Tag/ForeachClose.php +++ b/src/Compile/Tag/ForeachClose.php @@ -29,7 +29,8 @@ class ForeachClose extends Base { * @return string compiled code * @throws \Smarty\CompilerException */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $compiler->loopNesting--; [$openTag, $nocache_pushed, $localVariablePrefix, $item, $restore] = $this->closeTag($compiler, ['foreach', 'foreachelse']); diff --git a/src/Compile/Tag/ForeachElse.php b/src/Compile/Tag/ForeachElse.php index 3397bb4f0..d48898473 100644 --- a/src/Compile/Tag/ForeachElse.php +++ b/src/Compile/Tag/ForeachElse.php @@ -20,7 +20,8 @@ class ForeachElse extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { [$openTag, $nocache_pushed, $localVariablePrefix, $item, $restore] = $this->closeTag($compiler, ['foreach']); $this->openTag($compiler, 'foreachelse', ['foreachelse', $nocache_pushed, $localVariablePrefix, $item, false]); diff --git a/src/Compile/Tag/ForeachTag.php b/src/Compile/Tag/ForeachTag.php index c77a5464f..9f765af58 100644 --- a/src/Compile/Tag/ForeachTag.php +++ b/src/Compile/Tag/ForeachTag.php @@ -79,7 +79,8 @@ class ForeachTag extends ForeachSection { * @throws \Smarty\CompilerException * @throws \Smarty\Exception */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $compiler->loopNesting++; // init $this->isNamed = false; diff --git a/src/Compile/Tag/FunctionClose.php b/src/Compile/Tag/FunctionClose.php index 119db13ce..aff6dc658 100644 --- a/src/Compile/Tag/FunctionClose.php +++ b/src/Compile/Tag/FunctionClose.php @@ -33,9 +33,10 @@ class FunctionClose extends Base { * @param array $args array with attributes from parser * @param object|\Smarty\Compiler\Template $compiler compiler object * - * @return bool true + * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $this->compiler = $compiler; $saved_data = $this->closeTag($compiler, ['function']); $_attr = $saved_data[0]; @@ -140,7 +141,7 @@ public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = // restore old status $compiler->getTemplate()->getCompiled()->setNocacheCode($saved_data[2]); $compiler->getTemplate()->caching = $saved_data[3]; - return true; + return ''; } /** diff --git a/src/Compile/Tag/FunctionTag.php b/src/Compile/Tag/FunctionTag.php index aa41abdba..c291c3dee 100644 --- a/src/Compile/Tag/FunctionTag.php +++ b/src/Compile/Tag/FunctionTag.php @@ -42,10 +42,11 @@ class FunctionTag extends Base { * @param array $args array with attributes from parser * @param \Smarty\Compiler\Template $compiler compiler object * - * @return bool true + * @return string compiled code * @throws \Smarty\CompilerException */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { // check and get attributes $_attr = $this->getAttributes($compiler, $args); if ($_attr['nocache'] === true) { @@ -67,6 +68,6 @@ public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = // Init temporary context $compiler->getParser()->current_buffer = new \Smarty\ParseTree\Template(); $compiler->getTemplate()->getCompiled()->setNocacheCode(false); - return true; + return ''; } } \ No newline at end of file diff --git a/src/Compile/Tag/IfClose.php b/src/Compile/Tag/IfClose.php index 12f7e4427..df15094f1 100644 --- a/src/Compile/Tag/IfClose.php +++ b/src/Compile/Tag/IfClose.php @@ -28,7 +28,8 @@ class IfClose extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { [$nesting, $nocache_pushed] = $this->closeTag($compiler, ['if', 'else', 'elseif']); diff --git a/src/Compile/Tag/IfTag.php b/src/Compile/Tag/IfTag.php index 84bf477c0..7790859b1 100644 --- a/src/Compile/Tag/IfTag.php +++ b/src/Compile/Tag/IfTag.php @@ -22,7 +22,8 @@ class IfTag extends Base { * @return string compiled code * @throws \Smarty\CompilerException */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { if ($compiler->tag_nocache) { // push a {nocache} tag onto the stack to prevent caching of this block diff --git a/src/Compile/Tag/IncludeTag.php b/src/Compile/Tag/IncludeTag.php index f7619cc71..8e775811e 100644 --- a/src/Compile/Tag/IncludeTag.php +++ b/src/Compile/Tag/IncludeTag.php @@ -67,7 +67,8 @@ class IncludeTag extends Base { * @throws \Smarty\CompilerException * @throws \Smarty\Exception */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $uid = $t_hash = null; // check and get attributes $_attr = $this->getAttributes($compiler, $args); diff --git a/src/Compile/Tag/Ldelim.php b/src/Compile/Tag/Ldelim.php index 5a48d3ada..a265fa70c 100644 --- a/src/Compile/Tag/Ldelim.php +++ b/src/Compile/Tag/Ldelim.php @@ -30,7 +30,8 @@ class Ldelim extends Base { * @return string compiled code * @throws \Smarty\CompilerException */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $_attr = $this->getAttributes($compiler, $args); if ($_attr['nocache'] === true) { $compiler->trigger_template_error('nocache option not allowed', null, true); diff --git a/src/Compile/Tag/Nocache.php b/src/Compile/Tag/Nocache.php index 5e2cbd314..dd30f8937 100644 --- a/src/Compile/Tag/Nocache.php +++ b/src/Compile/Tag/Nocache.php @@ -26,12 +26,11 @@ class Nocache extends Base { * @param array $args array with attributes from parser * @param \Smarty\Compiler\Template $compiler compiler object * - * @return bool + * @return string */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $this->openTag($compiler, 'nocache'); - // this tag does not return compiled code - $compiler->has_code = false; - return true; + return ''; } } \ No newline at end of file diff --git a/src/Compile/Tag/NocacheClose.php b/src/Compile/Tag/NocacheClose.php index cacbf701c..75edd9982 100644 --- a/src/Compile/Tag/NocacheClose.php +++ b/src/Compile/Tag/NocacheClose.php @@ -27,12 +27,11 @@ class NocacheClose extends Base { * @param array $args array with attributes from parser * @param \Smarty\Compiler\Template $compiler compiler object * - * @return bool + * @return string */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $this->closeTag($compiler, ['nocache']); - // this tag does not return compiled code - $compiler->has_code = false; - return true; + return ''; } } diff --git a/src/Compile/Tag/Rdelim.php b/src/Compile/Tag/Rdelim.php index 87bd18897..60e7a23d1 100644 --- a/src/Compile/Tag/Rdelim.php +++ b/src/Compile/Tag/Rdelim.php @@ -28,7 +28,8 @@ class Rdelim extends Ldelim { * @return string compiled code * @throws \Smarty\CompilerException */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { parent::compile($args, $compiler); return $compiler->getTemplate()->getRightDelimiter(); } diff --git a/src/Compile/Tag/Section.php b/src/Compile/Tag/Section.php index de9202c53..f82ac4211 100644 --- a/src/Compile/Tag/Section.php +++ b/src/Compile/Tag/Section.php @@ -82,7 +82,8 @@ class Section extends ForeachSection { * @throws \Smarty\CompilerException * @throws \Smarty\Exception */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $compiler->loopNesting++; // check and get attributes $_attr = $this->getAttributes($compiler, $args); diff --git a/src/Compile/Tag/SectionClose.php b/src/Compile/Tag/SectionClose.php index dee65bab3..efab60975 100644 --- a/src/Compile/Tag/SectionClose.php +++ b/src/Compile/Tag/SectionClose.php @@ -25,7 +25,8 @@ class SectionClose extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $compiler->loopNesting--; [$openTag, $nocache_pushed] = $this->closeTag($compiler, ['section', 'sectionelse']); diff --git a/src/Compile/Tag/SectionElse.php b/src/Compile/Tag/SectionElse.php index be861e981..b9ea56366 100644 --- a/src/Compile/Tag/SectionElse.php +++ b/src/Compile/Tag/SectionElse.php @@ -20,7 +20,8 @@ class SectionElse extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { [$openTag, $nocache_pushed] = $this->closeTag($compiler, ['section']); $this->openTag($compiler, 'sectionelse', ['sectionelse', $nocache_pushed]); return ""; diff --git a/src/Compile/Tag/Setfilter.php b/src/Compile/Tag/Setfilter.php index 037a701e6..9da2f969c 100644 --- a/src/Compile/Tag/Setfilter.php +++ b/src/Compile/Tag/Setfilter.php @@ -21,7 +21,8 @@ class Setfilter extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $compiler->variable_filter_stack[] = $compiler->getSmarty()->getDefaultModifiers(); // The modifier_list is passed as an array of array's. The inner arrays have the modifier at index 0, @@ -34,8 +35,6 @@ public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = $compiler->getSmarty()->setDefaultModifiers($newList); - // this tag does not return compiled code - $compiler->has_code = false; - return true; + return ''; } } \ No newline at end of file diff --git a/src/Compile/Tag/SetfilterClose.php b/src/Compile/Tag/SetfilterClose.php index 273bb6fb0..2814f641d 100644 --- a/src/Compile/Tag/SetfilterClose.php +++ b/src/Compile/Tag/SetfilterClose.php @@ -29,7 +29,8 @@ class SetfilterClose extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $this->getAttributes($compiler, $args); // reset variable filter to previous state @@ -37,8 +38,6 @@ public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = count($compiler->variable_filter_stack) ? array_pop($compiler->variable_filter_stack) : [] ); - // this tag does not return compiled code - $compiler->has_code = false; - return true; + return ''; } } diff --git a/src/Compile/Tag/WhileClose.php b/src/Compile/Tag/WhileClose.php index 6c45cd720..5adb3a49b 100644 --- a/src/Compile/Tag/WhileClose.php +++ b/src/Compile/Tag/WhileClose.php @@ -28,7 +28,8 @@ class WhileClose extends Base { * * @return string compiled code */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $compiler->loopNesting--; $nocache_pushed = $this->closeTag($compiler, ['while']); diff --git a/src/Compile/Tag/WhileTag.php b/src/Compile/Tag/WhileTag.php index 3df7d197f..3300b5075 100644 --- a/src/Compile/Tag/WhileTag.php +++ b/src/Compile/Tag/WhileTag.php @@ -22,7 +22,8 @@ class WhileTag extends Base { * @return string compiled code * @throws \Smarty\CompilerException */ - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $compiler->loopNesting++; if ($compiler->tag_nocache) { diff --git a/src/Compiler/Template.php b/src/Compiler/Template.php index db3c580d3..23984151c 100644 --- a/src/Compiler/Template.php +++ b/src/Compiler/Template.php @@ -184,13 +184,6 @@ class Template extends BaseCompiler { */ public $prefixCodeStack = []; - /** - * Tag has compiled code - * - * @var bool - */ - public $has_code = false; - /** * A variable string was compiled * @@ -1074,12 +1067,10 @@ public function cStyleComment($string) { } public function compileChildBlock() { - $this->has_code = true; return $this->blockCompiler->compileChild($this); } public function compileParentBlock() { - $this->has_code = true; return $this->blockCompiler->compileParent($this); } @@ -1096,8 +1087,6 @@ public function compileParentBlock() { */ private function compileTag2($tag, $args, $parameter) { // $args contains the attributes parsed and compiled by the lexer/parser - // assume that tag does compile into code, but creates no HTML output - $this->has_code = true; $this->handleNocacheFlag($args); @@ -1106,12 +1095,10 @@ private function compileTag2($tag, $args, $parameter) { if (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this)) { $this->tag_nocache = $this->tag_nocache | !$tagCompiler->isCacheable(); $_output = $tagCompiler->compile($args, $this, $parameter); - if ($_output !== false) { - if (!empty($parameter['modifierlist'])) { - throw new CompilerException('No modifiers allowed on ' . $tag); - } - return $this->has_code && $_output !== true ? $_output : null; + if (!empty($parameter['modifierlist'])) { + throw new CompilerException('No modifiers allowed on ' . $tag); } + return $_output; } } @@ -1124,8 +1111,7 @@ private function compileTag2($tag, $args, $parameter) { $args['_attr']['name'] = "'{$tag}'"; $tagCompiler = $this->getTagCompiler('call'); - $_output = $tagCompiler === null ? false : $tagCompiler->compile($args, $this, $parameter); - return $this->has_code ? $_output : null; + return $tagCompiler === null ? false : $tagCompiler->compile($args, $this, $parameter); } // remaining tastes: (object-)function, (object-function-)block, custom-compiler diff --git a/src/Parser/TemplateParser.php b/src/Parser/TemplateParser.php index e55c1f034..58971b9c8 100644 --- a/src/Parser/TemplateParser.php +++ b/src/Parser/TemplateParser.php @@ -2134,13 +2134,11 @@ public function yy_r8(){ } // line 292 "src/Parser/TemplateParser.y" public function yy_r9(){ - if ($this->compiler->has_code) { - $this->current_buffer->append_subtree($this, $this->mergePrefixCode($this->yystack[$this->yyidx + 0]->minor)); - } + $this->current_buffer->append_subtree($this, $this->mergePrefixCode($this->yystack[$this->yyidx + 0]->minor)); $this->compiler->has_variable_string = false; $this->block_nesting_level = $this->compiler->getTagStackCount(); } -// line 304 "src/Parser/TemplateParser.y" +// line 302 "src/Parser/TemplateParser.y" public function yy_r11(){ $var = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' $'); $attributes = []; @@ -2150,7 +2148,7 @@ public function yy_r11(){ } $this->_retvalue = $this->compiler->compilePrintExpression($this->compiler->compileVariable('\''.$var.'\''), $attributes); } -// line 315 "src/Parser/TemplateParser.y" +// line 313 "src/Parser/TemplateParser.y" public function yy_r12(){ $tag = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength())); if ($tag == 'strip') { @@ -2171,7 +2169,7 @@ public function yy_r12(){ } } } -// line 336 "src/Parser/TemplateParser.y" +// line 334 "src/Parser/TemplateParser.y" public function yy_r13(){ $j = strrpos($this->yystack[$this->yyidx + 0]->minor,'.'); if ($this->yystack[$this->yyidx + 0]->minor[$j+1] == 'c') { @@ -2182,35 +2180,35 @@ public function yy_r13(){ $this->_retvalue = $this->compiler->compileParentBlock(); } } -// line 347 "src/Parser/TemplateParser.y" +// line 345 "src/Parser/TemplateParser.y" public function yy_r14(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; } -// line 351 "src/Parser/TemplateParser.y" +// line 349 "src/Parser/TemplateParser.y" public function yy_r15(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; } -// line 355 "src/Parser/TemplateParser.y" +// line 353 "src/Parser/TemplateParser.y" public function yy_r16(){ $this->_retvalue = $this->compiler->compilePrintExpression($this->yystack[$this->yyidx + 0]->minor[0], $this->yystack[$this->yyidx + 0]->minor[1]); } -// line 364 "src/Parser/TemplateParser.y" +// line 362 "src/Parser/TemplateParser.y" public function yy_r17(){ $this->_retvalue = $this->compiler->compileTag('assign',array_merge(array(array('value'=>$this->yystack[$this->yyidx + 0]->minor[0]),array('var'=>'\''.substr($this->yystack[$this->yyidx + -1]->minor,1).'\'')),$this->yystack[$this->yyidx + 0]->minor[1])); } -// line 368 "src/Parser/TemplateParser.y" +// line 366 "src/Parser/TemplateParser.y" public function yy_r18(){ $this->_retvalue = $this->compiler->compileTag('assign',array_merge(array(array('value'=>$this->yystack[$this->yyidx + 0]->minor[0]),array('var'=>$this->yystack[$this->yyidx + -1]->minor['var'])),$this->yystack[$this->yyidx + 0]->minor[1]),array('smarty_internal_index'=>$this->yystack[$this->yyidx + -1]->minor['smarty_internal_index'])); } -// line 372 "src/Parser/TemplateParser.y" +// line 370 "src/Parser/TemplateParser.y" public function yy_r19(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; } -// line 376 "src/Parser/TemplateParser.y" +// line 374 "src/Parser/TemplateParser.y" public function yy_r20(){ $this->_retvalue = array($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor); } -// line 391 "src/Parser/TemplateParser.y" +// line 389 "src/Parser/TemplateParser.y" public function yy_r24(){ if (defined($this->yystack[$this->yyidx + -1]->minor)) { if ($this->security) { @@ -2221,7 +2219,7 @@ public function yy_r24(){ $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor); } } -// line 401 "src/Parser/TemplateParser.y" +// line 399 "src/Parser/TemplateParser.y" public function yy_r25(){ if (defined($this->yystack[$this->yyidx + 0]->minor)) { if ($this->security) { @@ -2232,7 +2230,7 @@ public function yy_r25(){ $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + 0]->minor,array()); } } -// line 414 "src/Parser/TemplateParser.y" +// line 412 "src/Parser/TemplateParser.y" public function yy_r26(){ if (defined($this->yystack[$this->yyidx + -2]->minor)) { if ($this->security) { @@ -2243,66 +2241,66 @@ public function yy_r26(){ $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -2]->minor,$this->yystack[$this->yyidx + 0]->minor, array('modifierlist'=>$this->yystack[$this->yyidx + -1]->minor)); } } -// line 426 "src/Parser/TemplateParser.y" +// line 424 "src/Parser/TemplateParser.y" public function yy_r27(){ $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -3]->minor,$this->yystack[$this->yyidx + 0]->minor,array('object_method'=>$this->yystack[$this->yyidx + -1]->minor)); } -// line 431 "src/Parser/TemplateParser.y" +// line 429 "src/Parser/TemplateParser.y" public function yy_r28(){ $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -4]->minor,$this->yystack[$this->yyidx + 0]->minor,array('modifierlist'=>$this->yystack[$this->yyidx + -1]->minor, 'object_method'=>$this->yystack[$this->yyidx + -2]->minor)); } -// line 436 "src/Parser/TemplateParser.y" +// line 434 "src/Parser/TemplateParser.y" public function yy_r29(){ $tag = trim(substr($this->yystack[$this->yyidx + -1]->minor,$this->compiler->getLdelLength())); $this->_retvalue = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,array(),array('if condition'=>$this->yystack[$this->yyidx + 0]->minor)); } -// line 441 "src/Parser/TemplateParser.y" +// line 439 "src/Parser/TemplateParser.y" public function yy_r30(){ $tag = trim(substr($this->yystack[$this->yyidx + -2]->minor,$this->compiler->getLdelLength())); $this->_retvalue = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,$this->yystack[$this->yyidx + 0]->minor,array('if condition'=>$this->yystack[$this->yyidx + -1]->minor)); } -// line 446 "src/Parser/TemplateParser.y" +// line 444 "src/Parser/TemplateParser.y" public function yy_r31(){ $tag = trim(substr($this->yystack[$this->yyidx + -1]->minor,$this->compiler->getLdelLength())); $this->_retvalue = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,array(),array('if condition'=>$this->yystack[$this->yyidx + 0]->minor)); } -// line 457 "src/Parser/TemplateParser.y" +// line 455 "src/Parser/TemplateParser.y" public function yy_r33(){ $this->_retvalue = $this->compiler->compileTag('for',array_merge($this->yystack[$this->yyidx + 0]->minor,array(array('start'=>$this->yystack[$this->yyidx + -6]->minor),array('ifexp'=>$this->yystack[$this->yyidx + -4]->minor),array('var'=>$this->yystack[$this->yyidx + -2]->minor),array('step'=>$this->yystack[$this->yyidx + -1]->minor))),1); } -// line 461 "src/Parser/TemplateParser.y" +// line 459 "src/Parser/TemplateParser.y" public function yy_r34(){ $this->_retvalue = '='.$this->yystack[$this->yyidx + 0]->minor; } -// line 469 "src/Parser/TemplateParser.y" +// line 467 "src/Parser/TemplateParser.y" public function yy_r36(){ $this->_retvalue = $this->compiler->compileTag('for',array_merge($this->yystack[$this->yyidx + 0]->minor,array(array('start'=>$this->yystack[$this->yyidx + -3]->minor),array('to'=>$this->yystack[$this->yyidx + -1]->minor))),0); } -// line 473 "src/Parser/TemplateParser.y" +// line 471 "src/Parser/TemplateParser.y" public function yy_r37(){ $this->_retvalue = $this->compiler->compileTag('for',array_merge($this->yystack[$this->yyidx + 0]->minor,array(array('start'=>$this->yystack[$this->yyidx + -5]->minor),array('to'=>$this->yystack[$this->yyidx + -3]->minor),array('step'=>$this->yystack[$this->yyidx + -1]->minor))),0); } -// line 478 "src/Parser/TemplateParser.y" +// line 476 "src/Parser/TemplateParser.y" public function yy_r38(){ $this->_retvalue = $this->compiler->compileTag('foreach',array_merge($this->yystack[$this->yyidx + 0]->minor,array(array('from'=>$this->yystack[$this->yyidx + -3]->minor),array('item'=>$this->yystack[$this->yyidx + -1]->minor)))); } -// line 482 "src/Parser/TemplateParser.y" +// line 480 "src/Parser/TemplateParser.y" public function yy_r39(){ $this->_retvalue = $this->compiler->compileTag('foreach',array_merge($this->yystack[$this->yyidx + 0]->minor,array(array('from'=>$this->yystack[$this->yyidx + -5]->minor),array('item'=>$this->yystack[$this->yyidx + -1]->minor),array('key'=>$this->yystack[$this->yyidx + -3]->minor)))); } -// line 485 "src/Parser/TemplateParser.y" +// line 483 "src/Parser/TemplateParser.y" public function yy_r40(){ $this->_retvalue = $this->compiler->compileTag('foreach',$this->yystack[$this->yyidx + 0]->minor); } -// line 490 "src/Parser/TemplateParser.y" +// line 488 "src/Parser/TemplateParser.y" public function yy_r41(){ $this->_retvalue = $this->compiler->compileTag('setfilter',array(),array('modifier_list'=>array(array_merge(array($this->yystack[$this->yyidx + -1]->minor),$this->yystack[$this->yyidx + 0]->minor)))); } -// line 494 "src/Parser/TemplateParser.y" +// line 492 "src/Parser/TemplateParser.y" public function yy_r42(){ $this->_retvalue = $this->compiler->compileTag('setfilter',array(),array('modifier_list'=>array_merge(array(array_merge(array($this->yystack[$this->yyidx + -2]->minor),$this->yystack[$this->yyidx + -1]->minor)),$this->yystack[$this->yyidx + 0]->minor))); } -// line 500 "src/Parser/TemplateParser.y" +// line 498 "src/Parser/TemplateParser.y" public function yy_r43(){ $tag = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' /'); if ($tag === 'strip') { @@ -2312,36 +2310,36 @@ public function yy_r43(){ $this->_retvalue = $this->compiler->compileTag($tag.'close',array()); } } -// line 509 "src/Parser/TemplateParser.y" +// line 507 "src/Parser/TemplateParser.y" public function yy_r44(){ $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + 0]->minor.'close',array()); } -// line 513 "src/Parser/TemplateParser.y" +// line 511 "src/Parser/TemplateParser.y" public function yy_r45(){ $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -1]->minor.'close',array(),array('modifier_list'=>$this->yystack[$this->yyidx + 0]->minor)); } -// line 518 "src/Parser/TemplateParser.y" +// line 516 "src/Parser/TemplateParser.y" public function yy_r46(){ $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -2]->minor.'close',array(),array('object_method'=>$this->yystack[$this->yyidx + 0]->minor)); } -// line 522 "src/Parser/TemplateParser.y" +// line 520 "src/Parser/TemplateParser.y" public function yy_r47(){ $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -3]->minor.'close',array(),array('object_method'=>$this->yystack[$this->yyidx + -1]->minor, 'modifier_list'=>$this->yystack[$this->yyidx + 0]->minor)); } -// line 530 "src/Parser/TemplateParser.y" +// line 528 "src/Parser/TemplateParser.y" public function yy_r48(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; $this->_retvalue[] = $this->yystack[$this->yyidx + 0]->minor; } -// line 536 "src/Parser/TemplateParser.y" +// line 534 "src/Parser/TemplateParser.y" public function yy_r49(){ $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor); } -// line 541 "src/Parser/TemplateParser.y" +// line 539 "src/Parser/TemplateParser.y" public function yy_r50(){ $this->_retvalue = array(); } -// line 546 "src/Parser/TemplateParser.y" +// line 544 "src/Parser/TemplateParser.y" public function yy_r51(){ if (defined($this->yystack[$this->yyidx + 0]->minor)) { if ($this->security) { @@ -2352,108 +2350,108 @@ public function yy_r51(){ $this->_retvalue = array($this->yystack[$this->yyidx + -2]->minor=>'\''.$this->yystack[$this->yyidx + 0]->minor.'\''); } } -// line 557 "src/Parser/TemplateParser.y" +// line 555 "src/Parser/TemplateParser.y" public function yy_r52(){ $this->_retvalue = array(trim($this->yystack[$this->yyidx + -1]->minor," =\n\r\t")=>$this->yystack[$this->yyidx + 0]->minor); } -// line 565 "src/Parser/TemplateParser.y" +// line 563 "src/Parser/TemplateParser.y" public function yy_r54(){ $this->_retvalue = '\''.$this->yystack[$this->yyidx + 0]->minor.'\''; } -// line 577 "src/Parser/TemplateParser.y" +// line 575 "src/Parser/TemplateParser.y" public function yy_r57(){ $this->_retvalue = array($this->yystack[$this->yyidx + -2]->minor=>$this->yystack[$this->yyidx + 0]->minor); } -// line 590 "src/Parser/TemplateParser.y" +// line 588 "src/Parser/TemplateParser.y" public function yy_r59(){ $this->yystack[$this->yyidx + -2]->minor[]=$this->yystack[$this->yyidx + 0]->minor; $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor; } -// line 595 "src/Parser/TemplateParser.y" +// line 593 "src/Parser/TemplateParser.y" public function yy_r60(){ $this->_retvalue = array('var' => '\''.substr($this->yystack[$this->yyidx + -2]->minor,1).'\'', 'value'=>$this->yystack[$this->yyidx + 0]->minor); } -// line 602 "src/Parser/TemplateParser.y" +// line 600 "src/Parser/TemplateParser.y" public function yy_r62(){ $this->_retvalue = array('var' => $this->yystack[$this->yyidx + -2]->minor, 'value'=>$this->yystack[$this->yyidx + 0]->minor); } -// line 606 "src/Parser/TemplateParser.y" +// line 604 "src/Parser/TemplateParser.y" public function yy_r63(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; } -// line 631 "src/Parser/TemplateParser.y" +// line 629 "src/Parser/TemplateParser.y" public function yy_r67(){ $this->_retvalue = '$_smarty_tpl->getVariable(\''. substr($this->yystack[$this->yyidx + 0]->minor,1) .'\')->preIncDec(\'' . $this->yystack[$this->yyidx + -1]->minor . '\')'; } -// line 636 "src/Parser/TemplateParser.y" +// line 634 "src/Parser/TemplateParser.y" public function yy_r68(){ $this->_retvalue = '$_smarty_tpl->getVariable(\''. substr($this->yystack[$this->yyidx + -1]->minor,1) .'\')->postIncDec(\'' . $this->yystack[$this->yyidx + 0]->minor . '\')'; } -// line 641 "src/Parser/TemplateParser.y" +// line 639 "src/Parser/TemplateParser.y" public function yy_r69(){ $this->_retvalue = '$_smarty_tpl->getStreamVariable(\''.substr($this->yystack[$this->yyidx + -2]->minor,1).'://' . $this->yystack[$this->yyidx + 0]->minor . '\')'; } -// line 646 "src/Parser/TemplateParser.y" +// line 644 "src/Parser/TemplateParser.y" public function yy_r70(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor . trim($this->yystack[$this->yyidx + -1]->minor) . $this->yystack[$this->yyidx + 0]->minor; } -// line 656 "src/Parser/TemplateParser.y" +// line 654 "src/Parser/TemplateParser.y" public function yy_r72(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor['pre']. $this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + -1]->minor['op'].$this->yystack[$this->yyidx + 0]->minor .')'; } -// line 660 "src/Parser/TemplateParser.y" +// line 658 "src/Parser/TemplateParser.y" public function yy_r73(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } -// line 664 "src/Parser/TemplateParser.y" +// line 662 "src/Parser/TemplateParser.y" public function yy_r74(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor . $this->yystack[$this->yyidx + -1]->minor . ')'; } -// line 668 "src/Parser/TemplateParser.y" +// line 666 "src/Parser/TemplateParser.y" public function yy_r75(){ $this->_retvalue = 'in_array('.$this->yystack[$this->yyidx + -2]->minor.','.$this->yystack[$this->yyidx + 0]->minor.')'; } -// line 672 "src/Parser/TemplateParser.y" +// line 670 "src/Parser/TemplateParser.y" public function yy_r76(){ $this->_retvalue = 'in_array('.$this->yystack[$this->yyidx + -2]->minor.',(array)'.$this->yystack[$this->yyidx + 0]->minor.')'; } -// line 677 "src/Parser/TemplateParser.y" +// line 675 "src/Parser/TemplateParser.y" public function yy_r77(){ $this->_retvalue = $this->yystack[$this->yyidx + -3]->minor.' ?? '.$this->yystack[$this->yyidx + 0]->minor; } -// line 684 "src/Parser/TemplateParser.y" +// line 682 "src/Parser/TemplateParser.y" public function yy_r78(){ $this->_retvalue = $this->yystack[$this->yyidx + -4]->minor.' ? '. $this->compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + -2]->minor,1).'\'') . ' : '.$this->yystack[$this->yyidx + 0]->minor; } -// line 688 "src/Parser/TemplateParser.y" +// line 686 "src/Parser/TemplateParser.y" public function yy_r79(){ $this->_retvalue = $this->yystack[$this->yyidx + -4]->minor.' ? '.$this->yystack[$this->yyidx + -2]->minor.' : '.$this->yystack[$this->yyidx + 0]->minor; } -// line 697 "src/Parser/TemplateParser.y" +// line 695 "src/Parser/TemplateParser.y" public function yy_r81(){ $this->_retvalue = $this->yystack[$this->yyidx + -3]->minor.' ?: '.$this->yystack[$this->yyidx + 0]->minor; } -// line 707 "src/Parser/TemplateParser.y" +// line 705 "src/Parser/TemplateParser.y" public function yy_r83(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } -// line 712 "src/Parser/TemplateParser.y" +// line 710 "src/Parser/TemplateParser.y" public function yy_r84(){ $this->_retvalue = '!'.$this->yystack[$this->yyidx + 0]->minor; } -// line 733 "src/Parser/TemplateParser.y" +// line 731 "src/Parser/TemplateParser.y" public function yy_r89(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'.'.$this->yystack[$this->yyidx + 0]->minor; } -// line 737 "src/Parser/TemplateParser.y" +// line 735 "src/Parser/TemplateParser.y" public function yy_r90(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.'.'; } -// line 741 "src/Parser/TemplateParser.y" +// line 739 "src/Parser/TemplateParser.y" public function yy_r91(){ $this->_retvalue = '.'.$this->yystack[$this->yyidx + 0]->minor; } -// line 746 "src/Parser/TemplateParser.y" +// line 744 "src/Parser/TemplateParser.y" public function yy_r92(){ if (defined($this->yystack[$this->yyidx + 0]->minor)) { if ($this->security) { @@ -2464,15 +2462,15 @@ public function yy_r92(){ $this->_retvalue = '\''.$this->yystack[$this->yyidx + 0]->minor.'\''; } } -// line 763 "src/Parser/TemplateParser.y" +// line 761 "src/Parser/TemplateParser.y" public function yy_r94(){ $this->_retvalue = '('. $this->yystack[$this->yyidx + -1]->minor .')'; } -// line 767 "src/Parser/TemplateParser.y" +// line 765 "src/Parser/TemplateParser.y" public function yy_r95(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } -// line 785 "src/Parser/TemplateParser.y" +// line 783 "src/Parser/TemplateParser.y" public function yy_r99(){ if ($this->security && $this->security->static_classes !== array()) { $this->compiler->trigger_template_error('dynamic static class not allowed by security setting'); @@ -2485,18 +2483,18 @@ public function yy_r99(){ } $this->_retvalue = $prefixVar .'::'.$this->yystack[$this->yyidx + 0]->minor[0].$this->yystack[$this->yyidx + 0]->minor[1]; } -// line 799 "src/Parser/TemplateParser.y" +// line 797 "src/Parser/TemplateParser.y" public function yy_r100(){ $prefixVar = $this->compiler->getNewPrefixVariable(); $tmp = $this->compiler->appendCode('', $this->yystack[$this->yyidx + 0]->minor); $this->compiler->appendPrefixCode($this->compiler->appendCode($tmp, "")); $this->_retvalue = $prefixVar; } -// line 806 "src/Parser/TemplateParser.y" +// line 804 "src/Parser/TemplateParser.y" public function yy_r101(){ $this->_retvalue = $this->compiler->compileModifier($this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -1]->minor); } -// line 819 "src/Parser/TemplateParser.y" +// line 817 "src/Parser/TemplateParser.y" public function yy_r104(){ if (!in_array(strtolower($this->yystack[$this->yyidx + -2]->minor), array('self', 'parent')) && (!$this->security || $this->security->isTrustedStaticClassAccess($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor, $this->compiler))) { if (isset($this->smarty->registered_classes[$this->yystack[$this->yyidx + -2]->minor])) { @@ -2508,15 +2506,15 @@ public function yy_r104(){ $this->compiler->trigger_template_error ('static class \''.$this->yystack[$this->yyidx + -2]->minor.'\' is undefined or not allowed by security setting'); } } -// line 838 "src/Parser/TemplateParser.y" +// line 836 "src/Parser/TemplateParser.y" public function yy_r106(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; } -// line 849 "src/Parser/TemplateParser.y" +// line 847 "src/Parser/TemplateParser.y" public function yy_r107(){ $this->_retvalue = $this->compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + 0]->minor,1).'\''); } -// line 852 "src/Parser/TemplateParser.y" +// line 850 "src/Parser/TemplateParser.y" public function yy_r108(){ if ($this->yystack[$this->yyidx + 0]->minor['var'] === '\'smarty\'') { $smarty_var = (new \Smarty\Compile\SpecialVariableCompiler())->compile(array(),$this->compiler,$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index']); @@ -2528,104 +2526,104 @@ public function yy_r108(){ $this->_retvalue = $this->compiler->compileVariable($this->yystack[$this->yyidx + 0]->minor['var']).$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index']; } } -// line 865 "src/Parser/TemplateParser.y" +// line 863 "src/Parser/TemplateParser.y" public function yy_r109(){ $this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -2]->minor .')->'.$this->yystack[$this->yyidx + 0]->minor; } -// line 875 "src/Parser/TemplateParser.y" +// line 873 "src/Parser/TemplateParser.y" public function yy_r111(){ $this->_retvalue = $this->compiler->compileConfigVariable('\'' . $this->yystack[$this->yyidx + -1]->minor . '\''); } -// line 879 "src/Parser/TemplateParser.y" +// line 877 "src/Parser/TemplateParser.y" public function yy_r112(){ $this->_retvalue = '(is_array($tmp = ' . $this->compiler->compileConfigVariable('\'' . $this->yystack[$this->yyidx + -2]->minor . '\'') . ') ? $tmp'.$this->yystack[$this->yyidx + 0]->minor.' :null)'; } -// line 883 "src/Parser/TemplateParser.y" +// line 881 "src/Parser/TemplateParser.y" public function yy_r113(){ $this->_retvalue = $this->compiler->compileConfigVariable($this->yystack[$this->yyidx + -1]->minor); } -// line 887 "src/Parser/TemplateParser.y" +// line 885 "src/Parser/TemplateParser.y" public function yy_r114(){ $this->_retvalue = '(is_array($tmp = ' . $this->compiler->compileConfigVariable($this->yystack[$this->yyidx + -2]->minor) . ') ? $tmp'.$this->yystack[$this->yyidx + 0]->minor.' : null)'; } -// line 891 "src/Parser/TemplateParser.y" +// line 889 "src/Parser/TemplateParser.y" public function yy_r115(){ $this->_retvalue = array('var'=>'\''.substr($this->yystack[$this->yyidx + -1]->minor,1).'\'', 'smarty_internal_index'=>$this->yystack[$this->yyidx + 0]->minor); } -// line 894 "src/Parser/TemplateParser.y" +// line 892 "src/Parser/TemplateParser.y" public function yy_r116(){ $this->_retvalue = array('var'=>$this->yystack[$this->yyidx + -1]->minor, 'smarty_internal_index'=>$this->yystack[$this->yyidx + 0]->minor); } -// line 907 "src/Parser/TemplateParser.y" +// line 905 "src/Parser/TemplateParser.y" public function yy_r118(){ return; } -// line 913 "src/Parser/TemplateParser.y" +// line 911 "src/Parser/TemplateParser.y" public function yy_r119(){ $this->_retvalue = '['.$this->compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + 0]->minor,1).'\'').']'; } -// line 916 "src/Parser/TemplateParser.y" +// line 914 "src/Parser/TemplateParser.y" public function yy_r120(){ $this->_retvalue = '['.$this->compiler->compileVariable($this->yystack[$this->yyidx + 0]->minor).']'; } -// line 920 "src/Parser/TemplateParser.y" +// line 918 "src/Parser/TemplateParser.y" public function yy_r121(){ $this->_retvalue = '['.$this->compiler->compileVariable($this->yystack[$this->yyidx + -2]->minor).'->'.$this->yystack[$this->yyidx + 0]->minor.']'; } -// line 924 "src/Parser/TemplateParser.y" +// line 922 "src/Parser/TemplateParser.y" public function yy_r122(){ $this->_retvalue = '[\''. $this->yystack[$this->yyidx + 0]->minor .'\']'; } -// line 928 "src/Parser/TemplateParser.y" +// line 926 "src/Parser/TemplateParser.y" public function yy_r123(){ $this->_retvalue = '['. $this->yystack[$this->yyidx + 0]->minor .']'; } -// line 933 "src/Parser/TemplateParser.y" +// line 931 "src/Parser/TemplateParser.y" public function yy_r124(){ $this->_retvalue = '['. $this->yystack[$this->yyidx + -1]->minor .']'; } -// line 938 "src/Parser/TemplateParser.y" +// line 936 "src/Parser/TemplateParser.y" public function yy_r125(){ $this->_retvalue = '['.(new \Smarty\Compile\SpecialVariableCompiler())->compile(array(),$this->compiler,'[\'section\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\'][\'index\']').']'; } -// line 942 "src/Parser/TemplateParser.y" +// line 940 "src/Parser/TemplateParser.y" public function yy_r126(){ $this->_retvalue = '['.(new \Smarty\Compile\SpecialVariableCompiler())->compile(array(),$this->compiler,'[\'section\'][\''.$this->yystack[$this->yyidx + -3]->minor.'\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\']').']'; } -// line 945 "src/Parser/TemplateParser.y" +// line 943 "src/Parser/TemplateParser.y" public function yy_r127(){ $this->_retvalue = '['.$this->yystack[$this->yyidx + -1]->minor.']'; } -// line 951 "src/Parser/TemplateParser.y" +// line 949 "src/Parser/TemplateParser.y" public function yy_r129(){ $this->_retvalue = '['.$this->compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + -1]->minor,1).'\'').']'; } -// line 967 "src/Parser/TemplateParser.y" +// line 965 "src/Parser/TemplateParser.y" public function yy_r133(){ $this->_retvalue = '[]'; } -// line 977 "src/Parser/TemplateParser.y" +// line 975 "src/Parser/TemplateParser.y" public function yy_r134(){ $this->_retvalue = '\''.substr($this->yystack[$this->yyidx + 0]->minor,1).'\''; } -// line 981 "src/Parser/TemplateParser.y" +// line 979 "src/Parser/TemplateParser.y" public function yy_r135(){ $this->_retvalue = '\'\''; } -// line 986 "src/Parser/TemplateParser.y" +// line 984 "src/Parser/TemplateParser.y" public function yy_r136(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.'.'.$this->yystack[$this->yyidx + 0]->minor; } -// line 994 "src/Parser/TemplateParser.y" +// line 992 "src/Parser/TemplateParser.y" public function yy_r138(){ $var = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' $'); $this->_retvalue = $this->compiler->compileVariable('\''.$var.'\''); } -// line 1000 "src/Parser/TemplateParser.y" +// line 998 "src/Parser/TemplateParser.y" public function yy_r139(){ $this->_retvalue = '('.$this->yystack[$this->yyidx + -1]->minor.')'; } -// line 1007 "src/Parser/TemplateParser.y" +// line 1005 "src/Parser/TemplateParser.y" public function yy_r140(){ if ($this->yystack[$this->yyidx + -1]->minor['var'] === '\'smarty\'') { $this->_retvalue = (new \Smarty\Compile\SpecialVariableCompiler())->compile(array(),$this->compiler,$this->yystack[$this->yyidx + -1]->minor['smarty_internal_index']).$this->yystack[$this->yyidx + 0]->minor; @@ -2633,58 +2631,58 @@ public function yy_r140(){ $this->_retvalue = $this->compiler->compileVariable($this->yystack[$this->yyidx + -1]->minor['var']).$this->yystack[$this->yyidx + -1]->minor['smarty_internal_index'].$this->yystack[$this->yyidx + 0]->minor; } } -// line 1016 "src/Parser/TemplateParser.y" +// line 1014 "src/Parser/TemplateParser.y" public function yy_r141(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; } -// line 1021 "src/Parser/TemplateParser.y" +// line 1019 "src/Parser/TemplateParser.y" public function yy_r142(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } -// line 1026 "src/Parser/TemplateParser.y" +// line 1024 "src/Parser/TemplateParser.y" public function yy_r143(){ if ($this->security && substr($this->yystack[$this->yyidx + -1]->minor,0,1) === '_') { $this->compiler->trigger_template_error (self::ERR1); } $this->_retvalue = '->'.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; } -// line 1033 "src/Parser/TemplateParser.y" +// line 1031 "src/Parser/TemplateParser.y" public function yy_r144(){ if ($this->security) { $this->compiler->trigger_template_error (self::ERR2); } $this->_retvalue = '->{'.$this->compiler->compileVariable($this->yystack[$this->yyidx + -1]->minor).$this->yystack[$this->yyidx + 0]->minor.'}'; } -// line 1040 "src/Parser/TemplateParser.y" +// line 1038 "src/Parser/TemplateParser.y" public function yy_r145(){ if ($this->security) { $this->compiler->trigger_template_error (self::ERR2); } $this->_retvalue = '->{'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + 0]->minor.'}'; } -// line 1047 "src/Parser/TemplateParser.y" +// line 1045 "src/Parser/TemplateParser.y" public function yy_r146(){ if ($this->security) { $this->compiler->trigger_template_error (self::ERR2); } $this->_retvalue = '->{\''.$this->yystack[$this->yyidx + -4]->minor.'\'.'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + 0]->minor.'}'; } -// line 1055 "src/Parser/TemplateParser.y" +// line 1053 "src/Parser/TemplateParser.y" public function yy_r147(){ $this->_retvalue = '->'.$this->yystack[$this->yyidx + 0]->minor; } -// line 1063 "src/Parser/TemplateParser.y" +// line 1061 "src/Parser/TemplateParser.y" public function yy_r148(){ $this->_retvalue = $this->compiler->compileModifierInExpression($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + -1]->minor); } -// line 1071 "src/Parser/TemplateParser.y" +// line 1069 "src/Parser/TemplateParser.y" public function yy_r149(){ if ($this->security && substr($this->yystack[$this->yyidx + -3]->minor,0,1) === '_') { $this->compiler->trigger_template_error (self::ERR1); } $this->_retvalue = $this->yystack[$this->yyidx + -3]->minor . '('. implode(',',$this->yystack[$this->yyidx + -1]->minor) .')'; } -// line 1078 "src/Parser/TemplateParser.y" +// line 1076 "src/Parser/TemplateParser.y" public function yy_r150(){ if ($this->security) { $this->compiler->trigger_template_error (self::ERR2); @@ -2693,55 +2691,55 @@ public function yy_r150(){ $this->compiler->appendPrefixCode("compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + -3]->minor,1).'\'').';?>'); $this->_retvalue = $prefixVar .'('. implode(',',$this->yystack[$this->yyidx + -1]->minor) .')'; } -// line 1089 "src/Parser/TemplateParser.y" +// line 1087 "src/Parser/TemplateParser.y" public function yy_r151(){ $this->_retvalue = array_merge($this->yystack[$this->yyidx + -2]->minor,array($this->yystack[$this->yyidx + 0]->minor)); } -// line 1106 "src/Parser/TemplateParser.y" +// line 1104 "src/Parser/TemplateParser.y" public function yy_r154(){ $this->_retvalue = array_merge($this->yystack[$this->yyidx + -2]->minor,array(array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor))); } -// line 1110 "src/Parser/TemplateParser.y" +// line 1108 "src/Parser/TemplateParser.y" public function yy_r155(){ $this->_retvalue = array(array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor)); } -// line 1118 "src/Parser/TemplateParser.y" +// line 1116 "src/Parser/TemplateParser.y" public function yy_r157(){ $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor); } -// line 1126 "src/Parser/TemplateParser.y" +// line 1124 "src/Parser/TemplateParser.y" public function yy_r158(){ $this->_retvalue = array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor); } -// line 1139 "src/Parser/TemplateParser.y" +// line 1137 "src/Parser/TemplateParser.y" public function yy_r161(){ $this->_retvalue = array(trim($this->yystack[$this->yyidx + -1]->minor).$this->yystack[$this->yyidx + 0]->minor); } -// line 1148 "src/Parser/TemplateParser.y" +// line 1146 "src/Parser/TemplateParser.y" public function yy_r163(){ $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor, '', 'method'); } -// line 1153 "src/Parser/TemplateParser.y" +// line 1151 "src/Parser/TemplateParser.y" public function yy_r164(){ $this->_retvalue = array($this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor, 'method'); } -// line 1158 "src/Parser/TemplateParser.y" +// line 1156 "src/Parser/TemplateParser.y" public function yy_r165(){ $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor, ''); } -// line 1163 "src/Parser/TemplateParser.y" +// line 1161 "src/Parser/TemplateParser.y" public function yy_r166(){ $this->_retvalue = array($this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor, 'property'); } -// line 1168 "src/Parser/TemplateParser.y" +// line 1166 "src/Parser/TemplateParser.y" public function yy_r167(){ $this->_retvalue = array($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor, 'property'); } -// line 1174 "src/Parser/TemplateParser.y" +// line 1172 "src/Parser/TemplateParser.y" public function yy_r168(){ $this->_retvalue = ' '. trim($this->yystack[$this->yyidx + 0]->minor) . ' '; } -// line 1178 "src/Parser/TemplateParser.y" +// line 1176 "src/Parser/TemplateParser.y" public function yy_r169(){ static $lops = array( 'eq' => ' == ', @@ -2761,7 +2759,7 @@ public function yy_r169(){ $op = strtolower(preg_replace('/\s*/', '', $this->yystack[$this->yyidx + 0]->minor)); $this->_retvalue = $lops[$op]; } -// line 1197 "src/Parser/TemplateParser.y" +// line 1195 "src/Parser/TemplateParser.y" public function yy_r170(){ static $tlops = array( 'isdivby' => array('op' => ' % ', 'pre' => '!('), @@ -2774,7 +2772,7 @@ public function yy_r170(){ $op = strtolower(preg_replace('/\s*/', '', $this->yystack[$this->yyidx + 0]->minor)); $this->_retvalue = $tlops[$op]; } -// line 1210 "src/Parser/TemplateParser.y" +// line 1208 "src/Parser/TemplateParser.y" public function yy_r171(){ static $scond = array ( 'iseven' => '!(1 & ', @@ -2785,53 +2783,53 @@ public function yy_r171(){ $op = strtolower(str_replace(' ', '', $this->yystack[$this->yyidx + 0]->minor)); $this->_retvalue = $scond[$op]; } -// line 1224 "src/Parser/TemplateParser.y" +// line 1222 "src/Parser/TemplateParser.y" public function yy_r172(){ $this->_retvalue = 'array('.$this->yystack[$this->yyidx + -1]->minor.')'; } -// line 1235 "src/Parser/TemplateParser.y" +// line 1233 "src/Parser/TemplateParser.y" public function yy_r175(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.','.$this->yystack[$this->yyidx + 0]->minor; } -// line 1243 "src/Parser/TemplateParser.y" +// line 1241 "src/Parser/TemplateParser.y" public function yy_r177(){ $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'=>'.$this->yystack[$this->yyidx + 0]->minor; } -// line 1247 "src/Parser/TemplateParser.y" +// line 1245 "src/Parser/TemplateParser.y" public function yy_r178(){ $this->_retvalue = '\''.$this->yystack[$this->yyidx + -2]->minor.'\'=>'.$this->yystack[$this->yyidx + 0]->minor; } -// line 1263 "src/Parser/TemplateParser.y" +// line 1261 "src/Parser/TemplateParser.y" public function yy_r181(){ $this->compiler->leaveDoubleQuote(); $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor->to_smarty_php($this); } -// line 1269 "src/Parser/TemplateParser.y" +// line 1267 "src/Parser/TemplateParser.y" public function yy_r182(){ $this->yystack[$this->yyidx + -1]->minor->append_subtree($this, $this->yystack[$this->yyidx + 0]->minor); $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; } -// line 1274 "src/Parser/TemplateParser.y" +// line 1272 "src/Parser/TemplateParser.y" public function yy_r183(){ $this->_retvalue = new Dq($this, $this->yystack[$this->yyidx + 0]->minor); } -// line 1278 "src/Parser/TemplateParser.y" +// line 1276 "src/Parser/TemplateParser.y" public function yy_r184(){ $this->_retvalue = new Code('(string)'.$this->yystack[$this->yyidx + -1]->minor); } -// line 1282 "src/Parser/TemplateParser.y" +// line 1280 "src/Parser/TemplateParser.y" public function yy_r185(){ $this->_retvalue = new Code('(string)('.$this->yystack[$this->yyidx + -1]->minor.')'); } -// line 1286 "src/Parser/TemplateParser.y" +// line 1284 "src/Parser/TemplateParser.y" public function yy_r186(){ $this->_retvalue = new Code('(string)$_smarty_tpl->getValue(\''. substr($this->yystack[$this->yyidx + 0]->minor,1) .'\')'); } -// line 1298 "src/Parser/TemplateParser.y" +// line 1296 "src/Parser/TemplateParser.y" public function yy_r189(){ $this->_retvalue = new Tag($this, $this->yystack[$this->yyidx + 0]->minor); } -// line 1302 "src/Parser/TemplateParser.y" +// line 1300 "src/Parser/TemplateParser.y" public function yy_r190(){ $this->_retvalue = new DqContent($this->yystack[$this->yyidx + 0]->minor); } diff --git a/src/Parser/TemplateParser.y b/src/Parser/TemplateParser.y index 7305dcc81..68648196a 100644 --- a/src/Parser/TemplateParser.y +++ b/src/Parser/TemplateParser.y @@ -290,9 +290,7 @@ literal_e1(A) ::= . { } // Smarty tag template ::= template smartytag(B). { - if ($this->compiler->has_code) { - $this->current_buffer->append_subtree($this, $this->mergePrefixCode(B)); - } + $this->current_buffer->append_subtree($this, $this->mergePrefixCode(B)); $this->compiler->has_variable_string = false; $this->block_nesting_level = $this->compiler->getTagStackCount(); } diff --git a/tests/UnitTests/SecurityTests/SecurityTest.php b/tests/UnitTests/SecurityTests/SecurityTest.php index 5f896cc81..e2e66c965 100644 --- a/tests/UnitTests/SecurityTests/SecurityTest.php +++ b/tests/UnitTests/SecurityTests/SecurityTest.php @@ -303,7 +303,7 @@ public function testTemplateNotTrustedStream() } /** * - * + * @group slow */ public function testTrustedUri() { diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php index 1a0564eb2..3dc8c0a75 100644 --- a/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php +++ b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php @@ -304,7 +304,8 @@ class blockparamsCompiler extends \Smarty\Compile\Base { protected $shorttag_order = ["first", "second"]; protected $optional_attributes = ["first", "second"]; - public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null): string + { $_attr = $this->getAttributes($compiler, $args); $output = ''; diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php index 13ca0dee7..8727d89f5 100644 --- a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php +++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php @@ -6,7 +6,8 @@ class smarty_compiler_test extends Base { - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $this->required_attributes = array('data'); $_attr = $this->getAttributes($compiler, $args); diff --git a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.testclose.php b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.testclose.php index 68ab73f1d..c9b4c6152 100644 --- a/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.testclose.php +++ b/tests/UnitTests/TemplateSource/TagTests/CompilerPlugin/PHPunitplugins/compiler.testclose.php @@ -6,7 +6,8 @@ class smarty_compiler_testclose extends Base { - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $this->closeTag($compiler, 'test'); diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php index bece9d6d3..d9899e3c4 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionFetchTest.php @@ -30,7 +30,7 @@ public function testInit() * test {fetch} from UIR * * -* +* @group slow */ public function testFetchUri() { diff --git a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php index 3f13cb4cb..863ca6c41 100644 --- a/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/TemplateFunction/CompileFunctionTest.php @@ -32,7 +32,6 @@ public function testInit() * * @dataProvider functionProvider * test simple function call tag - * */ public function testSimpleFunction_001($text) { diff --git a/tests/UnitTests/__shared/PHPunitplugins/compiler.getparamsshort.php b/tests/UnitTests/__shared/PHPunitplugins/compiler.getparamsshort.php index 368b4a912..9fb80a894 100644 --- a/tests/UnitTests/__shared/PHPunitplugins/compiler.getparamsshort.php +++ b/tests/UnitTests/__shared/PHPunitplugins/compiler.getparamsshort.php @@ -41,8 +41,8 @@ class smarty_compiler_getparamsshort extends Base */ public $shorttag_order = array('s1', 's2', 's3'); - public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) - { + public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string + { $_attr = $this->getAttributes($compiler, $args); $output = ' $value) {