diff --git a/TODO.txt b/TODO.txt index 26d5cc67..c0b575d4 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,3 +1,9 @@ +- [ ] \Smarty\Cacheresource\Base::load generates classnames that are now invalid +- [ ] \Smarty\Resource\BasePlugin::load generates classnames that are now invalid +- [ ] consistent ConfigFile Configfile + - [ ] review usages of ->_getSmartyObj and ->smarty: maybe change this so we can hide more - [ ] ->_objType and ->objMap - [ ] refactor _isTplObj, _isDataObj +- [ ] remove `require_once` calls from tests/*, especially where they load files from the demo dir +- [ ] look for and remove @method and @property phpdoc tags \ No newline at end of file diff --git a/demo/plugins/cacheresource.apc.php b/demo/plugins/cacheresource.apc.php index 335cd524..724c77d8 100644 --- a/demo/plugins/cacheresource.apc.php +++ b/demo/plugins/cacheresource.apc.php @@ -9,7 +9,7 @@ * @package CacheResource-examples * @author Uwe Tews */ -class Smarty_CacheResource_Apc extends \Smarty\Cacheresource\KeyValueStore +class My_CacheResource_Apc extends \Smarty\Cacheresource\KeyValueStore { /** * Smarty_CacheResource_Apc constructor. diff --git a/demo/plugins/cacheresource.memcache.php b/demo/plugins/cacheresource.memcache.php index 580d5e0e..343c32b1 100644 --- a/demo/plugins/cacheresource.memcache.php +++ b/demo/plugins/cacheresource.memcache.php @@ -10,7 +10,7 @@ * @package CacheResource-examples * @author Rodney Rehm */ -class Smarty_CacheResource_Memcache extends \Smarty\Cacheresource\KeyValueStore +class My_CacheResource_Memcache extends \Smarty\Cacheresource\KeyValueStore { /** * memcache instance diff --git a/demo/plugins/cacheresource.mysql.php b/demo/plugins/cacheresource.mysql.php index fda09bb7..3cd908e3 100644 --- a/demo/plugins/cacheresource.mysql.php +++ b/demo/plugins/cacheresource.mysql.php @@ -24,7 +24,7 @@ use Smarty\Exception; * @package CacheResource-examples * @author Rodney Rehm */ -class Smarty_CacheResource_Mysql extends \Smarty\Cacheresource\Custom +class My_CacheResource_Mysql extends \Smarty\Cacheresource\Custom { /** * @var \PDO diff --git a/demo/plugins/cacheresource.pdo.php b/demo/plugins/cacheresource.pdo.php index 8be18ec9..b01c2d3d 100644 --- a/demo/plugins/cacheresource.pdo.php +++ b/demo/plugins/cacheresource.pdo.php @@ -28,7 +28,7 @@ use Smarty\Exception; * * @author Beno!t POLASZEK - 2014 */ -class Smarty_CacheResource_Pdo extends \Smarty\Cacheresource\Custom +class My_CacheResource_Pdo extends \Smarty\Cacheresource\Custom { /** * @var string[] diff --git a/demo/plugins/cacheresource.pdo_gzip.php b/demo/plugins/cacheresource.pdo_gzip.php index acd21dd4..78e8adbf 100644 --- a/demo/plugins/cacheresource.pdo_gzip.php +++ b/demo/plugins/cacheresource.pdo_gzip.php @@ -11,7 +11,7 @@ require_once 'cacheresource.pdo.php'; * @require Smarty_CacheResource_Pdo class * @author Beno!t POLASZEK - 2014 */ -class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo +class My_CacheResource_Pdo_Gzip extends My_CacheResource_Pdo { /** * Encodes the content before saving to database diff --git a/demo/plugins/resource.extendsall.php b/demo/plugins/resource.extendsall.php index 09e9258d..1cbed5fe 100644 --- a/demo/plugins/resource.extendsall.php +++ b/demo/plugins/resource.extendsall.php @@ -12,7 +12,7 @@ use Smarty\Template\Source; * @package Resource-examples * @author Rodney Rehm */ -class Smarty_Resource_Extendsall extends \Smarty\Resource\ExtendsPlugin +class My_Resource_Extendsall extends \Smarty\Resource\ExtendsPlugin { /** * populate Source Object with meta data from Resource diff --git a/docs/getting-started.md b/docs/getting-started.md index 2a1391f4..ea9b8e0f 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -143,7 +143,9 @@ the same vars, etc., we can do that in one place. ```php assign('name','Ned'); $smarty->display('index.tpl'); ``` diff --git a/docs/programmers/advanced-features/advanced-features-outputfilters.md b/docs/programmers/advanced-features/advanced-features-outputfilters.md index f40f4aa9..a4756366 100644 --- a/docs/programmers/advanced-features/advanced-features-outputfilters.md +++ b/docs/programmers/advanced-features/advanced-features-outputfilters.md @@ -17,7 +17,7 @@ to return the result of the processing. \n\"; ?>\n".$tpl_source; } diff --git a/docs/programmers/advanced-features/advanced-features-prefilters.md b/docs/programmers/advanced-features/advanced-features-prefilters.md index bc84bea3..a71d0532 100644 --- a/docs/programmers/advanced-features/advanced-features-prefilters.md +++ b/docs/programmers/advanced-features/advanced-features-prefilters.md @@ -18,7 +18,7 @@ This will remove all the html comments in the template source. /U",'',$tpl_source); } diff --git a/docs/programmers/advanced-features/advanced-features-security.md b/docs/programmers/advanced-features/advanced-features-security.md index 730915f1..eeea8e56 100644 --- a/docs/programmers/advanced-features/advanced-features-security.md +++ b/docs/programmers/advanced-features/advanced-features-security.md @@ -103,9 +103,8 @@ Smarty\_Security class or create an instance of it. php_functions = null; // allow everthing as modifier diff --git a/docs/programmers/api-functions/api-register-cacheresource.md b/docs/programmers/api-functions/api-register-cacheresource.md index 60ae6030..62609149 100644 --- a/docs/programmers/api-functions/api-register-cacheresource.md +++ b/docs/programmers/api-functions/api-register-cacheresource.md @@ -31,7 +31,7 @@ how to create custom CacheResources. registerCacheResource('mysql', new Smarty_CacheResource_Mysql()); + $smarty->registerCacheResource('mysql', new My_CacheResource_Mysql()); ?> diff --git a/docs/programmers/api-functions/api-register-default-plugin-handler.md b/docs/programmers/api-functions/api-register-default-plugin-handler.md index 03547df7..b75a9f30 100644 --- a/docs/programmers/api-functions/api-register-default-plugin-handler.md +++ b/docs/programmers/api-functions/api-register-default-plugin-handler.md @@ -37,7 +37,7 @@ plugin types. * @param string $name name of the undefined tag * @param string $type tag type (e.g. Smarty::PLUGIN_FUNCTION, Smarty::PLUGIN_BLOCK, Smarty::PLUGIN_COMPILER, Smarty::PLUGIN_MODIFIER, Smarty::PLUGIN_MODIFIERCOMPILER) - * @param Smarty_Internal_Template $template template object + * @param \Smarty\Template\ $template template object * @param string &$callback returned function name * @param string &$script optional returned script filepath if function is external * @param bool &$cacheable true by default, set to false if plugin is not cachable (Smarty >= 3.1.8) diff --git a/docs/programmers/api-functions/api-register-resource.md b/docs/programmers/api-functions/api-register-resource.md index ca400546..774452bf 100644 --- a/docs/programmers/api-functions/api-register-resource.md +++ b/docs/programmers/api-functions/api-register-resource.md @@ -37,7 +37,7 @@ information on how to setup a function for fetching templates. registerResource('mysql', new Smarty_Resource_Mysql()); + $smarty->registerResource('mysql', new My_Resource_Mysql()); ?> diff --git a/docs/programmers/caching/caching-custom.md b/docs/programmers/caching/caching-custom.md index 2595fd2b..c0eddb59 100644 --- a/docs/programmers/caching/caching-custom.md +++ b/docs/programmers/caching/caching-custom.md @@ -66,7 +66,7 @@ to invoke your custom CacheResource implementation. * @package CacheResource-examples * @author Rodney Rehm */ - class Smarty_CacheResource_Mysql extends \Smarty\Cacheresource\Custom { + class My_CacheResource_Mysql extends \Smarty\Cacheresource\Custom { // PDO instance protected $db; protected $fetch; @@ -214,7 +214,7 @@ to invoke your custom CacheResource implementation. * @package CacheResource-examples * @author Rodney Rehm */ - class Smarty_CacheResource_Memcache extends \Smarty\Cacheresource\KeyValueStore { + class My_CacheResource_Memcache extends \Smarty\Cacheresource\KeyValueStore { /** * memcache instance * @var Memcache diff --git a/docs/programmers/plugins/plugins-functions.md b/docs/programmers/plugins/plugins-functions.md index 067b9382..5ac51539 100644 --- a/docs/programmers/plugins/plugins-functions.md +++ b/docs/programmers/plugins/plugins-functions.md @@ -40,7 +40,7 @@ some other Smarty-provided functionality, it can use the supplied * Purpose: outputs a random magic answer * ------------------------------------------------------------- */ - function smarty_function_eightball($params, Smarty_Internal_Template $template) + function smarty_function_eightball($params, \Smarty\Template\ $template) { $answers = array('Yes', 'No', @@ -71,7 +71,7 @@ which can be used in the template as: * Purpose: assign a value to a template variable * ------------------------------------------------------------- */ - function smarty_function_assign($params, Smarty_Internal_Template $template) + function smarty_function_assign($params, \Smarty\Template\ $template) { if (empty($params['var'])) { trigger_error("assign: missing 'var' parameter"); diff --git a/docs/programmers/plugins/plugins-inserts.md b/docs/programmers/plugins/plugins-inserts.md index 370a97bd..5f0f2088 100644 --- a/docs/programmers/plugins/plugins-inserts.md +++ b/docs/programmers/plugins/plugins-inserts.md @@ -35,7 +35,7 @@ substituted in place of the `{insert}` tag in the template. * Purpose: Inserts current date/time according to format * ------------------------------------------------------------- */ - function smarty_insert_time($params, Smarty_Internal_Template $template) + function smarty_insert_time($params, \Smarty\Template\ $template) { if (empty($params['format'])) { trigger_error("insert time: missing 'format' parameter"); diff --git a/docs/programmers/plugins/plugins-outputfilters.md b/docs/programmers/plugins/plugins-outputfilters.md index 4e34ab7e..f1e9111d 100644 --- a/docs/programmers/plugins/plugins-outputfilters.md +++ b/docs/programmers/plugins/plugins-outputfilters.md @@ -35,7 +35,7 @@ and return the results. * a simple protection against spambots * ------------------------------------------------------------- */ - function smarty_outputfilter_protect_email($output, Smarty_Internal_Template $template) + function smarty_outputfilter_protect_email($output, \Smarty\Template\ $template) { return preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!', '$1%40$2', $output); diff --git a/docs/programmers/plugins/plugins-prefilters-postfilters.md b/docs/programmers/plugins/plugins-prefilters-postfilters.md index 39467cbc..97cb7eaa 100644 --- a/docs/programmers/plugins/plugins-prefilters-postfilters.md +++ b/docs/programmers/plugins/plugins-prefilters-postfilters.md @@ -57,7 +57,7 @@ of this code. * Purpose: Convert html tags to be lowercase. * ------------------------------------------------------------- */ - function smarty_prefilter_pre01($source, Smarty_Internal_Template $template) + function smarty_prefilter_pre01($source, \Smarty\Template\ $template) { return preg_replace('!<(\w+)[^>]+>!e', 'strtolower("$1")', $source); } @@ -76,7 +76,7 @@ of this code. * Purpose: Output code that lists all current template vars. * ------------------------------------------------------------- */ - function smarty_postfilter_post01($compiled, Smarty_Internal_Template $template) + function smarty_postfilter_post01($compiled, \Smarty\Template\ $template) { $compiled = "
\ngetTemplateVars()); ?>\n
" . $compiled; return $compiled; diff --git a/docs/programmers/plugins/plugins-resources.md b/docs/programmers/plugins/plugins-resources.md index a54b1e99..608792cd 100644 --- a/docs/programmers/plugins/plugins-resources.md +++ b/docs/programmers/plugins/plugins-resources.md @@ -12,7 +12,7 @@ will be able to access that resource by prepending its name to the template you\'re addressing: `foobarxyz:yourtemplate.tpl`. If a Resource\'s templates should not be run through the Smarty -compiler, the Custom Resource may extend `Smarty_Resource_Uncompiled`. +compiler, the Custom Resource may extend `\Smarty\Resource\UncompiledPlugin`. The Resource Handler must then implement the function `renderUncompiled(\Smarty\Template $_template)`. `$_template` is a reference to the current template and contains all assigned variables @@ -23,7 +23,7 @@ output-cached if the Smarty instance was configured accordingly. See `src/Resource/PhpPlugin.php` for an example. If the Resource\'s compiled templates should not be cached on disk, the -Custom Resource may extend `Smarty_Resource_Recompiled`. These Resources +Custom Resource may extend `\Smarty\Resource\RecompiledPlugin`. These Resources are compiled every time they are accessed. This may be an expensive overhead. See `src/Resource/StringEval.php` for an example. @@ -51,7 +51,7 @@ example. * @package Resource-examples * @author Rodney Rehm */ - class Smarty_Resource_Mysql extends Smarty_Resource_Custom { + class My_Resource_Mysql extends \Smarty\Resource\CustomPlugin { // PDO instance protected $db; // prepared fetch() statement @@ -109,7 +109,7 @@ example. require_once 'libs/Smarty.class.php'; $smarty = new Smarty(); - $smarty->registerResource('mysql', new Smarty_Resource_Mysql()); + $smarty->registerResource('mysql', new My_Resource_Mysql()); // using resource from php script $smarty->display("mysql:index.tpl"); diff --git a/docs/programmers/resources/resources-custom.md b/docs/programmers/resources/resources-custom.md index 57b3d5fe..569f6b73 100644 --- a/docs/programmers/resources/resources-custom.md +++ b/docs/programmers/resources/resources-custom.md @@ -37,7 +37,7 @@ on the functions you are supposed to provide. * @package Resource-examples * @author Rodney Rehm */ - class Smarty_Resource_Mysql extends Smarty_Resource_Custom { + class My_Resource_Mysql extends \Smarty\Resource\Custom { // PDO instance protected $db; // prepared fetch() statement @@ -95,7 +95,7 @@ on the functions you are supposed to provide. require_once 'libs/Smarty.class.php'; $smarty = new Smarty(); - $smarty->registerResource('mysql', new Smarty_Resource_Mysql()); + $smarty->registerResource('mysql', new My_Resource_Mysql()); // using resource from php script $smarty->display("mysql:index.tpl"); diff --git a/docs/programmers/resources/template-resources.md b/docs/programmers/resources/template-resources.md index e442fdd3..3fb1b163 100644 --- a/docs/programmers/resources/template-resources.md +++ b/docs/programmers/resources/template-resources.md @@ -47,7 +47,7 @@ on the functions you are supposed to provide. * @package Resource-examples * @author Rodney Rehm */ - class Smarty_Resource_Mysql extends Smarty_Resource_Custom { + class My_Resource_Mysql extends \Smarty\Resource\Custom { // PDO instance protected $db; // prepared fetch() statement @@ -105,7 +105,7 @@ on the functions you are supposed to provide. require_once 'libs/Smarty.class.php'; $smarty = new Smarty(); - $smarty->registerResource('mysql', new Smarty_Resource_Mysql()); + $smarty->registerResource('mysql', new My_Resource_Mysql()); // using resource from php script $smarty->display("mysql:index.tpl"); diff --git a/src/Cacheresource/Custom.php b/src/Cacheresource/Custom.php index 8b5a03e1..e344a8e3 100644 --- a/src/Cacheresource/Custom.php +++ b/src/Cacheresource/Custom.php @@ -9,7 +9,9 @@ namespace Smarty\Cacheresource; * @subpackage Cacher */ +use Smarty\Smarty; use Smarty\Template; +use Smarty\Template\Cached; /** * Cache Handler API @@ -126,18 +128,18 @@ abstract class Custom extends Base $cached->exists = !!$cached->timestamp; } - /** - * Read the cached template and process the header - * - * @param \Smarty\Template $_smarty_tpl do not change variable name, is used by compiled template - * @param Smarty_Template_Cached $cached cached object - * @param boolean $update flag if called because cache update - * - * @return boolean true or false if the cached content does not exist - */ + /** + * Read the cached template and process the header + * + * @param Template $_smarty_tpl do not change variable name, is used by compiled template + * @param Cached|null $cached cached object + * @param boolean $update flag if called because cache update + * + * @return boolean true or false if the cached content does not exist + */ public function process( Template $_smarty_tpl, - Smarty_Template_Cached $cached = null, + \Smarty\Template\Cached $cached = null, $update = false ) { if (!$cached) { @@ -239,7 +241,7 @@ abstract class Custom extends Base { $cache_name = null; if (isset($resource_name)) { - $source = Smarty_Template_Source::load(null, $smarty, $resource_name); + $source = \Smarty\Template\Source::load(null, $smarty, $resource_name); if ($source->exists) { $cache_name = $source->name; } else { @@ -249,15 +251,15 @@ abstract class Custom extends Base return $this->delete($cache_name, $cache_id, $compile_id, $exp_time); } - /** - * Check is cache is locked for this template - * - * @param \Smarty\Smarty $smarty Smarty object - * @param Smarty_Template_Cached $cached cached object - * - * @return boolean true or false if cache is locked - */ - public function hasLock(\Smarty\Smarty $smarty, Smarty_Template_Cached $cached) + /** + * Check is cache is locked for this template + * + * @param Smarty $smarty Smarty object + * @param Cached $cached cached object + * + * @return boolean true or false if cache is locked + */ + public function hasLock(\Smarty\Smarty $smarty, \Smarty\Template\Cached $cached) { $id = $cached->lock_id; $name = $cached->source->name . '.lock'; @@ -272,11 +274,11 @@ abstract class Custom extends Base * Lock cache for this template * * @param \Smarty\Smarty $smarty Smarty object - * @param Smarty_Template_Cached $cached cached object + * @param \Smarty\Template\Cached $cached cached object * * @return bool|void */ - public function acquireLock(\Smarty\Smarty $smarty, Smarty_Template_Cached $cached) + public function acquireLock(\Smarty\Smarty $smarty, \Smarty\Template\Cached $cached) { $cached->is_locked = true; $id = $cached->lock_id; @@ -288,11 +290,11 @@ abstract class Custom extends Base * Unlock cache for this template * * @param \Smarty\Smarty $smarty Smarty object - * @param Smarty_Template_Cached $cached cached object + * @param \Smarty\Template\Cached $cached cached object * * @return bool|void */ - public function releaseLock(\Smarty\Smarty $smarty, Smarty_Template_Cached $cached) + public function releaseLock(\Smarty\Smarty $smarty, \Smarty\Template\Cached $cached) { $cached->is_locked = false; $name = $cached->source->name . '.lock'; diff --git a/src/Cacheresource/KeyValueStore.php b/src/Cacheresource/KeyValueStore.php index 4022d9ab..a51b2b90 100644 --- a/src/Cacheresource/KeyValueStore.php +++ b/src/Cacheresource/KeyValueStore.php @@ -234,7 +234,7 @@ abstract class KeyValueStore extends Base protected function getTemplateUid(Smarty $smarty, $resource_name) { if (isset($resource_name)) { - $source = Smarty_Template_Source::load(null, $smarty, $resource_name); + $source = \Smarty\Template\Source::load(null, $smarty, $resource_name); if ($source->exists) { return $source->uid; } diff --git a/src/Compile/BlockClose.php b/src/Compile/BlockClose.php index e71a22d4..f8f4a8bc 100644 --- a/src/Compile/BlockClose.php +++ b/src/Compile/BlockClose.php @@ -44,7 +44,7 @@ class BlockClose extends Inheritance { foreach ($_block as $property => $value) { $output .= "public \${$property} = " . var_export($value, true) . ";\n"; } - $output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n"; + $output .= "public function callBlock(\\Smarty\\Template \$_smarty_tpl) {\n"; if ($compiler->template->compiled->has_nocache_code) { $output .= "\$_smarty_tpl->cached->hashes['{$compiler->template->compiled->nocache_hash}'] = true;\n"; } diff --git a/src/Compile/BreakTag.php b/src/Compile/BreakTag.php index 8dae0efe..c25180ac 100644 --- a/src/Compile/BreakTag.php +++ b/src/Compile/BreakTag.php @@ -35,7 +35,7 @@ class BreakTag extends Base { protected $shorttag_order = ['levels']; /** - * Tag name may be overloaded by Smarty_Internal_Compile_Continue + * Tag name may be overloaded by ContinueTag * * @var string */ diff --git a/src/Compile/FunctionClose.php b/src/Compile/FunctionClose.php index af93ff07..83d5f8e2 100644 --- a/src/Compile/FunctionClose.php +++ b/src/Compile/FunctionClose.php @@ -70,7 +70,7 @@ class FunctionClose extends Base { $output = "cStyleComment(" {$_funcNameCaching} ") . "\n"; $output .= "if (!function_exists('{$_funcNameCaching}')) {\n"; - $output .= "function {$_funcNameCaching} (Smarty_Internal_Template \$_smarty_tpl,\$params) {\n"; + $output .= "function {$_funcNameCaching} (\\Smarty\\Template \$_smarty_tpl,\$params) {\n"; $output .= "ob_start();\n"; $output .= "\$_smarty_tpl->compiled->has_nocache_code = true;\n"; $output .= $_paramsCode; @@ -114,7 +114,7 @@ class FunctionClose extends Base { $output = "cStyleComment(" {$_funcName} ") . "\n"; $output .= "if (!function_exists('{$_funcName}')) {\n"; - $output .= "function {$_funcName}(Smarty_Internal_Template \$_smarty_tpl,\$params) {\n"; + $output .= "function {$_funcName}(\\Smarty\\Template \$_smarty_tpl,\$params) {\n"; $output .= $_paramsCode; $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new \\Smarty\\Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n"; $output .= "?>\n"; diff --git a/src/Compile/IncludeTag.php b/src/Compile/IncludeTag.php index 001cd16f..ae924357 100644 --- a/src/Compile/IncludeTag.php +++ b/src/Compile/IncludeTag.php @@ -325,7 +325,7 @@ class IncludeTag extends Base { // get compiled code $compiled_code = "cStyleComment(" Start inline template \"{$sourceInfo}\" =============================") . "\n"; - $compiled_code .= "function {$tpl->compiled->unifunc} (Smarty_Internal_Template \$_smarty_tpl) {\n"; + $compiled_code .= "function {$tpl->compiled->unifunc} (\\Smarty\\Template \$_smarty_tpl) {\n"; $compiled_code .= "?>\n" . $tpl->compiler->compileTemplateSource($tpl, null, $compiler->parent_compiler); $compiled_code .= "\n"; diff --git a/src/Compile/Insert.php b/src/Compile/Insert.php index 6c4ca572..f9845c82 100644 --- a/src/Compile/Insert.php +++ b/src/Compile/Insert.php @@ -144,13 +144,13 @@ class Insert extends Base { // call insert if (isset($_assign)) { if ($_smarty_tpl->caching && !$nocacheParam) { - $_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}',{$_assign});?>"; + $_output .= "echo \\Smarty\\Compile\\Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}',{$_assign});?>"; } else { $_output .= "\$_smarty_tpl->assign({$_assign} , {$_function} ({$_params},\$_smarty_tpl), true);?>"; } } else { if ($_smarty_tpl->caching && !$nocacheParam) { - $_output .= "echo Smarty_Internal_Nocache_Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}');?>"; + $_output .= "echo \\Smarty\\Compile\\Insert::compile ('{$_function}',{$_params}, \$_smarty_tpl, '{$_filepath}');?>"; } else { $_output .= "echo {$_function}({$_params},\$_smarty_tpl);?>"; } diff --git a/src/Compiler/CodeFrame.php b/src/Compiler/CodeFrame.php index 4ed563dd..7cd5cdd3 100644 --- a/src/Compiler/CodeFrame.php +++ b/src/Compiler/CodeFrame.php @@ -57,11 +57,11 @@ class CodeFrame date("Y-m-d H:i:s"), str_replace('*/', '* /', $this->_template->source->filepath) ); - $output .= "/* @var Smarty_Internal_Template \$_smarty_tpl */\n"; + $output .= "/* @var \\Smarty\\Template \$_smarty_tpl */\n"; $dec = "\$_smarty_tpl->_decodeProperties(\$_smarty_tpl, " . var_export($properties, true) . ',' . ($cache ? 'true' : 'false') . ')'; $output .= "if ({$dec}) {\n"; - $output .= "function {$properties['unifunc']} (Smarty_Internal_Template \$_smarty_tpl) {\n"; + $output .= "function {$properties['unifunc']} (\\Smarty\\Template \$_smarty_tpl) {\n"; if (!$cache && !empty($compiler->tpl_function)) { $output .= '$_smarty_tpl->smarty->getRuntime(\'TplFunction\')->registerTplFunctions($_smarty_tpl, '; $output .= var_export($compiler->tpl_function, true); diff --git a/src/Compiler/ConfigFile.php b/src/Compiler/ConfigFile.php index 41aba7d5..5be42649 100644 --- a/src/Compiler/ConfigFile.php +++ b/src/Compiler/ConfigFile.php @@ -11,8 +11,8 @@ namespace Smarty\Compiler; use Smarty; -use Smarty_Internal_ConfigFileLexer; -use Smarty_Internal_ConfigFileParser; +use Smarty\Lexer\ConfigFileLexer; +use Smarty\Parser\ConfigFileParser; use Smarty\Template; use Smarty\CompilerException; @@ -113,7 +113,7 @@ class ConfigFile { $this->smarty->_debug->start_compile($this->template); } // init the lexer/parser to compile the config file - /* @var Smarty_Internal_ConfigFileLexer $this- >lex */ + /* @var \Smarty\Lexer\ConfigfileLexer $this->lex */ $this->lex = new $this->lexer_class( str_replace( [ @@ -125,7 +125,7 @@ class ConfigFile { ) . "\n", $this ); - /* @var Smarty_Internal_ConfigFileParser $this- >parser */ + /* @var \Smarty\Parser\ConfigfileParser $this->parser */ $this->parser = new $this->parser_class($this->lex, $this); if (function_exists('mb_internal_encoding') && function_exists('ini_get') diff --git a/src/Compiler/Template.php b/src/Compiler/Template.php index e84344ac..3c507c30 100644 --- a/src/Compiler/Template.php +++ b/src/Compiler/Template.php @@ -13,7 +13,7 @@ namespace Smarty\Compiler; use Smarty; use Smarty\Compile\Base; use Smarty\Compile\ExtendsTag; -use Smarty_Internal_Templateparser; +use Smarty\Parser\TemplateParser; use Smarty\CompilerException; use Smarty\Exception; @@ -42,7 +42,7 @@ class Template { /** * Parser object * - * @var Smarty_Internal_Templateparser + * @var \Smarty\Parser\TemplateParser */ public $parser = null; @@ -84,7 +84,7 @@ class Template { /** * current template * - * @var Smarty_Internal_Template + * @var \Smarty\Template */ public $template = null; @@ -356,15 +356,15 @@ class Template { /** * Method to compile a Smarty template * - * @param Smarty_Internal_Template $template template object to compile - * @param bool $nocache true is shall be compiled in nocache mode - * @param null|\Smarty\Compiler\Template $parent_compiler + * @param Smarty\Template $template template object to compile + * @param null $nocache true is shall be compiled in nocache mode + * @param null|Template $parent_compiler * * @return bool true if compiling succeeded, false if it failed - * @throws \Exception + * @throws Exception */ public function compileTemplate( - Smarty_Internal_Template $template, + \Smarty\Template $template, $nocache = null, \Smarty\Compiler\Template $parent_compiler = null ) { @@ -394,7 +394,7 @@ class Template { * @throws \Exception */ public function compileTemplateSource( - Smarty_Internal_Template $template, + \Smarty\Template $template, $nocache = null, \Smarty\Compiler\Template $parent_compiler = null ) { @@ -694,8 +694,7 @@ class Template { /** * lazy loads internal compile plugin for tag and calls the compile method * 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 * @param array $args list of tag attributes diff --git a/src/Data.php b/src/Data.php index 1dc2121b..77c31fac 100644 --- a/src/Data.php +++ b/src/Data.php @@ -73,7 +73,7 @@ abstract class Data * @param mixed $value the value to assign * @param boolean $nocache if true any output of this variable will be not cached * - * @return Data current Data (or Smarty or Smarty_Internal_Template) instance for + * @return Data current Data (or Smarty or \Smarty\Template) instance for * chaining */ public function assign($tpl_var, $value = null, $nocache = false) @@ -222,7 +222,7 @@ abstract class Data } protected function _updateScope($varName, $tagScope = 0) { - // implemented in Smarty_Internal_Template only + // implemented in \Smarty\Template only } /** @@ -466,7 +466,7 @@ abstract class Data $confObj->caching = Smarty::CACHING_OFF; $confObj->source->config_sections = $sections; $confObj->source->scope = $scope; - $confObj->compiled = Smarty_Template_Compiled::load($confObj); + $confObj->compiled = \Smarty\Template\Compiled::load($confObj); $confObj->compiled->render($confObj); if ($this->_isTplObj()) { $this->compiled->file_dependency[ $confObj->source->uid ] = diff --git a/src/Lexer/smarty_internal_configfilelexer.plex b/src/Lexer/ConfigfileLexer.plex similarity index 74% rename from src/Lexer/smarty_internal_configfilelexer.plex rename to src/Lexer/ConfigfileLexer.plex index 2b2d9ae6..31ba0413 100644 --- a/src/Lexer/smarty_internal_configfilelexer.plex +++ b/src/Lexer/ConfigfileLexer.plex @@ -1,4 +1,7 @@ data = $data . "\n"; //now all lines are \n-terminated $this->dataLength = strlen($data); @@ -179,31 +182,31 @@ naked_string = /[^\n]+?(?=[ \t\r]*\n)/ %statename START commentstart { - $this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_COMMENTSTART; $this->yypushstate(self::COMMENT); } openB { - $this->token = Smarty_Internal_Configfileparser::TPC_OPENB; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_OPENB; $this->yypushstate(self::SECTION); } closeB { - $this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_CLOSEB; } equal { - $this->token = Smarty_Internal_Configfileparser::TPC_EQUAL; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_EQUAL; $this->yypushstate(self::VALUE); } whitespace { return false; } newline { - $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_NEWLINE; } id { - $this->token = Smarty_Internal_Configfileparser::TPC_ID; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_ID; } text { - $this->token = Smarty_Internal_Configfileparser::TPC_OTHER; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_OTHER; } */ @@ -215,23 +218,23 @@ whitespace { return false; } float { - $this->token = Smarty_Internal_Configfileparser::TPC_FLOAT; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_FLOAT; $this->yypopstate(); } int { - $this->token = Smarty_Internal_Configfileparser::TPC_INT; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_INT; $this->yypopstate(); } tripple_quotes { - $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_TRIPPLE_QUOTES; $this->yypushstate(self::TRIPPLE); } single_quoted_string { - $this->token = Smarty_Internal_Configfileparser::TPC_SINGLE_QUOTED_STRING; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_SINGLE_QUOTED_STRING; $this->yypopstate(); } double_quoted_string { - $this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_DOUBLE_QUOTED_STRING; $this->yypopstate(); } maybe_bool { @@ -240,16 +243,16 @@ maybe_bool { $this->yypushstate(self::NAKED_STRING_VALUE); return true; //reprocess in new state } else { - $this->token = Smarty_Internal_Configfileparser::TPC_BOOL; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_BOOL; $this->yypopstate(); } } naked_string { - $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_NAKED_STRING; $this->yypopstate(); } newline { - $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_NAKED_STRING; $this->value = ''; $this->yypopstate(); } @@ -260,7 +263,7 @@ newline { %statename NAKED_STRING_VALUE naked_string { - $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_NAKED_STRING; $this->yypopstate(); } @@ -273,10 +276,10 @@ whitespace { return false; } naked_string { - $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_NAKED_STRING; } newline { - $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_NEWLINE; $this->yypopstate(); } @@ -286,10 +289,10 @@ newline { %statename SECTION dot { - $this->token = Smarty_Internal_Configfileparser::TPC_DOT; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_DOT; } section { - $this->token = Smarty_Internal_Configfileparser::TPC_SECTION; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_SECTION; $this->yypopstate(); } @@ -298,7 +301,7 @@ section { %statename TRIPPLE tripple_quotes_end { - $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES_END; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_TRIPPLE_QUOTES_END; $this->yypopstate(); $this->yypushstate(self::START); } @@ -311,7 +314,7 @@ text { $this->compiler->trigger_config_file_error ('missing or misspelled literal closing tag'); } $this->value = substr($this->data,$this->counter,$to-$this->counter); - $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT; + $this->token = \Smarty\Parser\ConfigfileParser::TPC_TRIPPLE_TEXT; } */ diff --git a/src/Lexer/smarty_internal_templatelexer.plex b/src/Lexer/TemplateLexer.plex similarity index 74% rename from src/Lexer/smarty_internal_templatelexer.plex rename to src/Lexer/TemplateLexer.plex index a5f21f8e..33721948 100644 --- a/src/Lexer/smarty_internal_templatelexer.plex +++ b/src/Lexer/TemplateLexer.plex @@ -1,4 +1,7 @@ */ -class Smarty_Internal_Templatelexer +class TemplateLexer { /** * Source @@ -339,7 +342,7 @@ class Smarty_Internal_Templatelexer /*!lex2php %statename TEXT emptyjava { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; + $this->token = \Smarty\Parser\TemplateParser::TP_TEXT; } comment { $to = $this->dataLength; @@ -353,14 +356,14 @@ class Smarty_Internal_Templatelexer return false; } userliteral { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; + $this->token = \Smarty\Parser\TemplateParser::TP_TEXT; } ldel literal rdel { - $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART; + $this->token = \Smarty\Parser\TemplateParser::TP_LITERALSTART; $this->yypushstate(self::LITERAL); } ldel slash literal rdel { - $this->token = Smarty_Internal_Templateparser::TP_LITERALEND; + $this->token = \Smarty\Parser\TemplateParser::TP_LITERALEND; $this->yypushstate(self::LITERAL); } ldel { @@ -377,70 +380,70 @@ class Smarty_Internal_Templatelexer $to = $match[0][1]; } $this->value = substr($this->data,$this->counter,$to-$this->counter); - $this->token = Smarty_Internal_Templateparser::TP_TEXT; + $this->token = \Smarty\Parser\TemplateParser::TP_TEXT; } */ /*!lex2php %statename TAG ldel if { - $this->token = Smarty_Internal_Templateparser::TP_LDELIF; + $this->token = \Smarty\Parser\TemplateParser::TP_LDELIF; $this->yybegin(self::TAGBODY); $this->taglineno = $this->line; } ldel for { - $this->token = Smarty_Internal_Templateparser::TP_LDELFOR; + $this->token = \Smarty\Parser\TemplateParser::TP_LDELFOR; $this->yybegin(self::TAGBODY); $this->taglineno = $this->line; } ldel foreach { - $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; + $this->token = \Smarty\Parser\TemplateParser::TP_LDELFOREACH; $this->yybegin(self::TAGBODY); $this->taglineno = $this->line; } ldel setfilter { - $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER; + $this->token = \Smarty\Parser\TemplateParser::TP_LDELSETFILTER; $this->yybegin(self::TAGBODY); $this->taglineno = $this->line; } ldel makenocache { - $this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE; + $this->token = \Smarty\Parser\TemplateParser::TP_LDELMAKENOCACHE; $this->yybegin(self::TAGBODY); $this->taglineno = $this->line; } ldel id nocacherdel { $this->yypopstate(); - $this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG; + $this->token = \Smarty\Parser\TemplateParser::TP_SIMPLETAG; $this->taglineno = $this->line; } ldel smartyblockchildparent rdel { $this->yypopstate(); - $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT; + $this->token = \Smarty\Parser\TemplateParser::TP_SMARTYBLOCKCHILDPARENT; $this->taglineno = $this->line; } ldel slash id rdel { $this->yypopstate(); - $this->token = Smarty_Internal_Templateparser::TP_CLOSETAG; + $this->token = \Smarty\Parser\TemplateParser::TP_CLOSETAG; $this->taglineno = $this->line; } ldel dollar id nocacherdel { if ($this->_yy_stack[count($this->_yy_stack)-1] === self::TEXT) { $this->yypopstate(); - $this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT; + $this->token = \Smarty\Parser\TemplateParser::TP_SIMPELOUTPUT; $this->taglineno = $this->line; } else { $this->value = $this->smarty->getLeftDelimiter(); - $this->token = Smarty_Internal_Templateparser::TP_LDEL; + $this->token = \Smarty\Parser\TemplateParser::TP_LDEL; $this->yybegin(self::TAGBODY); $this->taglineno = $this->line; } } ldel slash { - $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; + $this->token = \Smarty\Parser\TemplateParser::TP_LDELSLASH; $this->yybegin(self::TAGBODY); $this->taglineno = $this->line; } ldel { - $this->token = Smarty_Internal_Templateparser::TP_LDEL; + $this->token = \Smarty\Parser\TemplateParser::TP_LDEL; $this->yybegin(self::TAGBODY); $this->taglineno = $this->line; } @@ -448,7 +451,7 @@ class Smarty_Internal_Templatelexer /*!lex2php %statename TAGBODY rdel { - $this->token = Smarty_Internal_Templateparser::TP_RDEL; + $this->token = \Smarty\Parser\TemplateParser::TP_RDEL; $this->yypopstate(); } ldel { @@ -456,143 +459,143 @@ class Smarty_Internal_Templatelexer return true; } double_quote { - $this->token = Smarty_Internal_Templateparser::TP_QUOTE; + $this->token = \Smarty\Parser\TemplateParser::TP_QUOTE; $this->yypushstate(self::DOUBLEQUOTEDSTRING); $this->compiler->enterDoubleQuote(); } singlequotestring { - $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING; + $this->token = \Smarty\Parser\TemplateParser::TP_SINGLEQUOTESTRING; } dollar id { - $this->token = Smarty_Internal_Templateparser::TP_DOLLARID; + $this->token = \Smarty\Parser\TemplateParser::TP_DOLLARID; } dollar { - $this->token = Smarty_Internal_Templateparser::TP_DOLLAR; + $this->token = \Smarty\Parser\TemplateParser::TP_DOLLAR; } isin { - $this->token = Smarty_Internal_Templateparser::TP_ISIN; + $this->token = \Smarty\Parser\TemplateParser::TP_ISIN; } as { - $this->token = Smarty_Internal_Templateparser::TP_AS; + $this->token = \Smarty\Parser\TemplateParser::TP_AS; } to { - $this->token = Smarty_Internal_Templateparser::TP_TO; + $this->token = \Smarty\Parser\TemplateParser::TP_TO; } step { - $this->token = Smarty_Internal_Templateparser::TP_STEP; + $this->token = \Smarty\Parser\TemplateParser::TP_STEP; } instanceof { - $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF; + $this->token = \Smarty\Parser\TemplateParser::TP_INSTANCEOF; } lop { - $this->token = Smarty_Internal_Templateparser::TP_LOGOP; + $this->token = \Smarty\Parser\TemplateParser::TP_LOGOP; } slop { - $this->token = Smarty_Internal_Templateparser::TP_SLOGOP; + $this->token = \Smarty\Parser\TemplateParser::TP_SLOGOP; } tlop { - $this->token = Smarty_Internal_Templateparser::TP_TLOGOP; + $this->token = \Smarty\Parser\TemplateParser::TP_TLOGOP; } scond { - $this->token = Smarty_Internal_Templateparser::TP_SINGLECOND; + $this->token = \Smarty\Parser\TemplateParser::TP_SINGLECOND; } not{ - $this->token = Smarty_Internal_Templateparser::TP_NOT; + $this->token = \Smarty\Parser\TemplateParser::TP_NOT; } typecast { - $this->token = Smarty_Internal_Templateparser::TP_TYPECAST; + $this->token = \Smarty\Parser\TemplateParser::TP_TYPECAST; } openP { - $this->token = Smarty_Internal_Templateparser::TP_OPENP; + $this->token = \Smarty\Parser\TemplateParser::TP_OPENP; } closeP { - $this->token = Smarty_Internal_Templateparser::TP_CLOSEP; + $this->token = \Smarty\Parser\TemplateParser::TP_CLOSEP; } openB { - $this->token = Smarty_Internal_Templateparser::TP_OPENB; + $this->token = \Smarty\Parser\TemplateParser::TP_OPENB; } closeB { - $this->token = Smarty_Internal_Templateparser::TP_CLOSEB; + $this->token = \Smarty\Parser\TemplateParser::TP_CLOSEB; } ptr { - $this->token = Smarty_Internal_Templateparser::TP_PTR; + $this->token = \Smarty\Parser\TemplateParser::TP_PTR; } aptr { - $this->token = Smarty_Internal_Templateparser::TP_APTR; + $this->token = \Smarty\Parser\TemplateParser::TP_APTR; } equal { - $this->token = Smarty_Internal_Templateparser::TP_EQUAL; + $this->token = \Smarty\Parser\TemplateParser::TP_EQUAL; } incdec { - $this->token = Smarty_Internal_Templateparser::TP_INCDEC; + $this->token = \Smarty\Parser\TemplateParser::TP_INCDEC; } unimath { - $this->token = Smarty_Internal_Templateparser::TP_UNIMATH; + $this->token = \Smarty\Parser\TemplateParser::TP_UNIMATH; } math { - $this->token = Smarty_Internal_Templateparser::TP_MATH; + $this->token = \Smarty\Parser\TemplateParser::TP_MATH; } at { - $this->token = Smarty_Internal_Templateparser::TP_AT; + $this->token = \Smarty\Parser\TemplateParser::TP_AT; } array openP { - $this->token = Smarty_Internal_Templateparser::TP_ARRAYOPEN; + $this->token = \Smarty\Parser\TemplateParser::TP_ARRAYOPEN; } hatch { - $this->token = Smarty_Internal_Templateparser::TP_HATCH; + $this->token = \Smarty\Parser\TemplateParser::TP_HATCH; } attr { // resolve conflicts with shorttag and right_delimiter starting with '=' if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) === $this->smarty->getRightDelimiter()) { preg_match('/\s+/',$this->value,$match); $this->value = $match[0]; - $this->token = Smarty_Internal_Templateparser::TP_SPACE; + $this->token = \Smarty\Parser\TemplateParser::TP_SPACE; } else { - $this->token = Smarty_Internal_Templateparser::TP_ATTR; + $this->token = \Smarty\Parser\TemplateParser::TP_ATTR; } } namespace { - $this->token = Smarty_Internal_Templateparser::TP_NAMESPACE; + $this->token = \Smarty\Parser\TemplateParser::TP_NAMESPACE; } id { - $this->token = Smarty_Internal_Templateparser::TP_ID; + $this->token = \Smarty\Parser\TemplateParser::TP_ID; } integer { - $this->token = Smarty_Internal_Templateparser::TP_INTEGER; + $this->token = \Smarty\Parser\TemplateParser::TP_INTEGER; } backtick { - $this->token = Smarty_Internal_Templateparser::TP_BACKTICK; + $this->token = \Smarty\Parser\TemplateParser::TP_BACKTICK; $this->yypopstate(); } vert { - $this->token = Smarty_Internal_Templateparser::TP_VERT; + $this->token = \Smarty\Parser\TemplateParser::TP_VERT; } dot { - $this->token = Smarty_Internal_Templateparser::TP_DOT; + $this->token = \Smarty\Parser\TemplateParser::TP_DOT; } comma { - $this->token = Smarty_Internal_Templateparser::TP_COMMA; + $this->token = \Smarty\Parser\TemplateParser::TP_COMMA; } semicolon { - $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON; + $this->token = \Smarty\Parser\TemplateParser::TP_SEMICOLON; } doublecolon { - $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON; + $this->token = \Smarty\Parser\TemplateParser::TP_DOUBLECOLON; } colon { - $this->token = Smarty_Internal_Templateparser::TP_COLON; + $this->token = \Smarty\Parser\TemplateParser::TP_COLON; } qmark { - $this->token = Smarty_Internal_Templateparser::TP_QMARK; + $this->token = \Smarty\Parser\TemplateParser::TP_QMARK; } hex { - $this->token = Smarty_Internal_Templateparser::TP_HEX; + $this->token = \Smarty\Parser\TemplateParser::TP_HEX; } space { - $this->token = Smarty_Internal_Templateparser::TP_SPACE; + $this->token = \Smarty\Parser\TemplateParser::TP_SPACE; } char { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; + $this->token = \Smarty\Parser\TemplateParser::TP_TEXT; } */ @@ -600,14 +603,14 @@ class Smarty_Internal_Templatelexer %statename LITERAL ldel literal rdel { $this->literal_cnt++; - $this->token = Smarty_Internal_Templateparser::TP_LITERAL; + $this->token = \Smarty\Parser\TemplateParser::TP_LITERAL; } ldel slash literal rdel { if ($this->literal_cnt) { $this->literal_cnt--; - $this->token = Smarty_Internal_Templateparser::TP_LITERAL; + $this->token = \Smarty\Parser\TemplateParser::TP_LITERAL; } else { - $this->token = Smarty_Internal_Templateparser::TP_LITERALEND; + $this->token = \Smarty\Parser\TemplateParser::TP_LITERALEND; $this->yypopstate(); } } @@ -623,19 +626,19 @@ class Smarty_Internal_Templatelexer $this->compiler->trigger_template_error ("missing or misspelled literal closing tag"); } $this->value = substr($this->data,$this->counter,$to-$this->counter); - $this->token = Smarty_Internal_Templateparser::TP_LITERAL; + $this->token = \Smarty\Parser\TemplateParser::TP_LITERAL; } */ /*!lex2php %statename DOUBLEQUOTEDSTRING userliteral { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; + $this->token = \Smarty\Parser\TemplateParser::TP_TEXT; } ldel literal rdel { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; + $this->token = \Smarty\Parser\TemplateParser::TP_TEXT; } ldel slash literal rdel { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; + $this->token = \Smarty\Parser\TemplateParser::TP_TEXT; } ldel slash { $this->yypushstate(self::TAG); @@ -646,33 +649,33 @@ class Smarty_Internal_Templatelexer return true; } ldel { - $this->token = Smarty_Internal_Templateparser::TP_LDEL; + $this->token = \Smarty\Parser\TemplateParser::TP_LDEL; $this->taglineno = $this->line; $this->yypushstate(self::TAGBODY); } double_quote { - $this->token = Smarty_Internal_Templateparser::TP_QUOTE; + $this->token = \Smarty\Parser\TemplateParser::TP_QUOTE; $this->yypopstate(); } backtick dollar { - $this->token = Smarty_Internal_Templateparser::TP_BACKTICK; + $this->token = \Smarty\Parser\TemplateParser::TP_BACKTICK; $this->value = substr($this->value,0,-1); $this->yypushstate(self::TAGBODY); $this->taglineno = $this->line; } dollar id { - $this->token = Smarty_Internal_Templateparser::TP_DOLLARID; + $this->token = \Smarty\Parser\TemplateParser::TP_DOLLARID; } dollar { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; + $this->token = \Smarty\Parser\TemplateParser::TP_TEXT; } textdoublequoted { - $this->token = Smarty_Internal_Templateparser::TP_TEXT; + $this->token = \Smarty\Parser\TemplateParser::TP_TEXT; } char { $to = $this->dataLength; $this->value = substr($this->data,$this->counter,$to-$this->counter); - $this->token = Smarty_Internal_Templateparser::TP_TEXT; + $this->token = \Smarty\Parser\TemplateParser::TP_TEXT; } */ } diff --git a/src/ParseTree/Base.php b/src/ParseTree/Base.php index a1e05785..fc21cc23 100644 --- a/src/ParseTree/Base.php +++ b/src/ParseTree/Base.php @@ -36,11 +36,11 @@ abstract class Base /** * Return buffer * - * @param \Smarty_Internal_Templateparser $parser + * @param \Smarty\Parser\TemplateParser $parser * * @return string buffer content */ - abstract public function to_smarty_php(\Smarty_Internal_Templateparser $parser); + abstract public function to_smarty_php(\Smarty\Parser\TemplateParser $parser); /** * Template data object destructor diff --git a/src/ParseTree/Code.php b/src/ParseTree/Code.php index 466ee93c..0109e1ef 100644 --- a/src/ParseTree/Code.php +++ b/src/ParseTree/Code.php @@ -34,11 +34,11 @@ class Code extends Base /** * Return buffer content in parentheses * - * @param \Smarty_Internal_Templateparser $parser + * @param \Smarty\Parser\TemplateParser $parser * * @return string content */ - public function to_smarty_php(\Smarty_Internal_Templateparser $parser) + public function to_smarty_php(\Smarty\Parser\TemplateParser $parser) { return sprintf('(%s)', $this->data); } diff --git a/src/ParseTree/Dq.php b/src/ParseTree/Dq.php index 72de82e5..8365bfd1 100644 --- a/src/ParseTree/Dq.php +++ b/src/ParseTree/Dq.php @@ -35,10 +35,10 @@ class Dq extends Base /** * Append buffer to subtree * - * @param \Smarty_Internal_Templateparser $parser + * @param \Smarty\Parser\TemplateParser $parser * @param Base $subtree parse tree buffer */ - public function append_subtree(\Smarty_Internal_Templateparser $parser, Base $subtree) + public function append_subtree(\Smarty\Parser\TemplateParser $parser, Base $subtree) { $last_subtree = count($this->subtrees) - 1; if ($last_subtree >= 0 && $this->subtrees[ $last_subtree ] instanceof Tag @@ -71,11 +71,11 @@ class Dq extends Base /** * Merge subtree buffer content together * - * @param \Smarty_Internal_Templateparser $parser + * @param \Smarty\Parser\TemplateParser $parser * * @return string compiled template code */ - public function to_smarty_php(\Smarty_Internal_Templateparser $parser) + public function to_smarty_php(\Smarty\Parser\TemplateParser $parser) { $code = ''; foreach ($this->subtrees as $subtree) { diff --git a/src/ParseTree/DqContent.php b/src/ParseTree/DqContent.php index d3dd0817..54b29904 100644 --- a/src/ParseTree/DqContent.php +++ b/src/ParseTree/DqContent.php @@ -33,11 +33,11 @@ class DqContent extends Base /** * Return content as double-quoted string * - * @param \Smarty_Internal_Templateparser $parser + * @param \Smarty\Parser\TemplateParser $parser * * @return string doubled quoted string */ - public function to_smarty_php(\Smarty_Internal_Templateparser $parser) + public function to_smarty_php(\Smarty\Parser\TemplateParser $parser) { return '"' . $this->data . '"'; } diff --git a/src/ParseTree/Tag.php b/src/ParseTree/Tag.php index 892c2c9f..ca925537 100644 --- a/src/ParseTree/Tag.php +++ b/src/ParseTree/Tag.php @@ -31,10 +31,10 @@ class Tag extends Base /** * Create parse tree buffer for Smarty tag * - * @param \Smarty_Internal_Templateparser $parser parser object + * @param \Smarty\Parser\TemplateParser $parser parser object * @param string $data content */ - public function __construct(\Smarty_Internal_Templateparser $parser, $data) + public function __construct(\Smarty\Parser\TemplateParser $parser, $data) { $this->data = $data; $this->saved_block_nesting = $parser->block_nesting_level; @@ -43,11 +43,11 @@ class Tag extends Base /** * Return buffer content * - * @param \Smarty_Internal_Templateparser $parser + * @param \Smarty\Parser\TemplateParser $parser * * @return string content */ - public function to_smarty_php(\Smarty_Internal_Templateparser $parser) + public function to_smarty_php(\Smarty\Parser\TemplateParser $parser) { return $this->data; } @@ -55,11 +55,11 @@ class Tag extends Base /** * Return complied code that loads the evaluated output of buffer content into a temporary variable * - * @param \Smarty_Internal_Templateparser $parser + * @param \Smarty\Parser\TemplateParser $parser * * @return string template code */ - public function assign_to_var(\Smarty_Internal_Templateparser $parser) + public function assign_to_var(\Smarty\Parser\TemplateParser $parser) { $var = $parser->compiler->getNewPrefixVariable(); $tmp = $parser->compiler->appendCode('', $this->data); diff --git a/src/ParseTree/Template.php b/src/ParseTree/Template.php index 09eb2fc1..1a70a4a8 100644 --- a/src/ParseTree/Template.php +++ b/src/ParseTree/Template.php @@ -38,10 +38,10 @@ class Template extends Base /** * Append buffer to subtree * - * @param \Smarty_Internal_Templateparser $parser + * @param \Smarty\Parser\TemplateParser $parser * @param Base $subtree */ - public function append_subtree(\Smarty_Internal_Templateparser $parser, Base $subtree) + public function append_subtree(\Smarty\Parser\TemplateParser $parser, Base $subtree) { if (!empty($subtree->subtrees)) { $this->subtrees = array_merge($this->subtrees, $subtree->subtrees); @@ -55,10 +55,10 @@ class Template extends Base /** * Append array to subtree * - * @param \Smarty_Internal_Templateparser $parser + * @param \Smarty\Parser\TemplateParser $parser * @param Base[] $array */ - public function append_array(\Smarty_Internal_Templateparser $parser, $array = array()) + public function append_array(\Smarty\Parser\TemplateParser $parser, $array = array()) { if (!empty($array)) { $this->subtrees = array_merge($this->subtrees, (array)$array); @@ -68,10 +68,10 @@ class Template extends Base /** * Prepend array to subtree * - * @param \Smarty_Internal_Templateparser $parser + * @param \Smarty\Parser\TemplateParser $parser * @param Base[] $array */ - public function prepend_array(\Smarty_Internal_Templateparser $parser, $array = array()) + public function prepend_array(\Smarty\Parser\TemplateParser $parser, $array = array()) { if (!empty($array)) { $this->subtrees = array_merge((array)$array, $this->subtrees); @@ -81,11 +81,11 @@ class Template extends Base /** * Sanitize and merge subtree buffers together * - * @param \Smarty_Internal_Templateparser $parser + * @param \Smarty\Parser\TemplateParser $parser * * @return string template code content */ - public function to_smarty_php(\Smarty_Internal_Templateparser $parser) + public function to_smarty_php(\Smarty\Parser\TemplateParser $parser) { $code = ''; diff --git a/src/ParseTree/Text.php b/src/ParseTree/Text.php index 51441b30..183b6970 100644 --- a/src/ParseTree/Text.php +++ b/src/ParseTree/Text.php @@ -48,11 +48,11 @@ class Text extends Base /** * Return buffer content * - * @param \Smarty_Internal_Templateparser $parser + * @param \Smarty\Parser\TemplateParser $parser * * @return string text */ - public function to_smarty_php(\Smarty_Internal_Templateparser $parser) + public function to_smarty_php(\Smarty\Parser\TemplateParser $parser) { return $this->data; } diff --git a/src/Parser/smarty_internal_configfileparser.y b/src/Parser/ConfigfileParser.y similarity index 95% rename from src/Parser/smarty_internal_configfileparser.y rename to src/Parser/ConfigfileParser.y index 213d7ebc..23ad6d2f 100644 --- a/src/Parser/smarty_internal_configfileparser.y +++ b/src/Parser/ConfigfileParser.y @@ -4,7 +4,7 @@ namespace Smarty\Parser; use \Smarty\Lexer\Configfile as Lexer; /** -* Smarty Internal Plugin Configfileparser +* ConfigfileParser * * This is the config file parser * @@ -19,12 +19,12 @@ use \Smarty\Lexer\Configfile as Lexer; * Smarty Internal Plugin Configfileparse * * This is the config file parser. -* It is generated from the smarty_internal_configfileparser.y file +* It is generated from the ConfigfileParser.y file * @package Smarty * @subpackage Compiler * @author Uwe Tews */ -class Configfile +class ConfigfileParser } %include_class { @@ -59,7 +59,7 @@ class Configfile /** * compiler object * - * @var Smarty\Compiler\ConfigFile + * @var \Smarty\Compiler\ConfigFile */ public $compiler = null; /** @@ -92,9 +92,9 @@ class Configfile * constructor * * @param Lexer $lex - * @param Smarty\Compiler\ConfigFile $compiler + * @param \Smarty\Compiler\ConfigFile $compiler */ - public function __construct(Lexer $lex, Smarty\Compiler\ConfigFile $compiler) + public function __construct(Lexer $lex, \Smarty\Compiler\ConfigFile $compiler) { $this->lex = $lex; $this->smarty = $compiler->smarty; diff --git a/src/Parser/smarty_internal_templateparser.y b/src/Parser/TemplateParser.y similarity index 98% rename from src/Parser/smarty_internal_templateparser.y rename to src/Parser/TemplateParser.y index 65649200..628d14a7 100644 --- a/src/Parser/smarty_internal_templateparser.y +++ b/src/Parser/TemplateParser.y @@ -1,3 +1,8 @@ + +namespace Smarty\Parser; + +use \Smarty\Lexer\Configfile as Lexer; + /* * This file is part of Smarty. * @@ -13,11 +18,11 @@ * Smarty Template Parser Class * * This is the template parser. -* It is generated from the smarty_internal_templateparser.y file +* It is generated from the TemplateParser.y file * * @author Uwe Tews */ -class Smarty_Internal_Templateparser +class TemplateParser } %include_class { @@ -74,7 +79,7 @@ class Smarty_Internal_Templateparser /** * lexer object * - * @var Smarty_Internal_Templatelexer + * @var Lexer */ public $lex; @@ -101,14 +106,14 @@ class Smarty_Internal_Templateparser /** * smarty object * - * @var Smarty + * @var \Smarty\Smarty */ public $smarty = null; /** * template object * - * @var Smarty_Internal_Template + * @var \Smarty\Template */ public $template = null; @@ -122,7 +127,7 @@ class Smarty_Internal_Templateparser /** * security object * - * @var Smarty_Security + * @var \Smarty\Security */ public $security = null; @@ -143,10 +148,10 @@ class Smarty_Internal_Templateparser /** * constructor * - * @param Smarty_Internal_Templatelexer $lex + * @param Lexer $lex * @param \Smarty\Compiler\Template $compiler */ - public function __construct(Smarty_Internal_Templatelexer $lex, \Smarty\Compiler\Template $compiler) + public function __construct(Lexer $lex, \Smarty\Compiler\Template $compiler) { $this->lex = $lex; $this->compiler = $compiler; diff --git a/src/Resource/BasePlugin.php b/src/Resource/BasePlugin.php index abb6d8b0..c787ee8a 100644 --- a/src/Resource/BasePlugin.php +++ b/src/Resource/BasePlugin.php @@ -17,9 +17,9 @@ namespace Smarty\Resource; * @package Smarty * @subpackage TemplateResources * - * @method renderUncompiled(Smarty_Template_Source $source, Smarty_Internal_Template $_template) - * @method populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template) - * @method process(Smarty_Internal_Template $_smarty_tpl) + * @method renderUncompiled(\Smarty\Template\Source $source, \Smarty\Template $_template) + * @method populateCompiledFilepath(\Smarty\Template\Compiled $compiled, \Smarty\Template $_template) + * @method process(\Smarty\Template $_smarty_tpl) */ abstract class BasePlugin { diff --git a/src/Security.php b/src/Security.php index 3acd4662..40bbf85b 100644 --- a/src/Security.php +++ b/src/Security.php @@ -8,12 +8,12 @@ */ /** - * FIXME: Smarty_Security API + * FIXME: \Smarty\Security API * - getter and setter instead of public properties would allow cultivating an internal cache properly * - current implementation of isTrustedResourceDir() assumes that Smarty::$template_dir and Smarty::$config_dir * are immutable the cache is killed every time either of the variables change. That means that two distinct * Smarty objects with differing - * $template_dir or $config_dir should NOT share the same Smarty_Security instance, + * $template_dir or $config_dir should NOT share the same \Smarty\Security instance, * as this would lead to (severe) performance penalty! how should this be handled? */ @@ -618,7 +618,7 @@ class Security { $smarty->security_policy = $security_class; return $smarty; } elseif (is_object($security_class)) { - throw new Exception("Class '" . get_class($security_class) . "' must extend Smarty_Security."); + throw new Exception("Class '" . get_class($security_class) . "' must extend \\Smarty\\Security."); } if ($security_class === null) { $security_class = $smarty->security_class; diff --git a/src/Smarty.php b/src/Smarty.php index 9af958ac..d624334c 100644 --- a/src/Smarty.php +++ b/src/Smarty.php @@ -271,7 +271,7 @@ class Smarty extends \Smarty\TemplateBase /** * class name - * This should be instance of \Smarty_Security. + * This should be instance of \Smarty\Security. * * @var string * @see \Smarty\Security @@ -1476,7 +1476,7 @@ class Smarty extends \Smarty\TemplateBase $_tpl = new $this->template_class($_file, $_smarty); $_tpl->caching = self::CACHING_OFF; $_tpl->source = - $isConfig ? Smarty_Template_Config::load($_tpl) : Smarty_Template_Source::load($_tpl); + $isConfig ? \Smarty\Template\Config::load($_tpl) : \Smarty\Template\Source::load($_tpl); if ($_tpl->mustCompile()) { $_tpl->compileTemplateSource(); $_count++; @@ -1563,9 +1563,6 @@ class Smarty extends \Smarty\TemplateBase /** * Run filters over content * The filters will be lazy loaded if required - * class name format: Smarty_FilterType_FilterName - * plugin filename format: filtertype.filtername.php - * Smarty2 filter plugins could be used * * @param string $type the type of filter ('pre','post','output') which shall run * @param string $content the content which shall be processed by the filters diff --git a/src/Template.php b/src/Template.php index 5f15bbf2..053c22f3 100644 --- a/src/Template.php +++ b/src/Template.php @@ -10,13 +10,12 @@ namespace Smarty; -use Smarty; +use Smarty\Smarty; use Smarty\Runtime\InheritanceRuntime; use Smarty\Template\Source; use Smarty\Template\Cached; use Smarty\Template\Compiled; use Smarty\Template\Config; -use Smarty\Exception; /** * Main class with template data structures and methods @@ -133,14 +132,11 @@ class Template extends TemplateBase { * * @param string $template_resource template resource string * @param Smarty $smarty Smarty instance - * @param null|\Smarty_Internal_Template|\Smarty|\Smarty\Data $_parent back pointer to parent - * object with variables or - * null + * @param \Smarty\Data|null $_parent back pointer to parent object with variables or null * @param mixed $_cache_id cache id or null * @param mixed $_compile_id compile id or null * @param bool|int|null $_caching use caching? - * @param int|null $_cache_lifetime cache life-time in - * seconds + * @param int|null $_cache_lifetime cache life-time in seconds * @param bool $_isConfig * * @throws \Smarty\Exception @@ -439,7 +435,7 @@ class Template extends TemplateBase { * - Decode saved properties from compiled template and cache files * - Check if compiled or cache file is valid * - * @param \Smarty_Internal_Template $tpl + * @param \Smarty\Template $tpl * @param array $properties special template properties * @param bool $cache flag if called from cache file * @@ -709,7 +705,6 @@ class Template extends TemplateBase { /** * load config variables into template object * - * @param \Smarty_Internal_Template $tpl * @param array $new_config_vars */ public function _loadConfigVars($new_config_vars) { @@ -727,7 +722,7 @@ class Template extends TemplateBase { $mergedScope = $tagScope | $this->scope; if ($mergedScope) { // update scopes - /* @var \Smarty_Internal_Template|\Smarty|Data $ptr */ + /* @var \Smarty\Data $ptr */ foreach ($this->parent->_getAffectedScopes($mergedScope) as $ptr) { $this->_assignConfigVars($ptr->config_vars, $new_config_vars); if ($tagScope && $ptr->_isTplObj() && isset($this->_var_stack)) { @@ -897,7 +892,7 @@ class Template extends TemplateBase { /** * Update variable in template local variable stack * - * @param \Smarty_Internal_Template $tpl + * @param Template $tpl * @param string|null $varName variable name or null for config variables */ private function _updateVarStack(Template $tpl, $varName) { diff --git a/src/Template/Config.php b/src/Template/Config.php index 069fa81f..8ecd95a8 100644 --- a/src/Template/Config.php +++ b/src/Template/Config.php @@ -40,21 +40,21 @@ class Config extends Source { * * @var string */ - public $compiler_class = 'Smarty\Compiler\ConfigFile'; + public $compiler_class = \Smarty\Compiler\ConfigFile::class; /** * Name of the Class to tokenize this resource's contents with * * @var string */ - public $template_lexer_class = 'Smarty_Internal_Configfilelexer'; + public $template_lexer_class = \Smarty\Lexer\ConfigfileLexer::class; /** * Name of the Class to parse this resource's contents with * * @var string */ - public $template_parser_class = 'Smarty_Internal_Configfileparser'; + public $template_parser_class = \Smarty\Parser\ConfigfileParser::class; /** * initialize Source Object for given resource diff --git a/src/Template/Source.php b/src/Template/Source.php index 61f44d85..ffdba431 100644 --- a/src/Template/Source.php +++ b/src/Template/Source.php @@ -24,7 +24,7 @@ class Source { public $uid = null; /** - * Template Resource (Smarty_Internal_Template::$template_resource) + * Template Resource (\Smarty\Template::$template_resource) * * @var string */ @@ -75,7 +75,7 @@ class Source { /** * The Components an extended template is made of * - * @var \Smarty_Template_Source[] + * @var \Smarty\Template\Source[] */ public $components = null; @@ -112,21 +112,21 @@ class Source { * * @var string */ - public $compiler_class = 'Smarty\Compiler\Template'; + public $compiler_class = \Smarty\Compiler\Template::class; /** * Name of the Class to tokenize this resource's contents with * * @var string */ - public $template_lexer_class = 'Smarty_Internal_Templatelexer'; + public $template_lexer_class = \Smarty\Lexer\TemplateLexer::class; /** * Name of the Class to parse this resource's contents with * * @var string */ - public $template_parser_class = 'Smarty_Internal_Templateparser'; + public $template_parser_class = \Smarty\Parser\TemplateParser::class; /** * create Source Object container diff --git a/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php b/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php index 84dc7ad1..530f2a15 100644 --- a/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php +++ b/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php @@ -25,7 +25,7 @@ class LoadPluginTest extends PHPUnit_Smarty */ public function testLoadPluginErrorReturn() { - $this->assertFalse($this->smarty->loadPlugin('Smarty_Not_Known')); + $this->assertFalse($this->smarty->loadPlugin('\\Smarty\\Not\\Known')); } /** @@ -33,7 +33,7 @@ class LoadPluginTest extends PHPUnit_Smarty */ public function testLoadPluginSmartyInternalDebug() { - $this->assertTrue($this->smarty->loadPlugin('\Smarty\Debug') == true); + $this->assertTrue($this->smarty->loadPlugin(\Smarty\Debug::class) == true); } /** @@ -49,6 +49,6 @@ class LoadPluginTest extends PHPUnit_Smarty */ public function testLoadPluginSmartyPluginCounter() { - $this->assertTrue($this->smarty->loadPlugin('Smarty_Function_Counter') == true); + $this->assertTrue($this->smarty->loadPlugin('smarty_function_counter') == true); } } diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php index 5bc6cc3b..8befb7d9 100644 --- a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php +++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.apctest.php @@ -1,11 +1,12 @@