From 608a400e66d24e86cd89c848948b20ab2e12fac6 Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Thu, 5 Jan 2023 23:07:45 +0100 Subject: [PATCH] Fix scoping / global state problems in tests by using DI in Default Extension. Also removing a bunch of old fashioned phpdoc annotations that are superseded by namespaces. --- demo/index.php | 2 +- docs/programmers/caching/caching-custom.md | 4 +- docs/programmers/plugins/plugins-resources.md | 2 +- .../programmers/resources/resources-custom.md | 2 +- .../resources/template-resources.md | 2 +- phpunit.xml | 2 +- src/Cacheresource/Base.php | 8 +- src/Cacheresource/Custom.php | 8 +- src/Cacheresource/File.php | 8 +- src/Cacheresource/KeyValueStore.php | 8 +- src/Compile/Base.php | 4 +- src/Compile/BlockCompiler.php | 8 +- src/Compile/CompilerInterface.php | 4 +- src/Compile/FunctionCallCompiler.php | 8 +- src/Compile/ModifierCompiler.php | 8 +- src/Compile/ObjectMethodBlockCompiler.php | 8 +- src/Compile/ObjectMethodCallCompiler.php | 8 +- src/Compile/PrintExpressionCompiler.php | 8 +- src/Compile/SpecialVariableCompiler.php | 8 +- src/Compile/Tag/Append.php | 8 +- src/Compile/Tag/Assign.php | 8 +- src/Compile/Tag/BreakTag.php | 8 +- src/Compile/Tag/Call.php | 5 - src/Compile/Tag/Capture.php | 4 +- src/Compile/Tag/CaptureClose.php | 8 +- src/Compile/Tag/ConfigLoad.php | 8 +- src/Compile/Tag/ContinueTag.php | 8 +- src/Compile/Tag/Debug.php | 8 +- src/Compile/Tag/ElseIfTag.php | 4 +- src/Compile/Tag/ElseTag.php | 4 +- src/Compile/Tag/EvalTag.php | 8 +- src/Compile/Tag/ExtendsTag.php | 8 +- src/Compile/Tag/ForClose.php | 8 +- src/Compile/Tag/ForElse.php | 4 +- src/Compile/Tag/ForTag.php | 4 +- src/Compile/Tag/ForeachClose.php | 8 +- src/Compile/Tag/ForeachElse.php | 4 +- src/Compile/Tag/ForeachSection.php | 8 +- src/Compile/Tag/ForeachTag.php | 4 +- src/Compile/Tag/FunctionClose.php | 8 +- src/Compile/Tag/FunctionTag.php | 4 +- src/Compile/Tag/IfClose.php | 8 +- src/Compile/Tag/IfTag.php | 4 +- src/Compile/Tag/IncludeTag.php | 8 +- src/Compile/Tag/Inheritance.php | 8 +- src/Compile/Tag/Ldelim.php | 8 +- src/Compile/Tag/MakeNocache.php | 8 +- src/Compile/Tag/Nocache.php | 4 +- src/Compile/Tag/NocacheClose.php | 8 +- src/Compile/Tag/Rdelim.php | 8 +- src/Compile/Tag/Section.php | 4 +- src/Compile/Tag/SectionClose.php | 8 +- src/Compile/Tag/SectionElse.php | 4 +- src/Compile/Tag/Setfilter.php | 4 +- src/Compile/Tag/SetfilterClose.php | 8 +- src/Compile/Tag/WhileClose.php | 8 +- src/Compile/Tag/WhileTag.php | 4 +- src/Compiler/Configfile.php | 8 +- src/Compiler/Template.php | 8 +- src/CompilerException.php | 2 +- src/Data.php | 4 +- src/DataObject.php | 8 +- src/Debug.php | 8 +- src/ErrorHandler.php | 4 +- src/Extension/DefaultExtension.php | 97 ++++++++++--------- src/FunctionHandler/Counter.php | 9 +- src/ParseTree/Base.php | 8 +- src/ParseTree/Code.php | 8 +- src/ParseTree/Dq.php | 8 +- src/ParseTree/DqContent.php | 8 +- src/ParseTree/Tag.php | 8 +- src/ParseTree/Template.php | 8 +- src/ParseTree/Text.php | 8 +- src/Resource/BasePlugin.php | 8 +- src/Resource/CustomPlugin.php | 8 +- src/Resource/ExtendsPlugin.php | 8 +- src/Resource/FilePlugin.php | 8 +- src/Resource/PhpPlugin.php | 4 +- src/Resource/RecompiledPlugin.php | 8 +- src/Resource/StreamPlugin.php | 8 +- src/Resource/StringEval.php | 8 +- src/Resource/StringPlugin.php | 8 +- src/Resource/UncompiledPlugin.php | 8 +- src/Runtime/Block.php | 4 +- src/Runtime/CaptureRuntime.php | 4 +- src/Runtime/ForeachRuntime.php | 4 +- src/Runtime/InheritanceRuntime.php | 4 +- src/Runtime/MakeNocacheRuntime.php | 4 +- src/Runtime/TplFunctionRuntime.php | 4 +- src/Security.php | 4 +- src/Smarty.php | 5 +- src/Template.php | 4 +- src/Template/Cached.php | 4 +- src/Template/Compiled.php | 4 +- src/Template/ResourceBase.php | 4 +- src/Template/Source.php | 4 +- src/TemplateBase.php | 4 +- src/TestInstall.php | 8 +- src/UndefinedVariable.php | 4 +- src/Variable.php | 4 +- 100 files changed, 355 insertions(+), 353 deletions(-) diff --git a/demo/index.php b/demo/index.php index 1e182c27..bf3aa489 100644 --- a/demo/index.php +++ b/demo/index.php @@ -2,7 +2,7 @@ /** * Example Application * - * @package Example-application + */ $smarty = new \Smarty\Smarty; diff --git a/docs/programmers/caching/caching-custom.md b/docs/programmers/caching/caching-custom.md index c0eddb59..e9c33368 100644 --- a/docs/programmers/caching/caching-custom.md +++ b/docs/programmers/caching/caching-custom.md @@ -63,7 +63,7 @@ to invoke your custom CacheResource implementation. * INDEX(`modified`) * ) ENGINE = InnoDB; * - * @package CacheResource-examples + * @author Rodney Rehm */ class My_CacheResource_Mysql extends \Smarty\Cacheresource\Custom { @@ -211,7 +211,7 @@ to invoke your custom CacheResource implementation. * Note that memcache has a limitation of 256 characters per cache-key. * To avoid complications all cache-keys are translated to a sha1 hash. * - * @package CacheResource-examples + * @author Rodney Rehm */ class My_CacheResource_Memcache extends \Smarty\Cacheresource\KeyValueStore { diff --git a/docs/programmers/plugins/plugins-resources.md b/docs/programmers/plugins/plugins-resources.md index 608792cd..4195222f 100644 --- a/docs/programmers/plugins/plugins-resources.md +++ b/docs/programmers/plugins/plugins-resources.md @@ -48,7 +48,7 @@ example. * Demo data: *
INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');
* - * @package Resource-examples + * @author Rodney Rehm */ class My_Resource_Mysql extends \Smarty\Resource\CustomPlugin { diff --git a/docs/programmers/resources/resources-custom.md b/docs/programmers/resources/resources-custom.md index 569f6b73..7d05e4f5 100644 --- a/docs/programmers/resources/resources-custom.md +++ b/docs/programmers/resources/resources-custom.md @@ -34,7 +34,7 @@ on the functions you are supposed to provide. * Demo data: *
INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');
* - * @package Resource-examples + * @author Rodney Rehm */ class My_Resource_Mysql extends \Smarty\Resource\Custom { diff --git a/docs/programmers/resources/template-resources.md b/docs/programmers/resources/template-resources.md index 3fb1b163..a14e518f 100644 --- a/docs/programmers/resources/template-resources.md +++ b/docs/programmers/resources/template-resources.md @@ -44,7 +44,7 @@ on the functions you are supposed to provide. * Demo data: *
INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');
* - * @package Resource-examples + * @author Rodney Rehm */ class My_Resource_Mysql extends \Smarty\Resource\Custom { diff --git a/phpunit.xml b/phpunit.xml index e0ad81d6..4bdff288 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -4,7 +4,7 @@ bootstrap="tests/Bootstrap.php" colors="true" backupGlobals="false" - backupStaticAttributes="true" + backupStaticAttributes="false" forceCoversAnnotation="false" processIsolation="false" stopOnError="false" diff --git a/src/Cacheresource/Base.php b/src/Cacheresource/Base.php index 12124551..7eccb288 100644 --- a/src/Cacheresource/Base.php +++ b/src/Cacheresource/Base.php @@ -9,15 +9,15 @@ use Smarty\Template\Cached; /** * Smarty Internal Plugin * - * @package Smarty - * @subpackage Cacher + + */ /** * Cache Handler API * - * @package Smarty - * @subpackage Cacher + + * @author Rodney Rehm */ abstract class Base diff --git a/src/Cacheresource/Custom.php b/src/Cacheresource/Custom.php index e344a8e3..949b0d82 100644 --- a/src/Cacheresource/Custom.php +++ b/src/Cacheresource/Custom.php @@ -5,8 +5,8 @@ namespace Smarty\Cacheresource; /** * Smarty Internal Plugin * - * @package Smarty - * @subpackage Cacher + + */ use Smarty\Smarty; @@ -16,8 +16,8 @@ use Smarty\Template\Cached; /** * Cache Handler API * - * @package Smarty - * @subpackage Cacher + + * @author Rodney Rehm */ abstract class Custom extends Base diff --git a/src/Cacheresource/File.php b/src/Cacheresource/File.php index b026c38a..1d9abdd7 100644 --- a/src/Cacheresource/File.php +++ b/src/Cacheresource/File.php @@ -11,8 +11,8 @@ use Smarty\Template\Cached; /** * Smarty Internal Plugin CacheResource File * - * @package Smarty - * @subpackage Cacher + + * @author Uwe Tews * @author Rodney Rehm */ @@ -21,8 +21,8 @@ use Smarty\Template\Cached; * This class does contain all necessary methods for the HTML cache on file system * Implements the file system as resource for the HTML cache Version ussing nocache inserts. * - * @package Smarty - * @subpackage Cacher + + */ class File extends Base { diff --git a/src/Cacheresource/KeyValueStore.php b/src/Cacheresource/KeyValueStore.php index a51b2b90..d44c3684 100644 --- a/src/Cacheresource/KeyValueStore.php +++ b/src/Cacheresource/KeyValueStore.php @@ -9,8 +9,8 @@ use Smarty\Template\Cached; /** * Smarty Internal Plugin * - * @package Smarty - * @subpackage Cacher + + */ /** @@ -31,8 +31,8 @@ use Smarty\Template\Cached; * cache groups: if your cache groups look somewhat like »a|b|$page|$items|$whatever« * consider using »a|b|c|$page-$items-$whatever« instead. * - * @package Smarty - * @subpackage Cacher + + * @author Rodney Rehm */ abstract class KeyValueStore extends Base diff --git a/src/Compile/Base.php b/src/Compile/Base.php index 12f3c3a5..85bcf72e 100644 --- a/src/Compile/Base.php +++ b/src/Compile/Base.php @@ -8,8 +8,8 @@ namespace Smarty\Compile; /** * This class does extend all internal compile plugins * - * @package Smarty - * @subpackage Compiler + + */ abstract class Base implements CompilerInterface { diff --git a/src/Compile/BlockCompiler.php b/src/Compile/BlockCompiler.php index 616edd4a..b96d5257 100644 --- a/src/Compile/BlockCompiler.php +++ b/src/Compile/BlockCompiler.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Block Plugin * Compiles code for the execution of block plugin * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -17,8 +17,8 @@ use Smarty\Exception; /** * Smarty Internal Plugin Compile Block Plugin Class * - * @package Smarty - * @subpackage Compiler + + */ class BlockCompiler extends Base { diff --git a/src/Compile/CompilerInterface.php b/src/Compile/CompilerInterface.php index 2d143fa1..0fdbb9eb 100644 --- a/src/Compile/CompilerInterface.php +++ b/src/Compile/CompilerInterface.php @@ -5,8 +5,8 @@ namespace Smarty\Compile; /** * This class does extend all internal compile plugins * - * @package Smarty - * @subpackage Compiler + + */ interface CompilerInterface { diff --git a/src/Compile/FunctionCallCompiler.php b/src/Compile/FunctionCallCompiler.php index 89340c7d..3e3a3217 100644 --- a/src/Compile/FunctionCallCompiler.php +++ b/src/Compile/FunctionCallCompiler.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Registered Function * Compiles code for the execution of a registered function * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compiler\Template; /** * Smarty Internal Plugin Compile Registered Function Class * - * @package Smarty - * @subpackage Compiler + + */ class FunctionCallCompiler extends Base { diff --git a/src/Compile/ModifierCompiler.php b/src/Compile/ModifierCompiler.php index c15e45ba..5058a5a4 100644 --- a/src/Compile/ModifierCompiler.php +++ b/src/Compile/ModifierCompiler.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Modifier * Compiles code for modifier execution * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Modifier Class * - * @package Smarty - * @subpackage Compiler + + */ class ModifierCompiler extends Base { diff --git a/src/Compile/ObjectMethodBlockCompiler.php b/src/Compile/ObjectMethodBlockCompiler.php index c8e921ff..76af1009 100644 --- a/src/Compile/ObjectMethodBlockCompiler.php +++ b/src/Compile/ObjectMethodBlockCompiler.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Object Block Function * Compiles code for registered objects as block function * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -13,8 +13,8 @@ namespace Smarty\Compile; /** * Smarty Internal Plugin Compile Object Block Function Class * - * @package Smarty - * @subpackage Compiler + + */ class ObjectMethodBlockCompiler extends BlockCompiler { diff --git a/src/Compile/ObjectMethodCallCompiler.php b/src/Compile/ObjectMethodCallCompiler.php index 673acedb..4e30b8c7 100644 --- a/src/Compile/ObjectMethodCallCompiler.php +++ b/src/Compile/ObjectMethodCallCompiler.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Object Function * Compiles code for registered objects as function * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -13,8 +13,8 @@ namespace Smarty\Compile; /** * Smarty Internal Plugin Compile Object Function Class * - * @package Smarty - * @subpackage Compiler + + */ class ObjectMethodCallCompiler extends Base { diff --git a/src/Compile/PrintExpressionCompiler.php b/src/Compile/PrintExpressionCompiler.php index 89c42973..13fe746f 100644 --- a/src/Compile/PrintExpressionCompiler.php +++ b/src/Compile/PrintExpressionCompiler.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Print Expression * Compiles any tag which will output an expression or variable * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -16,8 +16,8 @@ use Smarty\Compiler\BaseCompiler; /** * Smarty Internal Plugin Compile Print Expression Class * - * @package Smarty - * @subpackage Compiler + + */ class PrintExpressionCompiler extends Base { diff --git a/src/Compile/SpecialVariableCompiler.php b/src/Compile/SpecialVariableCompiler.php index b838e67a..9467e084 100644 --- a/src/Compile/SpecialVariableCompiler.php +++ b/src/Compile/SpecialVariableCompiler.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Special Smarty Variable * Compiles the special $smarty variables * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -20,8 +20,8 @@ use Smarty\CompilerException; /** * Smarty Internal Plugin Compile special Smarty Variable Class * - * @package Smarty - * @subpackage Compiler + + */ class SpecialVariableCompiler extends Base { diff --git a/src/Compile/Tag/Append.php b/src/Compile/Tag/Append.php index 6d7f1a93..e4a7b841 100644 --- a/src/Compile/Tag/Append.php +++ b/src/Compile/Tag/Append.php @@ -6,16 +6,16 @@ namespace Smarty\Compile\Tag; * Smarty Internal Plugin Compile Append * Compiles the {append} tag * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ /** * Smarty Internal Plugin Compile Append Class * - * @package Smarty - * @subpackage Compiler + + */ class Append extends Assign { diff --git a/src/Compile/Tag/Assign.php b/src/Compile/Tag/Assign.php index 06f5fba7..997eaa79 100644 --- a/src/Compile/Tag/Assign.php +++ b/src/Compile/Tag/Assign.php @@ -9,16 +9,16 @@ use Smarty\Smarty; * Smarty Internal Plugin Compile Assign * Compiles the {assign} tag * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ /** * Smarty Internal Plugin Compile Assign Class * - * @package Smarty - * @subpackage Compiler + + */ class Assign extends Base { diff --git a/src/Compile/Tag/BreakTag.php b/src/Compile/Tag/BreakTag.php index 0850fa87..fd562511 100644 --- a/src/Compile/Tag/BreakTag.php +++ b/src/Compile/Tag/BreakTag.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Break * Compiles the {break} tag * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Break Class * - * @package Smarty - * @subpackage Compiler + + */ class BreakTag extends Base { diff --git a/src/Compile/Tag/Call.php b/src/Compile/Tag/Call.php index 3a1112d7..3d552f10 100644 --- a/src/Compile/Tag/Call.php +++ b/src/Compile/Tag/Call.php @@ -3,8 +3,6 @@ * Smarty Internal Plugin Compile Function_Call * Compiles the calls of user defined tags defined by {function} * - * @package Smarty - * @subpackage Compiler * @author Uwe Tews */ @@ -14,9 +12,6 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Function_Call Class - * - * @package Smarty - * @subpackage Compiler */ class Call extends Base { diff --git a/src/Compile/Tag/Capture.php b/src/Compile/Tag/Capture.php index b58b3ba4..8dee4a8e 100644 --- a/src/Compile/Tag/Capture.php +++ b/src/Compile/Tag/Capture.php @@ -7,8 +7,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Capture Class * - * @package Smarty - * @subpackage Compiler + + */ class Capture extends Base { diff --git a/src/Compile/Tag/CaptureClose.php b/src/Compile/Tag/CaptureClose.php index 2df4d3a9..e15766b6 100644 --- a/src/Compile/Tag/CaptureClose.php +++ b/src/Compile/Tag/CaptureClose.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Capture * Compiles the {capture} tag * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Captureclose Class * - * @package Smarty - * @subpackage Compiler + + */ class CaptureClose extends Base { diff --git a/src/Compile/Tag/ConfigLoad.php b/src/Compile/Tag/ConfigLoad.php index 809d7908..dc68bbdd 100644 --- a/src/Compile/Tag/ConfigLoad.php +++ b/src/Compile/Tag/ConfigLoad.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Config Load * Compiles the {config load} tag * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -16,8 +16,8 @@ use Smarty\Smarty; /** * Smarty Internal Plugin Compile Config Load Class * - * @package Smarty - * @subpackage Compiler + + */ class ConfigLoad extends Base { diff --git a/src/Compile/Tag/ContinueTag.php b/src/Compile/Tag/ContinueTag.php index f5a3f3dd..82abe6ce 100644 --- a/src/Compile/Tag/ContinueTag.php +++ b/src/Compile/Tag/ContinueTag.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Continue * Compiles the {continue} tag * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -13,8 +13,8 @@ namespace Smarty\Compile\Tag; /** * Smarty Internal Plugin Compile Continue Class * - * @package Smarty - * @subpackage Compiler + + */ class ContinueTag extends BreakTag { diff --git a/src/Compile/Tag/Debug.php b/src/Compile/Tag/Debug.php index 10ba31fc..bd899892 100644 --- a/src/Compile/Tag/Debug.php +++ b/src/Compile/Tag/Debug.php @@ -4,8 +4,8 @@ * Compiles the {debug} tag. * It opens a window the the Smarty Debugging Console. * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -16,8 +16,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Debug Class * - * @package Smarty - * @subpackage Compiler + + */ class Debug extends Base { diff --git a/src/Compile/Tag/ElseIfTag.php b/src/Compile/Tag/ElseIfTag.php index 131211ab..c127e273 100644 --- a/src/Compile/Tag/ElseIfTag.php +++ b/src/Compile/Tag/ElseIfTag.php @@ -7,8 +7,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile ElseIf Class * - * @package Smarty - * @subpackage Compiler + + */ class ElseIfTag extends Base { diff --git a/src/Compile/Tag/ElseTag.php b/src/Compile/Tag/ElseTag.php index 3cf8f066..68a9a023 100644 --- a/src/Compile/Tag/ElseTag.php +++ b/src/Compile/Tag/ElseTag.php @@ -7,8 +7,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Else Class * - * @package Smarty - * @subpackage Compiler + + */ class ElseTag extends Base { diff --git a/src/Compile/Tag/EvalTag.php b/src/Compile/Tag/EvalTag.php index a7649f23..191dee3c 100644 --- a/src/Compile/Tag/EvalTag.php +++ b/src/Compile/Tag/EvalTag.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Eval * Compiles the {eval} tag. * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Eval Class * - * @package Smarty - * @subpackage Compiler + + */ class EvalTag extends Base { diff --git a/src/Compile/Tag/ExtendsTag.php b/src/Compile/Tag/ExtendsTag.php index 6d32142e..bcd02344 100644 --- a/src/Compile/Tag/ExtendsTag.php +++ b/src/Compile/Tag/ExtendsTag.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile extend * Compiles the {extends} tag * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -13,8 +13,8 @@ namespace Smarty\Compile\Tag; /** * Smarty Internal Plugin Compile extend Class * - * @package Smarty - * @subpackage Compiler + + */ class ExtendsTag extends Inheritance { diff --git a/src/Compile/Tag/ForClose.php b/src/Compile/Tag/ForClose.php index 292f0b46..cfc255e6 100644 --- a/src/Compile/Tag/ForClose.php +++ b/src/Compile/Tag/ForClose.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile For * Compiles the {for} {forelse} {/for} tags * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Forclose Class * - * @package Smarty - * @subpackage Compiler + + */ class ForClose extends Base { diff --git a/src/Compile/Tag/ForElse.php b/src/Compile/Tag/ForElse.php index 6df6a8cb..916beec7 100644 --- a/src/Compile/Tag/ForElse.php +++ b/src/Compile/Tag/ForElse.php @@ -7,8 +7,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Forelse Class * - * @package Smarty - * @subpackage Compiler + + */ class ForElse extends Base { diff --git a/src/Compile/Tag/ForTag.php b/src/Compile/Tag/ForTag.php index 5832bb1d..a66e50ce 100644 --- a/src/Compile/Tag/ForTag.php +++ b/src/Compile/Tag/ForTag.php @@ -7,8 +7,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile For Class * - * @package Smarty - * @subpackage Compiler + + */ class ForTag extends Base { diff --git a/src/Compile/Tag/ForeachClose.php b/src/Compile/Tag/ForeachClose.php index 33981499..513062bd 100644 --- a/src/Compile/Tag/ForeachClose.php +++ b/src/Compile/Tag/ForeachClose.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Foreach * Compiles the {foreach} {foreachelse} {/foreach} tags * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Foreachclose Class * - * @package Smarty - * @subpackage Compiler + + */ class ForeachClose extends Base { diff --git a/src/Compile/Tag/ForeachElse.php b/src/Compile/Tag/ForeachElse.php index a9df6a47..aac53359 100644 --- a/src/Compile/Tag/ForeachElse.php +++ b/src/Compile/Tag/ForeachElse.php @@ -7,8 +7,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Foreachelse Class * - * @package Smarty - * @subpackage Compiler + + */ class ForeachElse extends Base { diff --git a/src/Compile/Tag/ForeachSection.php b/src/Compile/Tag/ForeachSection.php index 588c128d..e066309a 100644 --- a/src/Compile/Tag/ForeachSection.php +++ b/src/Compile/Tag/ForeachSection.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile ForeachSection * Shared methods for {foreach} {section} tags * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile ForeachSection Class * - * @package Smarty - * @subpackage Compiler + + */ abstract class ForeachSection extends Base { diff --git a/src/Compile/Tag/ForeachTag.php b/src/Compile/Tag/ForeachTag.php index e528499b..19efdc3a 100644 --- a/src/Compile/Tag/ForeachTag.php +++ b/src/Compile/Tag/ForeachTag.php @@ -5,8 +5,8 @@ namespace Smarty\Compile\Tag; /** * Smarty Internal Plugin Compile Foreach Class * - * @package Smarty - * @subpackage Compiler + + */ class ForeachTag extends ForeachSection { diff --git a/src/Compile/Tag/FunctionClose.php b/src/Compile/Tag/FunctionClose.php index e55526f1..baf2547e 100644 --- a/src/Compile/Tag/FunctionClose.php +++ b/src/Compile/Tag/FunctionClose.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Function * Compiles the {function} {/function} tags * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Functionclose Class * - * @package Smarty - * @subpackage Compiler + + */ class FunctionClose extends Base { diff --git a/src/Compile/Tag/FunctionTag.php b/src/Compile/Tag/FunctionTag.php index b77cf6f4..da1d6a61 100644 --- a/src/Compile/Tag/FunctionTag.php +++ b/src/Compile/Tag/FunctionTag.php @@ -7,8 +7,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Function Class * - * @package Smarty - * @subpackage Compiler + + */ class FunctionTag extends Base { diff --git a/src/Compile/Tag/IfClose.php b/src/Compile/Tag/IfClose.php index 1a4af678..62737a3e 100644 --- a/src/Compile/Tag/IfClose.php +++ b/src/Compile/Tag/IfClose.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile If * Compiles the {if} {else} {elseif} {/if} tags * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Ifclose Class * - * @package Smarty - * @subpackage Compiler + + */ class IfClose extends Base { diff --git a/src/Compile/Tag/IfTag.php b/src/Compile/Tag/IfTag.php index f6c9495f..1e30a1c7 100644 --- a/src/Compile/Tag/IfTag.php +++ b/src/Compile/Tag/IfTag.php @@ -7,8 +7,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile If Class * - * @package Smarty - * @subpackage Compiler + + */ class IfTag extends Base { diff --git a/src/Compile/Tag/IncludeTag.php b/src/Compile/Tag/IncludeTag.php index f0c8acff..4fc18a21 100644 --- a/src/Compile/Tag/IncludeTag.php +++ b/src/Compile/Tag/IncludeTag.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Include * Compiles the {include} tag * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -18,8 +18,8 @@ use Smarty\Template\Compiled; /** * Smarty Internal Plugin Compile Include Class * - * @package Smarty - * @subpackage Compiler + + */ class IncludeTag extends Base { diff --git a/src/Compile/Tag/Inheritance.php b/src/Compile/Tag/Inheritance.php index b6064ee6..49c8173f 100644 --- a/src/Compile/Tag/Inheritance.php +++ b/src/Compile/Tag/Inheritance.php @@ -8,16 +8,16 @@ use Smarty\Compile\Base; * Smarty Internal Plugin Compile Shared Inheritance * Shared methods for {extends} and {block} tags * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ /** * Smarty Internal Plugin Compile Shared Inheritance Class * - * @package Smarty - * @subpackage Compiler + + */ abstract class Inheritance extends Base { diff --git a/src/Compile/Tag/Ldelim.php b/src/Compile/Tag/Ldelim.php index 2c9328a8..530592da 100644 --- a/src/Compile/Tag/Ldelim.php +++ b/src/Compile/Tag/Ldelim.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Ldelim * Compiles the {ldelim} tag * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Ldelim Class * - * @package Smarty - * @subpackage Compiler + + */ class Ldelim extends Base { diff --git a/src/Compile/Tag/MakeNocache.php b/src/Compile/Tag/MakeNocache.php index 36f3c5b2..caa8eb52 100644 --- a/src/Compile/Tag/MakeNocache.php +++ b/src/Compile/Tag/MakeNocache.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Make_Nocache * Compiles the {make_nocache} tag * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Make_Nocache Class * - * @package Smarty - * @subpackage Compiler + + */ class MakeNocache extends Base { diff --git a/src/Compile/Tag/Nocache.php b/src/Compile/Tag/Nocache.php index 22f0db54..0f12f189 100644 --- a/src/Compile/Tag/Nocache.php +++ b/src/Compile/Tag/Nocache.php @@ -7,8 +7,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Nocache Class * - * @package Smarty - * @subpackage Compiler + + */ class Nocache extends Base { diff --git a/src/Compile/Tag/NocacheClose.php b/src/Compile/Tag/NocacheClose.php index f1569576..0d968f3c 100644 --- a/src/Compile/Tag/NocacheClose.php +++ b/src/Compile/Tag/NocacheClose.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Nocache * Compiles the {nocache} {/nocache} tags. * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Nocacheclose Class * - * @package Smarty - * @subpackage Compiler + + */ class NocacheClose extends Base { diff --git a/src/Compile/Tag/Rdelim.php b/src/Compile/Tag/Rdelim.php index e174a8a4..267a4a96 100644 --- a/src/Compile/Tag/Rdelim.php +++ b/src/Compile/Tag/Rdelim.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Rdelim * Compiles the {rdelim} tag * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -13,8 +13,8 @@ namespace Smarty\Compile\Tag; /** * Smarty Internal Plugin Compile Rdelim Class * - * @package Smarty - * @subpackage Compiler + + */ class Rdelim extends Ldelim { diff --git a/src/Compile/Tag/Section.php b/src/Compile/Tag/Section.php index 9eec84ab..f51cc3ff 100644 --- a/src/Compile/Tag/Section.php +++ b/src/Compile/Tag/Section.php @@ -5,8 +5,8 @@ namespace Smarty\Compile\Tag; /** * Smarty Internal Plugin Compile Section Class * - * @package Smarty - * @subpackage Compiler + + */ class Section extends ForeachSection { diff --git a/src/Compile/Tag/SectionClose.php b/src/Compile/Tag/SectionClose.php index 1aede5d6..4d8cafef 100644 --- a/src/Compile/Tag/SectionClose.php +++ b/src/Compile/Tag/SectionClose.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Section * Compiles the {section} {sectionelse} {/section} tags * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Sectionclose Class * - * @package Smarty - * @subpackage Compiler + + */ class SectionClose extends Base { diff --git a/src/Compile/Tag/SectionElse.php b/src/Compile/Tag/SectionElse.php index fad50279..189aecd2 100644 --- a/src/Compile/Tag/SectionElse.php +++ b/src/Compile/Tag/SectionElse.php @@ -7,8 +7,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Sectionelse Class * - * @package Smarty - * @subpackage Compiler + + */ class SectionElse extends Base { diff --git a/src/Compile/Tag/Setfilter.php b/src/Compile/Tag/Setfilter.php index f828480c..037a701e 100644 --- a/src/Compile/Tag/Setfilter.php +++ b/src/Compile/Tag/Setfilter.php @@ -7,8 +7,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Setfilter Class * - * @package Smarty - * @subpackage Compiler + + */ class Setfilter extends Base { diff --git a/src/Compile/Tag/SetfilterClose.php b/src/Compile/Tag/SetfilterClose.php index 4626da24..273bb6fb 100644 --- a/src/Compile/Tag/SetfilterClose.php +++ b/src/Compile/Tag/SetfilterClose.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile Setfilter * Compiles code for setfilter tag * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Setfilterclose Class * - * @package Smarty - * @subpackage Compiler + + */ class SetfilterClose extends Base { diff --git a/src/Compile/Tag/WhileClose.php b/src/Compile/Tag/WhileClose.php index 3983e395..912170d4 100644 --- a/src/Compile/Tag/WhileClose.php +++ b/src/Compile/Tag/WhileClose.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Compile While * Compiles the {while} tag * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -15,8 +15,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile Whileclose Class * - * @package Smarty - * @subpackage Compiler + + */ class WhileClose extends Base { diff --git a/src/Compile/Tag/WhileTag.php b/src/Compile/Tag/WhileTag.php index df12f1f5..680c3de2 100644 --- a/src/Compile/Tag/WhileTag.php +++ b/src/Compile/Tag/WhileTag.php @@ -7,8 +7,8 @@ use Smarty\Compile\Base; /** * Smarty Internal Plugin Compile While Class * - * @package Smarty - * @subpackage Compiler + + */ class WhileTag extends Base { diff --git a/src/Compiler/Configfile.php b/src/Compiler/Configfile.php index 91cefb2d..6a7a0381 100644 --- a/src/Compiler/Configfile.php +++ b/src/Compiler/Configfile.php @@ -4,8 +4,8 @@ * This is the config file compiler class. It calls the lexer and parser to * perform the compiling. * - * @package Smarty - * @subpackage Config + + * @author Uwe Tews */ @@ -19,8 +19,8 @@ use Smarty\CompilerException; /** * Main config file compiler class * - * @package Smarty - * @subpackage Config + + */ class Configfile extends BaseCompiler { diff --git a/src/Compiler/Template.php b/src/Compiler/Template.php index 69bef1c1..b4de6de4 100644 --- a/src/Compiler/Template.php +++ b/src/Compiler/Template.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Smarty Template Compiler Base * This file contains the basic classes and methods for compiling Smarty templates with lexer/parser * - * @package Smarty - * @subpackage Compiler + + * @author Uwe Tews */ @@ -31,8 +31,8 @@ use function substr; /** * Class SmartyTemplateCompiler * - * @package Smarty - * @subpackage Compiler + + */ class Template extends BaseCompiler { diff --git a/src/CompilerException.php b/src/CompilerException.php index 7db8cb07..e3d67b46 100644 --- a/src/CompilerException.php +++ b/src/CompilerException.php @@ -5,7 +5,7 @@ namespace Smarty; /** * Smarty compiler exception class * - * @package Smarty + */ class CompilerException extends Exception { diff --git a/src/Data.php b/src/Data.php index a9d7e35e..f411aaea 100644 --- a/src/Data.php +++ b/src/Data.php @@ -6,8 +6,8 @@ namespace Smarty; * Smarty Internal Plugin Data * This file contains the basic classes and methods for template and variable creation * - * @package Smarty - * @subpackage Template + + * @author Uwe Tews */ diff --git a/src/DataObject.php b/src/DataObject.php index 2f80c989..f5bcb78b 100644 --- a/src/DataObject.php +++ b/src/DataObject.php @@ -3,8 +3,8 @@ * Smarty Plugin Data * This file contains the data object * - * @package Smarty - * @subpackage Template + + * @author Uwe Tews */ @@ -16,8 +16,8 @@ use Smarty\Exception; * class for the Smarty data object * The Smarty data object will hold Smarty variables in the current scope * - * @package Smarty - * @subpackage Template + + */ class DataObject extends Data { diff --git a/src/Debug.php b/src/Debug.php index 714c8411..bb7275da 100644 --- a/src/Debug.php +++ b/src/Debug.php @@ -6,16 +6,16 @@ namespace Smarty; * Smarty Internal Plugin Debug * Class to collect data for the Smarty Debugging Console * - * @package Smarty - * @subpackage Debug + + * @author Uwe Tews */ /** * Smarty Internal Plugin Debug Class * - * @package Smarty - * @subpackage Debug + + */ class Debug extends Data { diff --git a/src/ErrorHandler.php b/src/ErrorHandler.php index 815038c7..661950ae 100644 --- a/src/ErrorHandler.php +++ b/src/ErrorHandler.php @@ -5,8 +5,8 @@ namespace Smarty; /** * Smarty error handler to fix new error levels in PHP8 for backwards compatibility * - * @package Smarty - * @subpackage PluginsInternal + + * @author Simon Wisselink * */ diff --git a/src/Extension/DefaultExtension.php b/src/Extension/DefaultExtension.php index f5fa2566..e6291e3b 100644 --- a/src/Extension/DefaultExtension.php +++ b/src/Extension/DefaultExtension.php @@ -3,32 +3,58 @@ namespace Smarty\Extension; class DefaultExtension extends Base { + + private $modifiers = []; + + private $functionHandlers = []; + + private $blockHandlers = []; + + public function __construct() { + // modifiers + $this->modifiers['cat'] = new \Smarty\Compile\Modifier\CatModifierCompiler(); + $this->modifiers['count_characters'] = new \Smarty\Compile\Modifier\CountCharactersModifierCompiler(); + $this->modifiers['count_paragraphs'] = new \Smarty\Compile\Modifier\CountParagraphsModifierCompiler(); + $this->modifiers['count_sentences'] = new \Smarty\Compile\Modifier\CountSentencesModifierCompiler(); + $this->modifiers['count_words'] = new \Smarty\Compile\Modifier\CountWordsModifierCompiler(); + $this->modifiers['default'] = new \Smarty\Compile\Modifier\DefaultModifierCompiler(); + $this->modifiers['escape'] = new \Smarty\Compile\Modifier\EscapeModifierCompiler(); + $this->modifiers['from_charset'] = new \Smarty\Compile\Modifier\FromCharsetModifierCompiler(); + $this->modifiers['indent'] = new \Smarty\Compile\Modifier\IndentModifierCompiler(); + $this->modifiers['lower'] = new \Smarty\Compile\Modifier\LowerModifierCompiler(); + $this->modifiers['nl2br'] = new \Smarty\Compile\Modifier\Nl2brModifierCompiler(); + $this->modifiers['noprint'] = new \Smarty\Compile\Modifier\NoPrintModifierCompiler(); + $this->modifiers['round'] = new \Smarty\Compile\Modifier\RoundModifierCompiler(); + $this->modifiers['str_repeat'] = new \Smarty\Compile\Modifier\StrRepeatModifierCompiler(); + $this->modifiers['string_format'] = new \Smarty\Compile\Modifier\StringFormatModifierCompiler(); + $this->modifiers['strip'] = new \Smarty\Compile\Modifier\StripModifierCompiler(); + $this->modifiers['strip_tags'] = new \Smarty\Compile\Modifier\StripTagsModifierCompiler(); + $this->modifiers['strlen'] = new \Smarty\Compile\Modifier\StrlenModifierCompiler(); + $this->modifiers['to_charset'] = new \Smarty\Compile\Modifier\ToCharsetModifierCompiler(); + $this->modifiers['unescape'] = new \Smarty\Compile\Modifier\UnescapeModifierCompiler(); + $this->modifiers['upper'] = new \Smarty\Compile\Modifier\UpperModifierCompiler(); + $this->modifiers['wordwrap'] = new \Smarty\Compile\Modifier\WordWrapModifierCompiler(); + + // function handlers + $this->functionHandlers['counter'] = new \Smarty\FunctionHandler\Counter(); + $this->functionHandlers['cycle'] = new \Smarty\FunctionHandler\Cycle(); + $this->functionHandlers['fetch'] = new \Smarty\FunctionHandler\Fetch(); + $this->functionHandlers['html_checkboxes'] = new \Smarty\FunctionHandler\HtmlCheckboxes(); + $this->functionHandlers['html_image'] = new \Smarty\FunctionHandler\HtmlImage(); + $this->functionHandlers['html_options'] = new \Smarty\FunctionHandler\HtmlOptions(); + $this->functionHandlers['html_radios'] = new \Smarty\FunctionHandler\HtmlRadios(); + $this->functionHandlers['html_select_date'] = new \Smarty\FunctionHandler\HtmlSelectDate(); + $this->functionHandlers['html_select_time'] = new \Smarty\FunctionHandler\HtmlSelectTime(); + $this->functionHandlers['html_table'] = new \Smarty\FunctionHandler\HtmlTable(); + $this->functionHandlers['mailto'] = new \Smarty\FunctionHandler\Mailto(); + $this->functionHandlers['math'] = new \Smarty\FunctionHandler\Math(); + + // blockhandlers + $this->blockHandlers['textformat'] = new \Smarty\BlockHandler\TextFormat(); + } + public function getModifierCompiler(string $modifier): ?\Smarty\Compile\Modifier\ModifierCompilerInterface { - switch ($modifier) { - case 'cat': return new \Smarty\Compile\Modifier\CatModifierCompiler(); - case 'count_characters': return new \Smarty\Compile\Modifier\CountCharactersModifierCompiler(); - case 'count_paragraphs': return new \Smarty\Compile\Modifier\CountParagraphsModifierCompiler(); - case 'count_sentences': return new \Smarty\Compile\Modifier\CountSentencesModifierCompiler(); - case 'count_words': return new \Smarty\Compile\Modifier\CountWordsModifierCompiler(); - case 'default': return new \Smarty\Compile\Modifier\DefaultModifierCompiler(); - case 'escape': return new \Smarty\Compile\Modifier\EscapeModifierCompiler(); - case 'from_charset': return new \Smarty\Compile\Modifier\FromCharsetModifierCompiler(); - case 'indent': return new \Smarty\Compile\Modifier\IndentModifierCompiler(); - case 'lower': return new \Smarty\Compile\Modifier\LowerModifierCompiler(); - case 'nl2br': return new \Smarty\Compile\Modifier\Nl2brModifierCompiler(); - case 'noprint': return new \Smarty\Compile\Modifier\NoPrintModifierCompiler(); - case 'round': return new \Smarty\Compile\Modifier\RoundModifierCompiler(); - case 'str_repeat': return new \Smarty\Compile\Modifier\StrRepeatModifierCompiler(); - case 'string_format': return new \Smarty\Compile\Modifier\StringFormatModifierCompiler(); - case 'strip': return new \Smarty\Compile\Modifier\StripModifierCompiler(); - case 'strip_tags': return new \Smarty\Compile\Modifier\StripTagsModifierCompiler(); - case 'strlen': return new \Smarty\Compile\Modifier\StrlenModifierCompiler(); - case 'to_charset': return new \Smarty\Compile\Modifier\ToCharsetModifierCompiler(); - case 'unescape': return new \Smarty\Compile\Modifier\UnescapeModifierCompiler(); - case 'upper': return new \Smarty\Compile\Modifier\UpperModifierCompiler(); - case 'wordwrap': return new \Smarty\Compile\Modifier\WordWrapModifierCompiler(); - } - return null; + return $this->modifiers[$modifier] ?? null; } public function getModifierCallback(string $modifierName) { @@ -50,28 +76,11 @@ class DefaultExtension extends Base { } public function getFunctionHandler(string $functionName): ?\Smarty\FunctionHandler\FunctionHandlerInterface { - switch ($functionName) { - case 'counter': return new \Smarty\FunctionHandler\Counter(); - case 'cycle': return new \Smarty\FunctionHandler\Cycle(); - case 'fetch': return new \Smarty\FunctionHandler\Fetch(); - case 'html_checkboxes': return new \Smarty\FunctionHandler\HtmlCheckboxes(); - case 'html_image': return new \Smarty\FunctionHandler\HtmlImage(); - case 'html_options': return new \Smarty\FunctionHandler\HtmlOptions(); - case 'html_radios': return new \Smarty\FunctionHandler\HtmlRadios(); - case 'html_select_date': return new \Smarty\FunctionHandler\HtmlSelectDate(); - case 'html_select_time': return new \Smarty\FunctionHandler\HtmlSelectTime(); - case 'html_table': return new \Smarty\FunctionHandler\HtmlTable(); - case 'mailto': return new \Smarty\FunctionHandler\Mailto(); - case 'math': return new \Smarty\FunctionHandler\Math(); - } - return null; + return $this->functionHandlers[$functionName] ?? null; } public function getBlockHandler(string $blockTagName): ?\Smarty\BlockHandler\BlockHandlerInterface { - switch ($blockTagName) { - case 'textformat': return new \Smarty\BlockHandler\TextFormat(); - } - return null; + return $this->blockHandlers[$blockTagName] ?? null; } /** diff --git a/src/FunctionHandler/Counter.php b/src/FunctionHandler/Counter.php index ca89cb02..c6f9fdbe 100644 --- a/src/FunctionHandler/Counter.php +++ b/src/FunctionHandler/Counter.php @@ -20,13 +20,14 @@ use Smarty\Template; */ class Counter extends Base { + private $counters = []; + public function handle($params, Template $template) { - static $counters = []; $name = (isset($params['name'])) ? $params['name'] : 'default'; - if (!isset($counters[$name])) { - $counters[$name] = ['start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1]; + if (!isset($this->counters[$name])) { + $this->counters[$name] = ['start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1]; } - $counter =& $counters[$name]; + $counter =& $this->counters[$name]; if (isset($params['start'])) { $counter['start'] = $counter['count'] = (int)$params['start']; } diff --git a/src/ParseTree/Base.php b/src/ParseTree/Base.php index fc21cc23..247271aa 100644 --- a/src/ParseTree/Base.php +++ b/src/ParseTree/Base.php @@ -6,15 +6,15 @@ namespace Smarty\ParseTree; * Smarty Internal Plugin Templateparser ParseTree * These are classes to build parsetree in the template parser * - * @package Smarty - * @subpackage Compiler + + * @author Thue Kristensen * @author Uwe Tews */ /** - * @package Smarty - * @subpackage Compiler + + * @ignore */ abstract class Base diff --git a/src/ParseTree/Code.php b/src/ParseTree/Code.php index 0109e1ef..b39f22c8 100644 --- a/src/ParseTree/Code.php +++ b/src/ParseTree/Code.php @@ -6,8 +6,8 @@ namespace Smarty\ParseTree; * Smarty Internal Plugin Templateparser Parse Tree * These are classes to build parse trees in the template parser * - * @package Smarty - * @subpackage Compiler + + * @author Thue Kristensen * @author Uwe Tews */ @@ -15,8 +15,8 @@ namespace Smarty\ParseTree; /** * Code fragment inside a tag . * - * @package Smarty - * @subpackage Compiler + + * @ignore */ class Code extends Base diff --git a/src/ParseTree/Dq.php b/src/ParseTree/Dq.php index 8365bfd1..c8db13fa 100644 --- a/src/ParseTree/Dq.php +++ b/src/ParseTree/Dq.php @@ -4,16 +4,16 @@ namespace Smarty\ParseTree; /** * Double-quoted string inside a tag. * - * @package Smarty - * @subpackage Compiler + + * @ignore */ /** * Double quoted string inside a tag. * - * @package Smarty - * @subpackage Compiler + + * @ignore */ class Dq extends Base diff --git a/src/ParseTree/DqContent.php b/src/ParseTree/DqContent.php index 54b29904..f0a4b069 100644 --- a/src/ParseTree/DqContent.php +++ b/src/ParseTree/DqContent.php @@ -5,8 +5,8 @@ namespace Smarty\ParseTree; * Smarty Internal Plugin Templateparser Parse Tree * These are classes to build parse tree in the template parser * - * @package Smarty - * @subpackage Compiler + + * @author Thue Kristensen * @author Uwe Tews */ @@ -14,8 +14,8 @@ namespace Smarty\ParseTree; /** * Raw chars as part of a double-quoted string. * - * @package Smarty - * @subpackage Compiler + + * @ignore */ class DqContent extends Base diff --git a/src/ParseTree/Tag.php b/src/ParseTree/Tag.php index ca925537..9c52044a 100644 --- a/src/ParseTree/Tag.php +++ b/src/ParseTree/Tag.php @@ -6,8 +6,8 @@ namespace Smarty\ParseTree; * Smarty Internal Plugin Templateparser Parse Tree * These are classes to build parse tree in the template parser * - * @package Smarty - * @subpackage Compiler + + * @author Thue Kristensen * @author Uwe Tews */ @@ -15,8 +15,8 @@ namespace Smarty\ParseTree; /** * A complete smarty tag. * - * @package Smarty - * @subpackage Compiler + + * @ignore */ class Tag extends Base diff --git a/src/ParseTree/Template.php b/src/ParseTree/Template.php index 1a70a4a8..47096392 100644 --- a/src/ParseTree/Template.php +++ b/src/ParseTree/Template.php @@ -6,8 +6,8 @@ namespace Smarty\ParseTree; * Smarty Internal Plugin Templateparser Parse Tree * These are classes to build parse tree in the template parser * - * @package Smarty - * @subpackage Compiler + + * @author Thue Kristensen * @author Uwe Tews */ @@ -15,8 +15,8 @@ namespace Smarty\ParseTree; /** * Template element * - * @package Smarty - * @subpackage Compiler + + * @ignore */ class Template extends Base diff --git a/src/ParseTree/Text.php b/src/ParseTree/Text.php index 183b6970..e6131407 100644 --- a/src/ParseTree/Text.php +++ b/src/ParseTree/Text.php @@ -6,14 +6,14 @@ namespace Smarty\ParseTree; * Smarty Internal Plugin Templateparser Parse Tree * These are classes to build parse tree in the template parser * - * @package Smarty - * @subpackage Compiler + + * @author Thue Kristensen * @author Uwe Tews * * * template text - * @package Smarty - * @subpackage Compiler + + * @ignore */ class Text extends Base diff --git a/src/Resource/BasePlugin.php b/src/Resource/BasePlugin.php index 42254f59..fce26a75 100644 --- a/src/Resource/BasePlugin.php +++ b/src/Resource/BasePlugin.php @@ -7,8 +7,8 @@ use Smarty\Smarty; /** * Smarty Resource Plugin * - * @package Smarty - * @subpackage TemplateResources + + * @author Rodney Rehm */ @@ -16,8 +16,8 @@ use Smarty\Smarty; * Smarty Resource Plugin * Base implementation for resource plugins * - * @package Smarty - * @subpackage TemplateResources + + * * @method renderUncompiled(\Smarty\Template\Source $source, \Smarty\Template $_template) * @method populateCompiledFilepath(\Smarty\Template\Compiled $compiled, \Smarty\Template $_template) diff --git a/src/Resource/CustomPlugin.php b/src/Resource/CustomPlugin.php index e0b32756..fa2675ff 100644 --- a/src/Resource/CustomPlugin.php +++ b/src/Resource/CustomPlugin.php @@ -2,8 +2,8 @@ /** * Smarty Resource Plugin * - * @package Smarty - * @subpackage TemplateResources + + * @author Rodney Rehm */ @@ -17,8 +17,8 @@ use Smarty\Exception; * Smarty Resource Plugin * Wrapper Implementation for custom resource plugins * - * @package Smarty - * @subpackage TemplateResources + + */ abstract class CustomPlugin extends BasePlugin { diff --git a/src/Resource/ExtendsPlugin.php b/src/Resource/ExtendsPlugin.php index 19a9598c..1f79d516 100644 --- a/src/Resource/ExtendsPlugin.php +++ b/src/Resource/ExtendsPlugin.php @@ -5,8 +5,8 @@ namespace Smarty\Resource; /** * Smarty Internal Plugin Resource Extends * - * @package Smarty - * @subpackage TemplateResources + + * @author Uwe Tews * @author Rodney Rehm */ @@ -15,8 +15,8 @@ namespace Smarty\Resource; * Smarty Internal Plugin Resource Extends * Implements the file system as resource for Smarty which {extend}s a chain of template files templates * - * @package Smarty - * @subpackage TemplateResources + + */ class ExtendsPlugin extends BasePlugin { diff --git a/src/Resource/FilePlugin.php b/src/Resource/FilePlugin.php index 059c297a..2972a653 100644 --- a/src/Resource/FilePlugin.php +++ b/src/Resource/FilePlugin.php @@ -2,8 +2,8 @@ /** * Smarty Internal Plugin Resource File * - * @package Smarty - * @subpackage TemplateResources + + * @author Uwe Tews * @author Rodney Rehm */ @@ -18,8 +18,8 @@ use Smarty\Exception; * Smarty Internal Plugin Resource File * Implements the file system as resource for Smarty templates * - * @package Smarty - * @subpackage TemplateResources + + */ class FilePlugin extends BasePlugin { diff --git a/src/Resource/PhpPlugin.php b/src/Resource/PhpPlugin.php index 160d8133..1b146a60 100644 --- a/src/Resource/PhpPlugin.php +++ b/src/Resource/PhpPlugin.php @@ -11,8 +11,8 @@ use Smarty\Exception; * Smarty Internal Plugin Resource PHP * Implements the file system as resource for PHP templates * - * @package Smarty - * @subpackage TemplateResources + + * @author Uwe Tews * @author Rodney Rehm */ diff --git a/src/Resource/RecompiledPlugin.php b/src/Resource/RecompiledPlugin.php index a16ab990..17e92605 100644 --- a/src/Resource/RecompiledPlugin.php +++ b/src/Resource/RecompiledPlugin.php @@ -2,8 +2,8 @@ /** * Smarty Resource Plugin * - * @package Smarty - * @subpackage TemplateResources + + * @author Rodney Rehm */ @@ -17,8 +17,8 @@ use Smarty\Template\Compiled; * Smarty Resource Plugin * Base implementation for resource plugins that don't compile cache * - * @package Smarty - * @subpackage TemplateResources + + */ abstract class RecompiledPlugin extends BasePlugin { diff --git a/src/Resource/StreamPlugin.php b/src/Resource/StreamPlugin.php index 3173b545..0cf8512d 100644 --- a/src/Resource/StreamPlugin.php +++ b/src/Resource/StreamPlugin.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Resource Stream * Implements the streams as resource for Smarty template * - * @package Smarty - * @subpackage TemplateResources + + * @author Uwe Tews * @author Rodney Rehm */ @@ -20,8 +20,8 @@ use Smarty\Template\Source; * Implements the streams as resource for Smarty template * * @link https://php.net/streams - * @package Smarty - * @subpackage TemplateResources + + */ class StreamPlugin extends RecompiledPlugin { diff --git a/src/Resource/StringEval.php b/src/Resource/StringEval.php index 157c991e..22003f6b 100644 --- a/src/Resource/StringEval.php +++ b/src/Resource/StringEval.php @@ -7,8 +7,8 @@ use Smarty\Smarty; /** * Smarty Internal Plugin Resource Eval * - * @package Smarty - * @subpackage TemplateResources + + * @author Uwe Tews * @author Rodney Rehm */ @@ -18,8 +18,8 @@ use Smarty\Smarty; * Implements the strings as resource for Smarty template * {@internal unlike string-resources the compiled state of eval-resources is NOT saved for subsequent access}} * - * @package Smarty - * @subpackage TemplateResources + + */ class StringEval extends RecompiledPlugin { diff --git a/src/Resource/StringPlugin.php b/src/Resource/StringPlugin.php index c8f442e1..12931bd9 100644 --- a/src/Resource/StringPlugin.php +++ b/src/Resource/StringPlugin.php @@ -2,8 +2,8 @@ /** * Smarty Internal Plugin Resource String * - * @package Smarty - * @subpackage TemplateResources + + * @author Uwe Tews * @author Rodney Rehm */ @@ -18,8 +18,8 @@ use Smarty\Template\Source; * Implements the strings as resource for Smarty template * {@internal unlike eval-resources the compiled state of string-resources is saved for subsequent access}} * - * @package Smarty - * @subpackage TemplateResources + + */ class StringPlugin extends BasePlugin { diff --git a/src/Resource/UncompiledPlugin.php b/src/Resource/UncompiledPlugin.php index 2793d694..fe955b27 100644 --- a/src/Resource/UncompiledPlugin.php +++ b/src/Resource/UncompiledPlugin.php @@ -2,8 +2,8 @@ /** * Smarty Resource Plugin * - * @package Smarty - * @subpackage TemplateResources + + * @author Rodney Rehm */ @@ -17,8 +17,8 @@ use Smarty\Template\Compiled; * Smarty Resource Plugin * Base implementation for resource plugins that don't use the compiler * - * @package Smarty - * @subpackage TemplateResources + + */ abstract class UncompiledPlugin extends BasePlugin { diff --git a/src/Runtime/Block.php b/src/Runtime/Block.php index 161fd3a3..90eab9cb 100644 --- a/src/Runtime/Block.php +++ b/src/Runtime/Block.php @@ -5,8 +5,8 @@ namespace Smarty\Runtime; /** * Smarty {block} tag class * - * @package Smarty - * @subpackage PluginsInternal + + * @author Uwe Tews */ class Block diff --git a/src/Runtime/CaptureRuntime.php b/src/Runtime/CaptureRuntime.php index 24a1b717..fd84c3d4 100644 --- a/src/Runtime/CaptureRuntime.php +++ b/src/Runtime/CaptureRuntime.php @@ -6,8 +6,8 @@ use Smarty\Template; /** * Runtime Extension Capture * - * @package Smarty - * @subpackage PluginsInternal + + * @author Uwe Tews */ class CaptureRuntime { diff --git a/src/Runtime/ForeachRuntime.php b/src/Runtime/ForeachRuntime.php index 85d34d49..d8791ff6 100644 --- a/src/Runtime/ForeachRuntime.php +++ b/src/Runtime/ForeachRuntime.php @@ -6,8 +6,8 @@ use Smarty\Template; /** * Foreach Runtime Methods count(), init(), restore() * - * @package Smarty - * @subpackage PluginsInternal + + * @author Uwe Tews */ class ForeachRuntime { diff --git a/src/Runtime/InheritanceRuntime.php b/src/Runtime/InheritanceRuntime.php index 72663ef5..50e55b65 100644 --- a/src/Runtime/InheritanceRuntime.php +++ b/src/Runtime/InheritanceRuntime.php @@ -8,8 +8,8 @@ use Smarty\Exception; /** * Inheritance Runtime Methods processBlock, endChild, init * - * @package Smarty - * @subpackage PluginsInternal + + * @author Uwe Tews **/ class InheritanceRuntime { diff --git a/src/Runtime/MakeNocacheRuntime.php b/src/Runtime/MakeNocacheRuntime.php index 6be4c91c..bf755df9 100644 --- a/src/Runtime/MakeNocacheRuntime.php +++ b/src/Runtime/MakeNocacheRuntime.php @@ -6,8 +6,8 @@ use Smarty\Template; /** * {make_nocache} Runtime Methods save(), store() * - * @package Smarty - * @subpackage PluginsInternal + + * @author Uwe Tews */ class MakeNocacheRuntime { diff --git a/src/Runtime/TplFunctionRuntime.php b/src/Runtime/TplFunctionRuntime.php index 89f3a2c2..a28aa2ad 100644 --- a/src/Runtime/TplFunctionRuntime.php +++ b/src/Runtime/TplFunctionRuntime.php @@ -7,8 +7,8 @@ use Smarty\TemplateBase; /** * TplFunction Runtime Methods callTemplateFunction * - * @package Smarty - * @subpackage PluginsInternal + + * @author Uwe Tews **/ class TplFunctionRuntime { diff --git a/src/Security.php b/src/Security.php index 88379613..4385e276 100644 --- a/src/Security.php +++ b/src/Security.php @@ -2,8 +2,8 @@ /** * Smarty plugin * - * @package Smarty - * @subpackage Security + + * @author Uwe Tews */ diff --git a/src/Smarty.php b/src/Smarty.php index 35494bd4..2b732d60 100644 --- a/src/Smarty.php +++ b/src/Smarty.php @@ -38,13 +38,10 @@ use Smarty\Smarty\Runtime\TplFunctionRuntime; * smarty-discussion-subscribe@googlegroups.com * * @link https://www.smarty.net/ - * @copyright 2018 New Digital Group, Inc. - * @copyright 2018 Uwe Tews * @author Monte Ohrt * @author Uwe Tews * @author Rodney Rehm * @author Simon Wisselink - * @package Smarty */ /** @@ -1372,7 +1369,7 @@ class Smarty extends \Smarty\TemplateBase /** * Indicates if Smarty will mute errors for "undefined index", "undefined array key" and "trying to read property of null". - * @bool + * @return bool */ public function isMutingUndefinedOrNullWarnings(): bool { return $this->isMutingUndefinedOrNullWarnings; diff --git a/src/Template.php b/src/Template.php index e36da7aa..4598d0aa 100644 --- a/src/Template.php +++ b/src/Template.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Template * This file contains the Smarty template engine * - * @package Smarty - * @subpackage Template + + * @author Uwe Tews */ diff --git a/src/Template/Cached.php b/src/Template/Cached.php index 005a94f6..308d7130 100644 --- a/src/Template/Cached.php +++ b/src/Template/Cached.php @@ -10,8 +10,8 @@ use Smarty\Template\Source; * Smarty Resource Data Object * Cache Data Container for Template Files * - * @package Smarty - * @subpackage TemplateResources + + * @author Rodney Rehm */ class Cached extends ResourceBase { diff --git a/src/Template/Compiled.php b/src/Template/Compiled.php index 54036089..259b56c7 100644 --- a/src/Template/Compiled.php +++ b/src/Template/Compiled.php @@ -8,8 +8,8 @@ use Smarty\Template; * Smarty Resource Data Object * Meta Data Container for Template Files * - * @package Smarty - * @subpackage TemplateResources + + * @author Rodney Rehm * @property string $content compiled content */ diff --git a/src/Template/ResourceBase.php b/src/Template/ResourceBase.php index a5ce24fb..6f786418 100644 --- a/src/Template/ResourceBase.php +++ b/src/Template/ResourceBase.php @@ -7,8 +7,8 @@ use Smarty\Template; /** * Smarty Template Resource Base Object * - * @package Smarty - * @subpackage TemplateResources + + * @author Rodney Rehm */ abstract class ResourceBase { diff --git a/src/Template/Source.php b/src/Template/Source.php index ff71d176..75604835 100644 --- a/src/Template/Source.php +++ b/src/Template/Source.php @@ -10,8 +10,8 @@ use Smarty\Exception; * Smarty Resource Data Object * Meta Data Container for Template Files * - * @package Smarty - * @subpackage TemplateResources + + * @author Rodney Rehm */ class Source { diff --git a/src/TemplateBase.php b/src/TemplateBase.php index a3d8730a..6eb10fd3 100644 --- a/src/TemplateBase.php +++ b/src/TemplateBase.php @@ -3,8 +3,8 @@ * Smarty Internal Plugin Smarty Template Base * This file contains the basic shared methods for template handling * - * @package Smarty - * @subpackage Template + + * @author Uwe Tews */ diff --git a/src/TestInstall.php b/src/TestInstall.php index 401d633a..e24c3984 100644 --- a/src/TestInstall.php +++ b/src/TestInstall.php @@ -6,16 +6,16 @@ namespace Smarty; * Smarty Internal TestInstall * Test Smarty installation * - * @package Smarty - * @subpackage Utilities + + * @author Uwe Tews */ /** * TestInstall class * - * @package Smarty - * @subpackage Utilities + + */ class TestInstall { diff --git a/src/UndefinedVariable.php b/src/UndefinedVariable.php index fed1d9b5..ca728bef 100644 --- a/src/UndefinedVariable.php +++ b/src/UndefinedVariable.php @@ -6,8 +6,8 @@ namespace Smarty; * class for undefined variable object * This class defines an object for undefined variable handling * - * @package Smarty - * @subpackage Template + + */ class UndefinedVariable extends Variable { diff --git a/src/Variable.php b/src/Variable.php index 55676685..eb7449eb 100644 --- a/src/Variable.php +++ b/src/Variable.php @@ -6,8 +6,8 @@ namespace Smarty; * class for the Smarty variable object * This class defines the Smarty variable object * - * @package Smarty - * @subpackage Template + + */ #[\AllowDynamicProperties] class Variable