Entire src dir now PSR-4 compatible

This commit is contained in:
Simon Wisselink
2022-12-22 22:38:37 +01:00
parent f1e7b2d46f
commit 4d66910e7f
53 changed files with 279 additions and 268 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -143,7 +143,9 @@ the same vars, etc., we can do that in one place.
```php
<?php
class Smarty_GuestBook extends Smarty {
use Smarty\Smarty;
class My_GuestBook extends Smarty {
public function __construct()
{
@@ -161,9 +163,9 @@ class Smarty_GuestBook extends Smarty {
}
```
Now, we can use `Smarty_GuestBook` instead of `Smarty` in our scripts:
Now, we can use `My_GuestBook` instead of `Smarty` in our scripts:
```php
$smarty = new Smarty_GuestBook();
$smarty = new My_GuestBook();
$smarty->assign('name','Ned');
$smarty->display('index.tpl');
```

View File

@@ -17,7 +17,7 @@ to return the result of the processing.
<?php
// put this in your application
function protect_email($tpl_output, Smarty_Internal_Template $template)
function protect_email($tpl_output, \Smarty\Template\ $template)
{
$tpl_output =
preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!',

View File

@@ -12,7 +12,7 @@ function to return the result of the processing.
<?php
// put this in your application
function add_header_comment($tpl_source, Smarty_Internal_Template $template)
function add_header_comment($tpl_source, \Smarty\Template\ $template)
{
return "<?php echo \"<!-- Created by Smarty! -->\n\"; ?>\n".$tpl_source;
}

View File

@@ -18,7 +18,7 @@ This will remove all the html comments in the template source.
<?php
// put this in your application
function remove_dw_comments($tpl_source, Smarty_Internal_Template $template)
function remove_dw_comments($tpl_source, \Smarty\Template\ $template)
{
return preg_replace("/<!--#.*-->/U",'',$tpl_source);
}

View File

@@ -103,9 +103,8 @@ Smarty\_Security class or create an instance of it.
<?php
require 'Smarty.class.php';
class My_Security_Policy extends Smarty_Security {
class My_Security_Policy extends \Smarty\Security {
// disable all PHP functions
public $php_functions = null;
// allow everthing as modifier
@@ -118,9 +117,8 @@ Smarty\_Security class or create an instance of it.
<?php
require 'Smarty.class.php';
$smarty = new Smarty();
$my_security_policy = new Smarty_Security($smarty);
$my_security_policy = new \Smarty\Security($smarty);
// disable all PHP functions
$my_security_policy->php_functions = null;
// allow everthing as modifier

View File

@@ -31,7 +31,7 @@ how to create custom CacheResources.
<?php
$smarty->registerCacheResource('mysql', new Smarty_CacheResource_Mysql());
$smarty->registerCacheResource('mysql', new My_CacheResource_Mysql());
?>

View File

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

View File

@@ -37,7 +37,7 @@ information on how to setup a function for fetching templates.
<?php
$smarty->registerResource('mysql', new Smarty_Resource_Mysql());
$smarty->registerResource('mysql', new My_Resource_Mysql());
?>

View File

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

View File

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

View File

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

View File

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

View File

@@ -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 = "<pre>\n<?php print_r(\$template->getTemplateVars()); ?>\n</pre>" . $compiled;
return $compiled;

View File

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

View File

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

View File

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

View File

@@ -9,7 +9,9 @@ namespace Smarty\Cacheresource;
* @subpackage Cacher
*/
use Smarty\Smarty;
use Smarty\Template;
use Smarty\Template\Cached;
/**
* Cache Handler API
@@ -129,15 +131,15 @@ abstract class Custom extends Base
/**
* 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 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 {
@@ -252,12 +254,12 @@ abstract class Custom extends Base
/**
* Check is cache is locked for this template
*
* @param \Smarty\Smarty $smarty Smarty object
* @param Smarty_Template_Cached $cached cached object
* @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)
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';

View File

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

View File

@@ -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";
}

View File

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

View File

@@ -70,7 +70,7 @@ class FunctionClose extends Base {
$output = "<?php\n";
$output .= $compiler->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 = "<?php\n";
$output .= $compiler->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";

View File

@@ -325,7 +325,7 @@ class IncludeTag extends Base {
// get compiled code
$compiled_code = "<?php\n\n";
$compiled_code .= $compiler->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 .= "<?php\n";
$compiled_code .= "}\n?>\n";

View File

@@ -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);?>";
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,7 @@
<?php
namespace Smarty\Lexer;
/**
* Smarty Internal Plugin Configfilelexer
*
@@ -8,16 +11,16 @@
* @author Uwe Tews
*/
/**
* Smarty_Internal_Configfilelexer
* Configfilelexer
*
* This is the config file lexer.
* It is generated from the smarty_internal_configfilelexer.plex file
* It is generated from the ConfigfileLexer.plex file
*
* @package Smarty
* @subpackage Compiler
* @author Uwe Tews
*/
class Smarty_Internal_Configfilelexer
class Configfilelexer
{
/**
* Source
@@ -70,7 +73,7 @@ class Smarty_Internal_Configfilelexer
/**
* compiler object
*
* @var Smarty\Compiler\ConfigFile
* @var \Smarty\Compiler\ConfigFile
*/
private $compiler = null;
/**
@@ -122,9 +125,9 @@ class Smarty_Internal_Configfilelexer
* constructor
*
* @param string $data template source
* @param Smarty\Compiler\ConfigFile $compiler
* @param \Smarty\Compiler\ConfigFile $compiler
*/
public function __construct($data, Smarty\Compiler\ConfigFile $compiler)
public function __construct($data, \Smarty\Compiler\ConfigFile $compiler)
{
$this->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;
}
*/

View File

@@ -1,4 +1,7 @@
<?php
namespace Smarty\Lexer;
/*
* This file is part of Smarty.
*
@@ -9,14 +12,14 @@
*/
/**
* Smarty_Internal_Templatelexer
* TemplateLexer
* This is the template file lexer.
* It is generated from the smarty_internal_templatelexer.plex file
* It is generated from the TemplateLexer.plex file
*
*
* @author Uwe Tews <uwe.tews@googlemail.com>
*/
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;
}
*/
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -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('<?php ob_start();?>', $this->data);

View File

@@ -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 = '';

View File

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

View File

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

View File

@@ -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 <uwe.tews@googlemail.com>
*/
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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,11 +1,12 @@
<?php
use Smarty\Smarty;
use Smarty\Template;
use Smarty\Template\Cached;
require_once SMARTY_DIR . '../demo/plugins/cacheresource.apc.php';
class Smarty_CacheResource_Apctest extends Smarty_CacheResource_Apc
class Smarty_CacheResource_Apctest extends My_CacheResource_Apc
{
public $lockTime = 0;