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 105ee740..2d5c0c0e 100644 --- a/src/Compile/Base.php +++ b/src/Compile/Base.php @@ -229,5 +229,5 @@ abstract class Base implements CompilerInterface { * @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 5bd55613..e7a8f310 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 c3349222..5f2cc7cc 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 ff2f131c..e6d11384 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 8934c8d7..107dd98b 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 71b6511f..4e623224 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 f3ce6960..70855cfc 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 9220eeb9..3302254f 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 9ed96780..2b6cf433 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 @@ class SpecialVariableCompiler extends Base { } return $compiled_ref; } + + return ''; } } diff --git a/src/Compile/Tag/Append.php b/src/Compile/Tag/Append.php index 86eda99e..171f6960 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 f53bdf33..8433a97e 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 0224250d..abd89f78 100644 --- a/src/Compile/Tag/BCPluginWrapper.php +++ b/src/Compile/Tag/BCPluginWrapper.php @@ -24,7 +24,8 @@ class BCPluginWrapper extends Base { /** * @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 0ea4873a..d8b30100 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 ee42edca..586c7c05 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 0ec03df2..b8b554f3 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 101393a7..7b7362f9 100644 --- a/src/Compile/Tag/Capture.php +++ b/src/Compile/Tag/Capture.php @@ -53,7 +53,8 @@ class Capture 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); $buffer = $_attr['name'] ?? "'default'"; diff --git a/src/Compile/Tag/CaptureClose.php b/src/Compile/Tag/CaptureClose.php index 0d553a2b..c0d77969 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 6425749e..d9e67ec9 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 bd899892..4542bd3c 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 60b888a8..8e59c341 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 68a9a023..a7025da7 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 c6535570..8396fd09 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 e33e1308..dcdbbc97 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 bde1a075..189bcfd9 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 a754a0d5..d939a72a 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 8066d83e..fdf71b68 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 80599149..e657c1d8 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 3397bb4f..d4889847 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 c77a5464..9f765af5 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 33035955..aff6dc65 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 2d99d7f1..c291c3de 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 12f7e442..df15094f 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 84bf477c..7790859b 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 f7619cc7..8e775811 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 5a48d3ad..a265fa70 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 ffa7b7c2..dd30f893 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 93461f12..75edd998 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 87bd1889..60e7a23d 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 de9202c5..f82ac421 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 dee65bab..efab6097 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 be861e98..b9ea5636 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 2e0a4b2f..9da2f969 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 dd960ba0..2814f641 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 6c45cd72..5adb3a49 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 3df7d197..3300b507 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 1a0564eb..3dc8c0a7 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 13ca0dee..8727d89f 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 @@ use Smarty\Compile\Base; 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 68ab73f1..c9b4c615 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 @@ use Smarty\Compile\Base; 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 368b4a91..9fb80a89 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) {