From ccc9543632b0c292ef312993804a96189f2a4ab3 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Wed, 29 Nov 2023 00:12:39 +0100 Subject: [PATCH] Add :string method signature to compile method everywhere. --- src/Compile/Base.php | 2 +- src/Compile/BlockCompiler.php | 3 ++- src/Compile/CompilerInterface.php | 2 +- src/Compile/DefaultHandlerFunctionCallCompiler.php | 3 ++- src/Compile/FunctionCallCompiler.php | 3 ++- src/Compile/ModifierCompiler.php | 3 ++- src/Compile/ObjectMethodCallCompiler.php | 3 ++- src/Compile/PrintExpressionCompiler.php | 3 ++- src/Compile/SpecialVariableCompiler.php | 5 ++++- src/Compile/Tag/Append.php | 4 ++-- src/Compile/Tag/Assign.php | 4 ++-- src/Compile/Tag/BCPluginWrapper.php | 3 ++- src/Compile/Tag/Block.php | 2 +- src/Compile/Tag/BlockClose.php | 2 +- src/Compile/Tag/BreakTag.php | 2 +- src/Compile/Tag/Call.php | 3 ++- src/Compile/Tag/Capture.php | 3 ++- src/Compile/Tag/CaptureClose.php | 3 ++- src/Compile/Tag/ConfigLoad.php | 3 ++- src/Compile/Tag/Debug.php | 3 ++- src/Compile/Tag/ElseIfTag.php | 3 ++- src/Compile/Tag/ElseTag.php | 3 ++- src/Compile/Tag/EvalTag.php | 3 ++- src/Compile/Tag/ExtendsTag.php | 3 ++- src/Compile/Tag/ForClose.php | 3 ++- src/Compile/Tag/ForElse.php | 3 ++- src/Compile/Tag/ForTag.php | 3 ++- src/Compile/Tag/ForeachClose.php | 3 ++- src/Compile/Tag/ForeachElse.php | 3 ++- src/Compile/Tag/ForeachTag.php | 3 ++- src/Compile/Tag/FunctionClose.php | 5 +++-- src/Compile/Tag/FunctionTag.php | 5 +++-- src/Compile/Tag/IfClose.php | 3 ++- src/Compile/Tag/IfTag.php | 3 ++- src/Compile/Tag/IncludeTag.php | 3 ++- src/Compile/Tag/Ldelim.php | 3 ++- src/Compile/Tag/Nocache.php | 5 +++-- src/Compile/Tag/NocacheClose.php | 5 +++-- src/Compile/Tag/Rdelim.php | 3 ++- src/Compile/Tag/Section.php | 3 ++- src/Compile/Tag/SectionClose.php | 3 ++- src/Compile/Tag/SectionElse.php | 3 ++- src/Compile/Tag/Setfilter.php | 3 ++- src/Compile/Tag/SetfilterClose.php | 3 ++- src/Compile/Tag/WhileClose.php | 3 ++- src/Compile/Tag/WhileTag.php | 3 ++- .../SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php | 3 ++- .../TagTests/CompilerPlugin/PHPunitplugins/compiler.test.php | 3 ++- .../CompilerPlugin/PHPunitplugins/compiler.testclose.php | 3 ++- .../__shared/PHPunitplugins/compiler.getparamsshort.php | 4 ++-- 50 files changed, 101 insertions(+), 57 deletions(-) diff --git a/src/Compile/Base.php b/src/Compile/Base.php index 105ee7405..2d5c0c0ef 100644 --- a/src/Compile/Base.php +++ b/src/Compile/Base.php @@ -229,5 +229,5 @@ protected function convertScope($scope): int { * @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 5bd55613d..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); diff --git a/src/Compile/CompilerInterface.php b/src/Compile/CompilerInterface.php index c33492222..5f2cc7ccc 100644 --- a/src/Compile/CompilerInterface.php +++ b/src/Compile/CompilerInterface.php @@ -20,7 +20,7 @@ interface CompilerInterface { * @return string compiled code as a string * @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; public function isCacheable(): bool; } \ No newline at end of file diff --git a/src/Compile/DefaultHandlerFunctionCallCompiler.php b/src/Compile/DefaultHandlerFunctionCallCompiler.php index ff2f131c2..e6d11384e 100644 --- a/src/Compile/DefaultHandlerFunctionCallCompiler.php +++ b/src/Compile/DefaultHandlerFunctionCallCompiler.php @@ -27,7 +27,8 @@ class DefaultHandlerFunctionCallCompiler 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); 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 71b6511f9..4e6232244 100644 --- a/src/Compile/ModifierCompiler.php +++ b/src/Compile/ModifierCompiler.php @@ -33,7 +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) { + 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 9220eeb93..3302254f9 100644 --- a/src/Compile/PrintExpressionCompiler.php +++ b/src/Compile/PrintExpressionCompiler.php @@ -47,7 +47,8 @@ class PrintExpressionCompiler extends Base { * @return string * @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); diff --git a/src/Compile/SpecialVariableCompiler.php b/src/Compile/SpecialVariableCompiler.php index 9ed96780e..2b6cf4330 100644 --- a/src/Compile/SpecialVariableCompiler.php +++ b/src/Compile/SpecialVariableCompiler.php @@ -37,7 +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) { + 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])); @@ -127,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 0ea4873a4..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; diff --git a/src/Compile/Tag/BlockClose.php b/src/Compile/Tag/BlockClose.php index ee42edca7..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']); 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 101393a77..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'"; 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 e33e1308b..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) { 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 330359552..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]; diff --git a/src/Compile/Tag/FunctionTag.php b/src/Compile/Tag/FunctionTag.php index 2d99d7f1f..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) { 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 ffa7b7c28..dd30f8937 100644 --- a/src/Compile/Tag/Nocache.php +++ b/src/Compile/Tag/Nocache.php @@ -26,9 +26,10 @@ 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'); return ''; } diff --git a/src/Compile/Tag/NocacheClose.php b/src/Compile/Tag/NocacheClose.php index 93461f12d..75edd9982 100644 --- a/src/Compile/Tag/NocacheClose.php +++ b/src/Compile/Tag/NocacheClose.php @@ -27,9 +27,10 @@ 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']); 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 2e0a4b2fb..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, diff --git a/src/Compile/Tag/SetfilterClose.php b/src/Compile/Tag/SetfilterClose.php index dd960ba0b..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 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/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/__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) {