diff --git a/src/Compiler/smarty_internal_templatecompilerbase.php b/src/Compiler/smarty_internal_templatecompilerbase.php index 2c41d59e..64c52fcd 100644 --- a/src/Compiler/smarty_internal_templatecompilerbase.php +++ b/src/Compiler/smarty_internal_templatecompilerbase.php @@ -8,6 +8,8 @@ * @author Uwe Tews */ +use Smarty\Compile\Base; + /** * Main abstract compiler class * @@ -712,9 +714,9 @@ abstract class Smarty_Internal_TemplateCompilerBase * @return bool|string compiled code or false * @throws \SmartyCompilerException */ - public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null) + private function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null) { - /* @var Smarty_Internal_CompileBase $tagCompiler */ + /* @var Base $tagCompiler */ $tagCompiler = $this->getTagCompiler($tag); // compile this tag return $tagCompiler === false ? false : $tagCompiler->compile($args, $this, $param1, $param2, $param3); @@ -723,21 +725,35 @@ abstract class Smarty_Internal_TemplateCompilerBase /** * lazy loads internal compile plugin for tag compile objects cached for reuse. * - * class name format: Smarty_Internal_Compile_TagName - * plugin filename format: Smarty_Internal_TagName.php + * class name format: \Smarty\Compile\TagName * * @param string $tag tag name * - * @return bool|\Smarty_Internal_CompileBase tag compiler object or false if not found + * @return bool|\Smarty\Compile\Base tag compiler object or false if not found */ public function getTagCompiler($tag) { + + static $map = [ + 'break' => \Smarty\Compile\BreakTag::class, + 'config_load' => \Smarty\Compile\ConfigLoad::class, + 'eval' => \Smarty\Compile\EvalTag::class, + 'include' => \Smarty\Compile\IncludeTag::class, + 'while' => \Smarty\Compile\WhileTag::class, + 'private_modifier' => \Smarty\Compile\PrivateModifier::class, + ]; + // re-use object if already exists if (!isset(self::$_tag_objects[ $tag ])) { - // lazy load internal compiler plugin - $_tag = explode('_', $tag); - $_tag = array_map('smarty_ucfirst_ascii', $_tag); - $class_name = 'Smarty_Internal_Compile_' . implode('_', $_tag); + + if (isset($map[$tag])) { + $class_name = $map[$tag]; + } else { + $_tag = explode('_', $tag); + $_tag = array_map('smarty_ucfirst_ascii', $_tag); + $class_name = '\\Smarty\\Compile\\' . implode('_', $_tag); + } + if (class_exists($class_name) && (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this)) ) { diff --git a/src/ParseTree/Dq.php b/src/ParseTree/Dq.php index 2099445b..72de82e5 100644 --- a/src/ParseTree/Dq.php +++ b/src/ParseTree/Dq.php @@ -2,7 +2,7 @@ namespace Smarty\ParseTree; /** - * Double quoted string inside a tag. + * Double-quoted string inside a tag. * * @package Smarty * @subpackage Compiler @@ -19,7 +19,7 @@ namespace Smarty\ParseTree; class Dq extends Base { /** - * Create parse tree buffer for double quoted string subtrees + * Create parse tree buffer for double-quoted string subtrees * * @param object $parser parser object * @param Base $subtree parse tree buffer diff --git a/src/ParseTree/DqContent.php b/src/ParseTree/DqContent.php index 8f3b78d7..d3dd0817 100644 --- a/src/ParseTree/DqContent.php +++ b/src/ParseTree/DqContent.php @@ -12,7 +12,7 @@ namespace Smarty\ParseTree; */ /** - * Raw chars as part of a double quoted string. + * Raw chars as part of a double-quoted string. * * @package Smarty * @subpackage Compiler @@ -31,7 +31,7 @@ class DqContent extends Base } /** - * Return content as double quoted string + * Return content as double-quoted string * * @param \Smarty_Internal_Templateparser $parser *