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.

This commit is contained in:
Simon Wisselink
2023-01-05 23:07:45 +01:00
parent f07e342d61
commit 608a400e66
100 changed files with 355 additions and 353 deletions

View File

@@ -2,7 +2,7 @@
/**
* Example Application
*
* @package Example-application
*/
$smarty = new \Smarty\Smarty;

View File

@@ -63,7 +63,7 @@ to invoke your custom CacheResource implementation.
* INDEX(`modified`)
* ) ENGINE = InnoDB;</pre>
*
* @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 {

View File

@@ -48,7 +48,7 @@ example.
* Demo data:
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
*
* @package Resource-examples
* @author Rodney Rehm
*/
class My_Resource_Mysql extends \Smarty\Resource\CustomPlugin {

View File

@@ -34,7 +34,7 @@ on the functions you are supposed to provide.
* Demo data:
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
*
* @package Resource-examples
* @author Rodney Rehm
*/
class My_Resource_Mysql extends \Smarty\Resource\Custom {

View File

@@ -44,7 +44,7 @@ on the functions you are supposed to provide.
* Demo data:
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
*
* @package Resource-examples
* @author Rodney Rehm
*/
class My_Resource_Mysql extends \Smarty\Resource\Custom {

View File

@@ -4,7 +4,7 @@
bootstrap="tests/Bootstrap.php"
colors="true"
backupGlobals="false"
backupStaticAttributes="true"
backupStaticAttributes="false"
forceCoversAnnotation="false"
processIsolation="false"
stopOnError="false"

View File

@@ -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

View File

@@ -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

View File

@@ -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
{

View File

@@ -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

View File

@@ -8,8 +8,8 @@ namespace Smarty\Compile;
/**
* This class does extend all internal compile plugins
*
* @package Smarty
* @subpackage Compiler
*/
abstract class Base implements CompilerInterface {

View File

@@ -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 {

View File

@@ -5,8 +5,8 @@ namespace Smarty\Compile;
/**
* This class does extend all internal compile plugins
*
* @package Smarty
* @subpackage Compiler
*/
interface CompilerInterface {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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
{

View File

@@ -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
{

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -7,8 +7,8 @@ use Smarty\Compile\Base;
/**
* Smarty Internal Plugin Compile Capture Class
*
* @package Smarty
* @subpackage Compiler
*/
class Capture extends Base {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -7,8 +7,8 @@ use Smarty\Compile\Base;
/**
* Smarty Internal Plugin Compile ElseIf Class
*
* @package Smarty
* @subpackage Compiler
*/
class ElseIfTag extends Base {

View File

@@ -7,8 +7,8 @@ use Smarty\Compile\Base;
/**
* Smarty Internal Plugin Compile Else Class
*
* @package Smarty
* @subpackage Compiler
*/
class ElseTag extends Base {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -7,8 +7,8 @@ use Smarty\Compile\Base;
/**
* Smarty Internal Plugin Compile Forelse Class
*
* @package Smarty
* @subpackage Compiler
*/
class ForElse extends Base {

View File

@@ -7,8 +7,8 @@ use Smarty\Compile\Base;
/**
* Smarty Internal Plugin Compile For Class
*
* @package Smarty
* @subpackage Compiler
*/
class ForTag extends Base {

View File

@@ -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 {

View File

@@ -7,8 +7,8 @@ use Smarty\Compile\Base;
/**
* Smarty Internal Plugin Compile Foreachelse Class
*
* @package Smarty
* @subpackage Compiler
*/
class ForeachElse extends Base {

View File

@@ -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 {

View File

@@ -5,8 +5,8 @@ namespace Smarty\Compile\Tag;
/**
* Smarty Internal Plugin Compile Foreach Class
*
* @package Smarty
* @subpackage Compiler
*/
class ForeachTag extends ForeachSection {

View File

@@ -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 {

View File

@@ -7,8 +7,8 @@ use Smarty\Compile\Base;
/**
* Smarty Internal Plugin Compile Function Class
*
* @package Smarty
* @subpackage Compiler
*/
class FunctionTag extends Base {

View File

@@ -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 {

View File

@@ -7,8 +7,8 @@ use Smarty\Compile\Base;
/**
* Smarty Internal Plugin Compile If Class
*
* @package Smarty
* @subpackage Compiler
*/
class IfTag extends Base {

View File

@@ -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 {

View File

@@ -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
{

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -7,8 +7,8 @@ use Smarty\Compile\Base;
/**
* Smarty Internal Plugin Compile Nocache Class
*
* @package Smarty
* @subpackage Compiler
*/
class Nocache extends Base {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -5,8 +5,8 @@ namespace Smarty\Compile\Tag;
/**
* Smarty Internal Plugin Compile Section Class
*
* @package Smarty
* @subpackage Compiler
*/
class Section extends ForeachSection {

View File

@@ -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 {

View File

@@ -7,8 +7,8 @@ use Smarty\Compile\Base;
/**
* Smarty Internal Plugin Compile Sectionelse Class
*
* @package Smarty
* @subpackage Compiler
*/
class SectionElse extends Base {

View File

@@ -7,8 +7,8 @@ use Smarty\Compile\Base;
/**
* Smarty Internal Plugin Compile Setfilter Class
*
* @package Smarty
* @subpackage Compiler
*/
class Setfilter extends Base {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -7,8 +7,8 @@ use Smarty\Compile\Base;
/**
* Smarty Internal Plugin Compile While Class
*
* @package Smarty
* @subpackage Compiler
*/
class WhileTag extends Base {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -5,7 +5,7 @@ namespace Smarty;
/**
* Smarty compiler exception class
*
* @package Smarty
*/
class CompilerException extends Exception {

View File

@@ -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
*/

View File

@@ -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 {

View File

@@ -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
{

View File

@@ -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
*
*/

View File

@@ -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;
}
/**

View File

@@ -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'];
}

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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
{

View File

@@ -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 {

View File

@@ -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
*/

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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
{

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -5,8 +5,8 @@ namespace Smarty\Runtime;
/**
* Smarty {block} tag class
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*/
class Block

View File

@@ -6,8 +6,8 @@ use Smarty\Template;
/**
* Runtime Extension Capture
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*/
class CaptureRuntime {

View File

@@ -6,8 +6,8 @@ use Smarty\Template;
/**
* Foreach Runtime Methods count(), init(), restore()
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*/
class ForeachRuntime {

View File

@@ -8,8 +8,8 @@ use Smarty\Exception;
/**
* Inheritance Runtime Methods processBlock, endChild, init
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
**/
class InheritanceRuntime {

View File

@@ -6,8 +6,8 @@ use Smarty\Template;
/**
* {make_nocache} Runtime Methods save(), store()
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
*/
class MakeNocacheRuntime {

View File

@@ -7,8 +7,8 @@ use Smarty\TemplateBase;
/**
* TplFunction Runtime Methods callTemplateFunction
*
* @package Smarty
* @subpackage PluginsInternal
* @author Uwe Tews
**/
class TplFunctionRuntime {

View File

@@ -2,8 +2,8 @@
/**
* Smarty plugin
*
* @package Smarty
* @subpackage Security
* @author Uwe Tews
*/

View File

@@ -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 <monte at ohrt dot com>
* @author Uwe Tews <uwe dot tews at gmail dot com>
* @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;

View File

@@ -3,8 +3,8 @@
* Smarty Internal Plugin Template
* This file contains the Smarty template engine
*
* @package Smarty
* @subpackage Template
* @author Uwe Tews
*/

View File

@@ -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 {

View File

@@ -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
*/

View File

@@ -7,8 +7,8 @@ use Smarty\Template;
/**
* Smarty Template Resource Base Object
*
* @package Smarty
* @subpackage TemplateResources
* @author Rodney Rehm
*/
abstract class ResourceBase {

View File

@@ -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 {

View File

@@ -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
*/

View File

@@ -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
{

View File

@@ -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 {

View File

@@ -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