[prev in list] [next in list] [prev in thread] [next in thread]
List: smarty-dev
Subject: Re: [SMARTY-DEV] Strict PHP5 Compatibility
From: Ruben Vermeersch <lists () lambda1 ! be>
Date: 2004-07-23 0:27:10
Message-ID: 1090542430.9838.12.camel () ruben
[Download RAW message or body]
[Attachment #2 (multipart/mixed)]
Didn't feel like sleeping, here's the whole thing.
Ruben
On Fri, 2004-07-23 at 02:17 +0200, Ruben Vermeersch wrote:
> Note: this is only a patched Smarty.class.php file, rest will follow,
> but it's getting quite late.
>
> Ruben
>
> On Fri, 2004-07-23 at 02:14 +0200, Ruben Vermeersch wrote:
> > Patching Smarty for my latest project again. This time, it's E_STRICT
> > compatibility (PHP5). Offcourse, this cannot be taken into HEAD, since
> > it would break backwards compatibility. Just posting it anyway, there
> > was some interest.
> >
> > Ain't a big patch anyway (took my 5 minutes), just put all the normal
> > vars public, the @access private vars protected. The latter is because I
> > still want to be able to access em when overloading Smarty. This does
> > add some crap in PhpDocumentor, although i find it rather usefull to
> > have these vars in the docs too. The most important change is the
> > renaming of the constructor (It's PHP5 after all ;)).
> >
> > If anyone can use it, enjoy!
> >
> > Regards,
> > Ruben
> >
--
Ruben Vermeersch
http://www.Lambda1.be/
["smarty-php5-strict.diff" (smarty-php5-strict.diff)]
Index: Smarty_Compiler.class.php
===================================================================
--- Smarty_Compiler.class.php (revision 32)
+++ Smarty_Compiler.class.php (working copy)
@@ -38,46 +38,48 @@
/**#@+
* @access private
*/
- var $_folded_blocks = array(); // keeps folded template blocks
- var $_current_file = null; // the current template being compiled
- var $_current_line_no = 1; // line number for error messages
- var $_capture_stack = array(); // keeps track of nested capture buffers
- var $_plugin_info = array(); // keeps track of plugins to load
- var $_init_smarty_vars = false;
- var $_permitted_tokens = array('true','false','yes','no','on','off','null');
- var $_db_qstr_regexp = null; // regexps are setup in the constructor
- var $_si_qstr_regexp = null;
- var $_qstr_regexp = null;
- var $_func_regexp = null;
- var $_var_bracket_regexp = null;
- var $_dvar_guts_regexp = null;
- var $_dvar_regexp = null;
- var $_cvar_regexp = null;
- var $_svar_regexp = null;
- var $_avar_regexp = null;
- var $_mod_regexp = null;
- var $_var_regexp = null;
- var $_parenth_param_regexp = null;
- var $_func_call_regexp = null;
- var $_obj_ext_regexp = null;
- var $_obj_start_regexp = null;
- var $_obj_params_regexp = null;
- var $_obj_call_regexp = null;
- var $_cacheable_state = 0;
- var $_cache_attrs_count = 0;
- var $_nocache_count = 0;
- var $_cache_serial = null;
- var $_cache_include = null;
+ private $_folded_blocks = array(); // keeps folded template blocks
+ private $_current_file = null; // the current template being compiled
+ private $_current_line_no = 1; // line number for error messages
+ private $_capture_stack = array(); // keeps track of nested capture buffers
+ private $_plugin_info = array(); // keeps track of plugins to load
+ private $_init_smarty_vars = false;
+ private $_permitted_tokens = array('true','false','yes','no','on','off','null');
+ private $_db_qstr_regexp = null; // regexps are setup in the constructor
+ private $_si_qstr_regexp = null;
+ private $_qstr_regexp = null;
+ private $_func_regexp = null;
+ private $_var_bracket_regexp = null;
+ private $_dvar_guts_regexp = null;
+ private $_dvar_regexp = null;
+ private $_cvar_regexp = null;
+ private $_svar_regexp = null;
+ private $_avar_regexp = null;
+ private $_mod_regexp = null;
+ private $_var_regexp = null;
+ private $_parenth_param_regexp = null;
+ private $_func_call_regexp = null;
+ private $_obj_ext_regexp = null;
+ private $_obj_start_regexp = null;
+ private $_obj_params_regexp = null;
+ private $_obj_call_regexp = null;
+ private $_cacheable_state = 0;
+ private $_cache_attrs_count = 0;
+ private $_nocache_count = 0;
+ private $_cache_serial = null;
+ private $_cache_include = null;
- var $_strip_depth = 0;
- var $_additional_newline = "\n";
+ private $_strip_depth = 0;
+ private $_additional_newline = "\n";
/**#@-*/
/**
* The class constructor.
*/
- function Smarty_Compiler()
+ function __construct()
{
+ parent::__construct();
+
// matches double quoted strings:
// "foobar"
// "foo\"bar"
Index: Smarty.class.php
===================================================================
--- Smarty.class.php (revision 32)
+++ Smarty.class.php (working copy)
@@ -68,28 +68,28 @@
*
* @var string
*/
- var $template_dir = 'templates';
+ public $template_dir = 'templates';
/**
* The directory where compiled templates are located.
*
* @var string
*/
- var $compile_dir = 'templates_c';
+ public $compile_dir = 'templates_c';
/**
* The directory where config files are located.
*
* @var string
*/
- var $config_dir = 'configs';
+ public $config_dir = 'configs';
/**
* An array of directories searched for plugins.
*
* @var array
*/
- var $plugins_dir = array('plugins');
+ public $plugins_dir = array('plugins');
/**
* If debugging is enabled, a debug console window will display
@@ -98,14 +98,14 @@
*
* @var boolean
*/
- var $debugging = false;
+ public $debugging = false;
/**
* When set, smarty does uses this value as error_reporting-level.
*
* @var boolean
*/
- var $error_reporting = null;
+ public $error_reporting = null;
/**
* This is the path to the debug console template. If not set,
@@ -113,7 +113,7 @@
*
* @var string
*/
- var $debug_tpl = '';
+ public $debug_tpl = '';
/**
* This determines if debugging is enable-able from the browser.
@@ -124,7 +124,7 @@
* @link http://www.foo.dom/index.php?SMARTY_DEBUG
* @var string
*/
- var $debugging_ctrl = 'NONE';
+ public $debugging_ctrl = 'NONE';
/**
* This tells Smarty whether to check for recompiling or not. Recompiling
@@ -134,7 +134,7 @@
*
* @var boolean
*/
- var $compile_check = true;
+ public $compile_check = true;
/**
* This forces templates to compile every time. Useful for development
@@ -142,7 +142,7 @@
*
* @var boolean
*/
- var $force_compile = false;
+ public $force_compile = false;
/**
* This enables template caching.
@@ -153,14 +153,14 @@
* </ul>
* @var integer
*/
- var $caching = 0;
+ public $caching = 0;
/**
* The name of the directory for cache files.
*
* @var string
*/
- var $cache_dir = 'cache';
+ public $cache_dir = 'cache';
/**
* This is the number of seconds cached content will persist.
@@ -171,7 +171,7 @@
*
* @var integer
*/
- var $cache_lifetime = 3600;
+ public $cache_lifetime = 3600;
/**
* Only used when $caching is enabled. If true, then If-Modified-Since headers
@@ -181,7 +181,7 @@
*
* @var boolean
*/
- var $cache_modified_check = false;
+ public $cache_modified_check = false;
/**
* This determines how Smarty handles "<?php ... ?>" tags in templates.
@@ -195,7 +195,7 @@
*
* @var integer
*/
- var $php_handling = SMARTY_PHP_PASSTHRU;
+ public $php_handling = SMARTY_PHP_PASSTHRU;
/**
* This enables template security. When enabled, many things are restricted
@@ -205,7 +205,7 @@
*
* @var boolean
*/
- var $security = false;
+ public $security = false;
/**
* This is the list of template directories that are considered secure. This
@@ -214,7 +214,7 @@
*
* @var array
*/
- var $secure_dir = array();
+ public $secure_dir = array();
/**
* These are the security settings for Smarty. They are used only when
@@ -222,7 +222,7 @@
*
* @var array
*/
- var $security_settings = array(
+ public $security_settings = array(
'PHP_HANDLING' => false,
'IF_FUNCS' => array('array', 'list',
'isset', 'empty',
@@ -240,21 +240,21 @@
*
* @var array
*/
- var $trusted_dir = array();
+ public $trusted_dir = array();
/**
* The left delimiter used for the template tags.
*
* @var string
*/
- var $left_delimiter = '{';
+ public $left_delimiter = '{';
/**
* The right delimiter used for the template tags.
*
* @var string
*/
- var $right_delimiter = '}';
+ public $right_delimiter = '}';
/**
* The order in which request variables are registered, similar to
@@ -263,7 +263,7 @@
*
* @var string
*/
- var $request_vars_order = 'EGPCS';
+ public $request_vars_order = 'EGPCS';
/**
* Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false)
@@ -273,7 +273,7 @@
*
* @var boolean
*/
- var $request_use_auto_globals = true;
+ public $request_use_auto_globals = true;
/**
* Set this if you want different sets of compiled files for the same
@@ -283,7 +283,7 @@
*
* @var string
*/
- var $compile_id = null;
+ public $compile_id = null;
/**
* This tells Smarty whether or not to use sub dirs in the cache/ and
@@ -293,7 +293,7 @@
* @var boolean
*
*/
- var $use_sub_dirs = false;
+ public $use_sub_dirs = false;
/**
* This is a list of the modifiers to apply to all template variables.
@@ -302,7 +302,7 @@
*
* @var array
*/
- var $default_modifiers = array();
+ public $default_modifiers = array();
/**
* This is the resource type to be used when not specified
@@ -316,21 +316,21 @@
*
* @var array
*/
- var $default_resource_type = 'file';
+ public $default_resource_type = 'file';
/**
* The function used for cache file handling. If not set, built-in caching is used.
*
* @var null|string function name
*/
- var $cache_handler_func = null;
+ public $cache_handler_func = null;
/**
* This indicates which filters are automatically loaded into Smarty.
*
* @var array array of filter names
*/
- var $autoload_filters = array();
+ public $autoload_filters = array();
/**#@+
* @var boolean
@@ -339,14 +339,14 @@
* This tells if config file vars of the same name overwrite each other or not.
* if disabled, same name variables are accumulated in an array.
*/
- var $config_overwrite = true;
+ public $config_overwrite = true;
/**
* This tells whether or not to automatically booleanize config file variables.
* If enabled, then the strings "on", "true", and "yes" are treated as boolean
* true, and "off", "false" and "no" are treated as boolean false.
*/
- var $config_booleanize = true;
+ public $config_booleanize = true;
/**
* This tells whether hidden sections [.foobar] are readable from the
@@ -354,13 +354,13 @@
* the point behind hidden sections: the application can access them, but
* the templates cannot.
*/
- var $config_read_hidden = false;
+ public $config_read_hidden = false;
/**
* This tells whether or not automatically fix newlines in config files.
* It basically converts \r (mac) or \r\n (dos) to \n
*/
- var $config_fix_newlines = true;
+ public $config_fix_newlines = true;
/**#@-*/
/**
@@ -369,7 +369,7 @@
*
* @var string function name
*/
- var $default_template_handler_func = '';
+ public $default_template_handler_func = '';
/**
* The file that contains the compiler class. This can a full
@@ -377,152 +377,152 @@
*
* @var string
*/
- var $compiler_file = 'Smarty_Compiler.class.php';
+ public $compiler_file = 'Smarty_Compiler.class.php';
/**
* The class used for compiling templates.
*
* @var string
*/
- var $compiler_class = 'Smarty_Compiler';
+ public $compiler_class = 'Smarty_Compiler';
/**
* The class used to load config vars.
*
* @var string
*/
- var $config_class = 'Config_File';
+ public $config_class = 'Config_File';
/**#@+
* END Smarty Configuration Section
* There should be no need to touch anything below this line.
- * @access private
+ * @access protected
*/
/**
* where assigned template vars are kept
*
* @var array
*/
- var $_tpl_vars = array();
+ protected $_tpl_vars = array();
/**
* stores run-time $smarty.* vars
*
* @var null|array
*/
- var $_smarty_vars = null;
+ protected $_smarty_vars = null;
/**
* keeps track of sections
*
* @var array
*/
- var $_sections = array();
+ protected $_sections = array();
/**
* keeps track of foreach blocks
*
* @var array
*/
- var $_foreach = array();
+ protected $_foreach = array();
/**
* keeps track of tag hierarchy
*
* @var array
*/
- var $_tag_stack = array();
+ protected $_tag_stack = array();
/**
* configuration object
*
* @var Config_file
*/
- var $_conf_obj = null;
+ protected $_conf_obj = null;
/**
* loaded configuration settings
*
* @var array
*/
- var $_config = array(array('vars' => array(), 'files' => array()));
+ protected $_config = array(array('vars' => array(), 'files' => array()));
/**
* md5 checksum of the string 'Smarty'
*
* @var string
*/
- var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f';
+ protected $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f';
/**
* Smarty version number
*
* @var string
*/
- var $_version = '2.6.4-dev';
+ protected $_version = '2.6.4-dev';
/**
* current template inclusion depth
*
* @var integer
*/
- var $_inclusion_depth = 0;
+ protected $_inclusion_depth = 0;
/**
* for different compiled templates
*
* @var string
*/
- var $_compile_id = null;
+ protected $_compile_id = null;
/**
* text in URL to enable debug mode
*
* @var string
*/
- var $_smarty_debug_id = 'SMARTY_DEBUG';
+ protected $_smarty_debug_id = 'SMARTY_DEBUG';
/**
* debugging information for debug console
*
* @var array
*/
- var $_smarty_debug_info = array();
+ protected $_smarty_debug_info = array();
/**
* info that makes up a cache file
*
* @var array
*/
- var $_cache_info = array();
+ protected $_cache_info = array();
/**
* default file permissions
*
* @var integer
*/
- var $_file_perms = 0644;
+ protected $_file_perms = 0644;
/**
* default dir permissions
*
* @var integer
*/
- var $_dir_perms = 0771;
+ protected $_dir_perms = 0771;
/**
* registered objects
*
* @var array
*/
- var $_reg_objects = array();
+ protected $_reg_objects = array();
/**
* table keeping track of plugins
*
* @var array
*/
- var $_plugins = array(
+ protected $_plugins = array(
'modifier' => array(),
'function' => array(),
'block' => array(),
@@ -539,14 +539,14 @@
*
* @var array
*/
- var $_cache_serials = array();
+ protected $_cache_serials = array();
/**
* name of optional cache include file
*
* @var string
*/
- var $_cache_include = null;
+ protected $_cache_include = null;
/**
* indicate if the current code is used in a compiled
@@ -554,13 +554,13 @@
*
* @var string
*/
- var $_cache_including = false;
+ protected $_cache_including = false;
/**#@-*/
/**
* The class constructor.
*/
- function Smarty()
+ function __construct()
{
$this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME']
: @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
Index: Config_File.class.php
===================================================================
--- Config_File.class.php (revision 32)
+++ Config_File.class.php (working copy)
@@ -39,29 +39,29 @@
/**
* Controls whether variables with the same name overwrite each other.
*/
- var $overwrite = true;
+ public $overwrite = true;
/**
* Controls whether config values of on/true/yes and off/false/no get
* converted to boolean values automatically.
*/
- var $booleanize = true;
+ public $booleanize = true;
/**
* Controls whether hidden config sections/vars are read from the file.
*/
- var $read_hidden = true;
+ public $read_hidden = true;
/**
* Controls whether or not to fix mac or dos formatted newlines.
* If set to true, \r or \r\n will be changed to \n.
*/
- var $fix_newlines = true;
+ public $fix_newlines = true;
/**#@-*/
/** @access private */
- var $_config_path = "";
- var $_config_data = array();
+ private $_config_path = "";
+ private $_config_data = array();
/**#@-*/
/**
@@ -69,7 +69,7 @@
*
* @param string $config_path (optional) path to the config files
*/
- function Config_File($config_path = NULL)
+ function __construct($config_path = NULL)
{
if (isset($config_path))
$this->set_path($config_path);
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic