Strict PHP5 Compatibility

[email protected] (Ruben Vermeersch)
Newsgroups php.smarty.dev
Message-ID <1090541693.9838.8.camel@ruben>
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 (text/x-patch, 13.2 KB)
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']);
signature.asc (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQBBAFh94xxhPkoR/ZURAjy/AKDfSA1Xf2Sl3tGrwUst6STDQ1CdjgCcCcI/
Nq5eeSgToaPgLsC1Dqh5CM0=
=/YGF
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.