diff --git a/change_log.txt b/change_log.txt index f214d270..5121a950 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,8 +1,9 @@ ===== 3.1.32 - dev === -05.11.2017 3.1.32-dev-32 +05.11.2017 - lexer/parser optimization + - code cleanup and optimizations -26.10.2017 3.1.32-dev-28 +26.10.2017 - bugfix Smarty version was not filled in header comment of compiled and cached files - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR - deprecate functions Smarty::muteExpectedErrors() and Smarty::unmuteExpectedErrors() @@ -98,12 +99,11 @@ https://github.com/smarty-php/smarty/issues/347 14.4.2017 - - merge pull requests https://github.com/smarty-php/smarty/pull/349, https://github.com/smarty-php/smarty/pull/322 and - https://github.com/smarty-php/smarty/pull/337 to fix spelling and annotation + - merge pull requests https://github.com/smarty-php/smarty/pull/349, https://github.com/smarty-php/smarty/pull/322 and https://github.com/smarty-php/smarty/pull/337 to fix spelling and annotation 13.4.2017 - bugfix array_merge() parameter should be checked https://github.com/smarty-php/smarty/issues/350 - + ===== 3.1.31 ===== (14.12.2016) 23.11.2016 - move template object cache into static variables @@ -142,7 +142,7 @@ 19.10.2016 - bugfix {make_nocache $var} did fail when variable value did contain '\' https://github.com/smarty-php/smarty/issues/305 - bugfix {make_nocache $var} remove spaces from variable value https://github.com/smarty-php/smarty/issues/304 - + 12.10.2016 - bugfix {include} with template names including variable or constants could fail after bugfix from 28.09.2016 https://github.com/smarty-php/smarty/issues/302 @@ -201,7 +201,7 @@ 01.09.2016 - performance require_once should be called only once for shared plugins https://github.com/smarty-php/smarty/issues/280 - + 26.08.2016 - bugfix change of 23.08.2016 failed on linux when use_include_path = true @@ -224,47 +224,47 @@ - bugfix update of 04.08.2016 was incomplete 05.08.2016 - - bugfix compiling of templates failed when the Smarty delimiter did contain '/' https://github.com/smarty-php/smarty/issues/264 + - bugfix compiling of templates failed when the Smarty delimiter did contain '/' https://github.com/smarty-php/smarty/issues/264 - updated error checking at template and config default handler - + 04.08.2016 - improvement move template function source parameter into extension - + 26.07.2016 - optimization unneeded loading of compiled resource - + 24.07.2016 - regression this->addPluginsDir('/abs/path/to/dir') adding absolute path without trailing '/' did fail https://github.com/smarty-php/smarty/issues/260 - + 23.07.2016 - bugfix setTemplateDir('/') and setTemplateDir('') did create wrong absolute filepath https://github.com/smarty-php/smarty/issues/245 - optimization of filepath normalization - improvement remove double function declaration in plugin shared.escape_special_cars.php https://github.com/smarty-php/smarty/issues/229 - + 19.07.2016 - bugfix multiple {include} with relative filepath within {block}{/block} could fail https://github.com/smarty-php/smarty/issues/246 - bugfix {math} shell injection vulnerability patch provided by Tim Weber - + 18.07.2016 - bugfix {foreach} if key variable and item@key attribute have been used both the key variable was not updated https://github.com/smarty-php/smarty/issues/254 - bugfix modifier on plugins like {plugin|modifier ... } did fail when the plugin does return an array https://github.com/smarty-php/smarty/issues/228 - bugfix avoid opcache_invalidate to result in ErrorException when opcache.restrict_api is not empty https://github.com/smarty-php/smarty/pull/244 - bugfix multiple {include} with relative filepath within {block}{/block} could fail https://github.com/smarty-php/smarty/issues/246 - + 14.07.2016 - bugfix wrong parameter on compileAllTemplates() and compileAllConfig() https://github.com/smarty-php/smarty/issues/231 - + 13.07.2016 - bugfix PHP 7 compatibility on registered compiler plugins https://github.com/smarty-php/smarty/issues/241 - update testInstall() https://github.com/smarty-php/smarty/issues/248https://github.com/smarty-php/smarty/issues/248 - bugfix enable debugging could fail when template objects did already exists https://github.com/smarty-php/smarty/issues/237 - bugfix template function data should be merged when loading subtemplate https://github.com/smarty-php/smarty/issues/240 - bugfix wrong parameter on compileAllTemplates() https://github.com/smarty-php/smarty/issues/231 - + 12.07.2016 - bugfix {foreach} item variable must be created also on empty from array https://github.com/smarty-php/smarty/issues/238 and https://github.com/smarty-php/smarty/issues/239 - bugfix enableSecurity() must init cache flags https://github.com/smarty-php/smarty/issues/247 - + 27.05.2016 - bugfix/improvement of compileAlltemplates() follow symlinks in template folder (PHP >= 5.3.1) https://github.com/smarty-php/smarty/issues/224 clear internal cache and expension handler for each template to avoid possible conflicts https://github.com/smarty-php/smarty/issues/231 @@ -307,26 +307,26 @@ 11.03.2016 - optimization of capture and security handling - improvement $smarty->clearCompiledTemplate() should return on recompiled or uncompiled resources - + 10.03.2016 - optimization of resource processing - + 09.03.2016 - improvement rework of 'scope' attribute handling see see NEW_FEATURES.txt https://github.com/smarty-php/smarty/issues/194 https://github.com/smarty-php/smarty/issues/186 https://github.com/smarty-php/smarty/issues/179 - bugfix correct Autoloader update of 2.3.2014 https://github.com/smarty-php/smarty/issues/199 - + 04.03.2016 - bugfix change from 01.03.2016 will cause $smarty->isCached(..) failure if called multiple time for same template (forum topic 25935) - + 02.03.2016 - revert autoloader optimizations because of unexplainable warning when using plugins https://github.com/smarty-php/smarty/issues/199 - + 01.03.2016 - bugfix template objects must be cached on $smarty->fetch('foo.tpl) calls incase the template is fetched multiple times (forum topic 25909) - + 25.02.2016 - bugfix wrong _realpath with 4 or more parent-directories https://github.com/smarty-php/smarty/issues/190 - optimization of _realpath @@ -335,10 +335,10 @@ 20.02.2016 - bugfix {strip} must keep space between hmtl tags. Broken by changes of 10.2.2016 https://github.com/smarty-php/smarty/issues/184 - new feature/bugfix {foreach}{section} add 'properties' attribute to force compilation of loop properties - see NEW_FEATURES.txt https://github.com/smarty-php/smarty/issues/189 - + see NEW_FEATURES.txt https://github.com/smarty-php/smarty/issues/189 + 19.02.2016 - - revert output buffer flushing on display, echo content again because possible problems when PHP files had + - revert output buffer flushing on display, echo content again because possible problems when PHP files had characters (newline} after ?> at file end https://github.com/smarty-php/smarty/issues/187 14.02.2016 @@ -349,33 +349,33 @@ - optimization make compiler tag object cache static for higher compilation speed 11.02.2016 - - improvement added KnockoutJS comments to trimwhitespace outputfilter https://github.com/smarty-php/smarty/issues/82 + - improvement added KnockoutJS comments to trimwhitespace outputfilter https://github.com/smarty-php/smarty/issues/82 https://github.com/smarty-php/smarty/pull/181 - + 10.02.2016 - bugfix {strip} must keep space on output creating smarty tags within html tags https://github.com/smarty-php/smarty/issues/177 - bugfix wrong precedence on special if conditions like '$foo is ... by $bar' could cause wrong code https://github.com/smarty-php/smarty/issues/178 - improvement because of ambiguities the inline constant support has been removed from the $foo.bar syntax https://github.com/smarty-php/smarty/issues/149 - - bugfix other {strip} error with output tags between hmtl https://github.com/smarty-php/smarty/issues/180 + - bugfix other {strip} error with output tags between hmtl https://github.com/smarty-php/smarty/issues/180 09.02.2016 - move some code from parser into compiler - reformat all code for unique style - update/bugfix scope attribute handling reworked. Read the newfeatures.txt file - + 05.02.2016 - improvement internal compiler changes - + 01.02.2016 - bugfix {foreach} compilation failed when $smarty->merge_compiled_includes = true and pre-filters are used. 29.01.2016 - bugfix implement replacement code for _tag_stack property https://github.com/smarty-php/smarty/issues/151 - + 28.01.2016 - bugfix allow windows network filepath or wrapper (forum topic 25876) https://github.com/smarty-php/smarty/issues/170 - bugfix if fetch('foo.tpl') is called on a template object the $parent parameter should default to the calling template object https://github.com/smarty-php/smarty/issues/152 - + 27.01.2016 - revert bugfix compiling {section} did create warning - bugfix {$smarty.section.customer.loop} did throw compiler error https://github.com/smarty-php/smarty/issues/161 @@ -385,7 +385,7 @@ - bugfix {extends} with relative file path did not work https://github.com/smarty-php/smarty/issues/154 https://github.com/smarty-php/smarty/issues/158 - bugfix {capture} data could not been seen in other templates with {$smarty.capture.name} https://github.com/smarty-php/smarty/issues/153 - + 26.01.2016 - improvement observe Smarty::$_CHARSET in debugging console https://github.com/smarty-php/smarty/issues/169 - bugfix compiling {section} did create warning @@ -395,28 +395,28 @@ - update scope handling - optimize block plugin compiler - improvement runtime checks if registered block plugins are callable - + 01.01.2016 - remove Smarty::$resource_cache_mode property - + 31.12.2015 - optimization of {assign}, {if} and {while} compiled code - + 30.12.2015 - bugfix plugin names starting with "php" did not compile https://github.com/smarty-php/smarty/issues/147 29.12.2015 - bugfix Smarty::error_reporting was not observed when display() or fetch() was called on template objects https://github.com/smarty-php/smarty/issues/145 - + 28.12.2015 - optimization of {foreach} code size and processing - + 27.12.2015 - improve inheritance code - update external methods - code fixes - PHPdoc updates - + 25.12.2015 - compile {block} tag code and its processing into classes - optimization replace hhvm extension by inline code @@ -430,45 +430,45 @@ - optimization move internal method decodeProperties back into template object - optimization move subtemplate processing back into template object - new feature Caching does now observe the template_dir setting and will create separate cache files if required - + 22.12.2015 - change $xxx_dir properties from private to protected in case Smarty class gets extended - code optimizations - + 21.12.2015 - bugfix a filepath starting with '/' or '\' on windows should normalize to the root dir of current working drive https://github.com/smarty-php/smarty/issues/134 - optimization of filepath normalization - bugfix {strip} must remove all blanks between html tags https://github.com/smarty-php/smarty/issues/136 - + ===== 3.1.29 ===== (21.12.2015) 21.12.2015 - optimization improve speed of filetime checks on extends and extendsall resource - + 20.12.2015 - bugfix failure when the default resource type was set to 'extendsall' https://github.com/smarty-php/smarty/issues/123 - update compilation of Smarty special variables - bugfix add addition check for OS type on normalization of file path https://github.com/smarty-php/smarty/issues/134 - bugfix the source uid of the extendsall resource must contain $template_dir settings https://github.com/smarty-php/smarty/issues/123 - + 19.12.2015 - bugfix using $smarty.capture.foo in expressions could fail https://github.com/smarty-php/smarty/pull/138 - bugfix broken PHP 5.2 compatibility https://github.com/smarty-php/smarty/issues/139 - remove no longer used code - improvement make sure that compiled and cache templates never can contain a trailing '?>? - + 18.12.2015 - bugfix regression when modifier parameter was followed by math https://github.com/smarty-php/smarty/issues/132 - + 17.12.2015 - bugfix {$smarty.capture.nameFail} did lowercase capture name https://github.com/smarty-php/smarty/issues/135 - bugfix using {block append/prepend} on same block in multiple levels of inheritance templates could fail (forum topic 25827) - bugfix text content consisting of just a single '0' like in {if true}0{/if} was suppressed (forum topic 25834) - + 16.12.2015 - bugfix {foreach} did fail if from atrribute is a Generator class https://github.com/smarty-php/smarty/issues/128 - bugfix direct access $smarty->template_dir = 'foo'; should call Smarty::setTemplateDir() https://github.com/smarty-php/smarty/issues/121 - + 15.12.2015 - bugfix {$smarty.cookies.foo} did return the $_COOKIE array not the 'foo' value https://github.com/smarty-php/smarty/issues/122 - bugfix a call to clearAllCache() and other should clear all internal template object caches (forum topic 25828) @@ -476,25 +476,25 @@ 14.12.2015 - bugfix {$smarty.config.foo} broken in 3.1.28 https://github.com/smarty-php/smarty/issues/120 - bugfix multiple calls of {section} with same name droped E_NOTICE error https://github.com/smarty-php/smarty/issues/118 - + ===== 3.1.28 ===== (13.12.2015) 13.12.2015 - bugfix {foreach} and {section} with uppercase characters in name attribute did not work (forum topic 25819) - bugfix $smarty->debugging_ctrl = 'URL' did not work (forum topic 25811) - bugfix Debug Console could display incorrect data when using subtemplates - + 09.12.2015 - bugfix Smarty did fail under PHP 7.0.0 with use_include_path = true; - + 09.12.2015 - bugfix {strip} should exclude some html tags from stripping, related to fix for https://github.com/smarty-php/smarty/issues/111 - + 08.12.2015 - bugfix internal template function data got stored in wrong compiled file https://github.com/smarty-php/smarty/issues/114 - + 05.12.2015 -bugfix {strip} should insert a single space https://github.com/smarty-php/smarty/issues/111 - + 25.11.2015 -bugfix a left delimter like '[%' did fail on [%$var_[%$variable%]%] (forum topic 25798) @@ -503,7 +503,7 @@ 01.11.2015 - update config file processing - + 31.10.2015 - bugfix add missing $trusted_dir property to SmartyBC class (forum topic 25751) @@ -527,7 +527,7 @@ 18.09.2015 - bugfix {if $foo instanceof $bar} failed to compile if 2nd value is a variable https://github.com/smarty-php/smarty/issues/92 - + 17.09.2015 - bugfix {foreach} first attribute was not correctly reset since commit 05a8fa2 of 02.08.2015 https://github.com/smarty-php/smarty/issues/90 @@ -541,7 +541,7 @@ - move code of {call} processing back into Smarty_Internal_Template class - improvement invalidate OPCACHE for cleared compiled and cached template files (forum topic 25557) - bugfix unintended multiple debug windows (forum topic 25699) - + 30.08.2015 - size optimization move some runtime functions into extension - optimize inline template processing @@ -690,10 +690,10 @@ 01.06.2015 - bugfix including template variables broken since 3.1.22 https://github.com/smarty-php/smarty/issues/47 - + 27.05.2015 - bugfix {include} with variable file name must not create by default individual cache file (since 3.1.22) https://github.com/smarty-php/smarty/issues/43 - + 24.05.2015 - bugfix if condition string 'neq' broken due to a typo https://github.com/smarty-php/smarty/issues/42 @@ -701,11 +701,11 @@ 23.05.2015 - improvement on php_handling to allow very large PHP sections, better error handling - improvement allow extreme large comment sections (forum 25538) - + 21.05.2015 - bugfix broken PHP 5.2 compatibility when compiling 1 did compile into wrong code https://github.com/smarty-php/smarty/issues/41 - + 19.05.2015 - bugfix compiler did overwrite existing variable value when setting the nocache attribute https://github.com/smarty-php/smarty/issues/39 - bugfix output filter trimwhitespace could run into the pcre.backtrack_limit on large output (code.google issue 220) @@ -713,14 +713,14 @@ 18.05.2015 - improvement introduce shortcuts in lexer/parser rules for most frequent terms for higher - compilation speed + compilation speed 16.05.2015 - bugfix {php}{/php} did work just for single lines https://github.com/smarty-php/smarty/issues/33 - improvement remove not needed ?> handling from parser to new compiler module 05.05.2015 - bugfix code could be messed up when {tags} are used in multiple attributes https://github.com/smarty-php/smarty/issues/23 - + 04.05.2015 - bugfix Smarty_Resource::parseResourceName incompatible with Google AppEngine (https://github.com/smarty-php/smarty/issues/22) - improvement use is_file() checks to avoid errors suppressed by @ which could still cause problems (https://github.com/smarty-php/smarty/issues/24) @@ -770,13 +770,13 @@ 28.04.2015 - bugfix plugins of merged subtemplates not loaded in 3.1.22-dev (forum topic 25508) - - 23.04.2015 + + 23.04.2015 - bugfix a nocache template variable used as parameter at {insert} was by mistake cached - + 20.04.2015 - bugfix at a template function containing nocache code a parmeter could overwrite a template variable of same name - + 27.03.2015 - bugfix Smarty_Security->allow_constants=false; did also disable true, false and null (change of 16.03.2015) - improvement added a whitelist for trusted constants to security Smarty_Security::$trusted_constants (forum topic 25471) @@ -784,39 +784,39 @@ 20.03.2015 - bugfix make sure that function properties get saved only in compiled files containing the fuction definition {forum topic 25452} - bugfix correct update of global variable values on exit of template functions. (reported under Smarty Developers) - + 16.03.2015 - bugfix problems with {function}{/function} and {call} tags in different subtemplate cache files {forum topic 25452} - bugfix Smarty_Security->allow_constants=false; did not disallow direct usage of defined constants like {SMARTY_DIR} {forum topic 25457} - bugfix {block}{/block} tags did not work inside double quoted strings https://github.com/smarty-php/smarty/issues/18 - - + + 15.03.2015 - bugfix $smarty->compile_check must be restored before rendering of a just updated cache file {forum 25452} - + 14.03.2015 - bugfix {nocache} {/nocache} tags corrupted code when used within a nocache section caused by a nocache template variable. - + - bugfix template functions defined with {function} in an included subtemplate could not be called in nocache mode with {call... nocache} if the subtemplate had it's own cache file {forum 25452} - + 10.03.2015 - bugfix {include ... nocache} whith variable file or compile_id attribute was not executed in nocache mode. - + 12.02.2015 - bugfix multiple Smarty::fetch() of same template when $smarty->merge_compiled_includes = true; could cause function already defined error - + 11.02.2015 - bugfix recursive {includes} did create E_NOTICE message when $smarty->merge_compiled_includes = true; (github issue #16) - + 22.01.2015 - new feature security can now control access to static methods and properties see also NEW_FEATURES.txt 21.01.2015 - bugfix clearCompiledTemplates(), clearAll() and clear() could try to delete whole drive at wrong path permissions because realpath() fail (forum 25397) - - bugfix 'self::' and 'parent::' was interpreted in template syntax as static class - + - bugfix 'self::' and 'parent::' was interpreted in template syntax as static class + 04.01.2015 - push last weeks changes to github @@ -827,10 +827,10 @@ - optimization restructure config file processing 31.12.2014 - - bugfix use function_exists('mb_get_info') for setting Smarty::$_MBSTRING. + - bugfix use function_exists('mb_get_info') for setting Smarty::$_MBSTRING. Function mb_split could be overloaded depending on php.ini mbstring.func_overload - - + + 29.12.2014 - new feature security can now limit the template nesting level by property $max_template_nesting see also NEW_FEATURES.txt (forum 25370) @@ -844,14 +844,14 @@ 13.12.2014 - improvement optimization of lexer and parser resulting in a up to 30% higher compiling speed - + 11.12.2014 - bugfix resolve parser ambiguity between constant print tag {CONST} and other smarty tags after change of 09.12.2014 - + 09.12.2014 - bugfix variables $null, $true and $false did not work after the change of 12.11.2014 (forum 25342) - bugfix call of template function by a variable name did not work after latest changes (forum 25342) - + 23.11.2014 - bugfix a plugin with attached modifier could fail if the tag was immediately followed by another Smarty tag (since 3.1.21) (forum 25326) @@ -869,12 +869,12 @@ 04.11.2014 - new feature $smarty->debugging = true; => overwrite existing Debug Console window (old behaviour) $smarty->debugging = 2; => individual Debug Console window by template name - + 03.11.2014 - bugfix Debug Console did not show included subtemplates since 3.1.17 (forum 25301) - bugfix Modifier debug_print_var did not limit recursion or prevent recursive object display at Debug Console (ATTENTION: parameter order has changed to be able to specify maximum recursion) - - bugfix Debug consol did not include subtemplate information with $smarty->merge_compiled_includes = true + - bugfix Debug consol did not include subtemplate information with $smarty->merge_compiled_includes = true - improvement The template variables are no longer displayed as objects on the Debug Console - improvement $smarty->createData($parent = null, $name = null) new optional name parameter for display at Debug Console - addition of some hooks for future extension of Debug Console @@ -891,7 +891,7 @@ 26.10.2014 - bugfix E_NOTICE message was created during compilation when ASP tags '<%' or '%>' are in template source text - bugfix merge_compiled_includes option failed when caching enables and same subtemplate was included cached and not cached - + ===== 3.1.21 ===== (18.10.2014) 18.10.2014 - composer moved to github @@ -918,143 +918,143 @@ ===== 3.1.20 ===== (09.10.2014) 08.10.2014 - bugfix security mode of "'; - } elseif ($encode == 'javascript_charcode') { + } elseif ($encode === 'javascript_charcode') { $string = '' . $text . ''; for ($x = 0, $y = strlen($string); $x < $y; $x ++) { @@ -123,7 +123,7 @@ function smarty_function_mailto($params) implode(',', $ord) . "))" . "}\n" . "\n"; return $_ret; - } elseif ($encode == 'hex') { + } elseif ($encode === 'hex') { preg_match('!^(.*)(\?.*)$!', $address, $match); if (!empty($match[ 2 ])) { trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING); diff --git a/libs/plugins/function.math.php b/libs/plugins/function.math.php index fc5db335..18054cbf 100644 --- a/libs/plugins/function.math.php +++ b/libs/plugins/function.math.php @@ -38,7 +38,7 @@ function smarty_function_math($params, $template) $equation = $params[ 'equation' ]; // make sure parenthesis are balanced - if (substr_count($equation, "(") != substr_count($equation, ")")) { + if (substr_count($equation, '(') !== substr_count($equation, ')')) { trigger_error("math: unbalanced parenthesis", E_USER_WARNING); return; @@ -59,9 +59,9 @@ function smarty_function_math($params, $template) } foreach ($params as $key => $val) { - if ($key != "equation" && $key != "format" && $key != "assign") { + if ($key !== 'equation' && $key !== 'format' && $key !== 'assign') { // make sure value is not empty - if (strlen($val) == 0) { + if (strlen($val) === 0) { trigger_error("math: parameter '{$key}' is empty", E_USER_WARNING); return; @@ -86,7 +86,7 @@ function smarty_function_math($params, $template) } foreach ($params as $key => $val) { - if ($key != "equation" && $key != "format" && $key != "assign") { + if ($key !== 'equation' && $key !== 'format' && $key !== 'assign') { $equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation); } } diff --git a/libs/plugins/modifier.capitalize.php b/libs/plugins/modifier.capitalize.php index 79c1a4fe..686f869a 100644 --- a/libs/plugins/modifier.capitalize.php +++ b/libs/plugins/modifier.capitalize.php @@ -72,7 +72,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals return $upper_string; } -/* +/* * * Bug: create_function() use exhausts memory when used in long loops * Fix: use declared functions for callbacks instead of using create_function() diff --git a/libs/plugins/modifier.date_format.php b/libs/plugins/modifier.date_format.php index 37cf85f2..325d43b6 100644 --- a/libs/plugins/modifier.date_format.php +++ b/libs/plugins/modifier.date_format.php @@ -42,14 +42,14 @@ function smarty_modifier_date_format($string, $format = null, $default_date = '' } $is_loaded = true; } - if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') { + if ($string !== '' && $string !== '0000-00-00' && $string !== '0000-00-00 00:00:00') { $timestamp = smarty_make_timestamp($string); - } elseif ($default_date != '') { + } elseif ($default_date !== '') { $timestamp = smarty_make_timestamp($default_date); } else { return; } - if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) { + if ($formatter === 'strftime' || ($formatter === 'auto' && strpos($format, '%') !== false)) { if (Smarty::$_IS_WINDOWS) { $_win_from = array('%D', '%h', diff --git a/libs/plugins/modifier.debug_print_var.php b/libs/plugins/modifier.debug_print_var.php index 34f85dcd..2eb61dd8 100644 --- a/libs/plugins/modifier.debug_print_var.php +++ b/libs/plugins/modifier.debug_print_var.php @@ -28,7 +28,7 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = switch (gettype($var)) { case 'array' : $results = 'Array (' . count($var) . ')'; - if ($depth == $max) { + if ($depth === $max) { break; } foreach ($var as $curr_key => $curr_val) { @@ -46,7 +46,7 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = $results .= ' called recursive'; break; } - if ($depth == $max) { + if ($depth === $max) { break; } $objects[] = $var; diff --git a/libs/plugins/modifier.truncate.php b/libs/plugins/modifier.truncate.php index 6fe84425..0f79dd26 100644 --- a/libs/plugins/modifier.truncate.php +++ b/libs/plugins/modifier.truncate.php @@ -27,7 +27,7 @@ */ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) { - if ($length == 0) { + if ($length === 0) { return ''; } diff --git a/libs/plugins/modifiercompiler.count_characters.php b/libs/plugins/modifiercompiler.count_characters.php index f752d861..d2c9a4cf 100644 --- a/libs/plugins/modifiercompiler.count_characters.php +++ b/libs/plugins/modifiercompiler.count_characters.php @@ -21,7 +21,7 @@ */ function smarty_modifiercompiler_count_characters($params) { - if (!isset($params[ 1 ]) || $params[ 1 ] != 'true') { + if (!isset($params[ 1 ]) || $params[ 1 ] !== 'true') { return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)'; } if (Smarty::$_MBSTRING) { diff --git a/libs/plugins/modifiercompiler.strip_tags.php b/libs/plugins/modifiercompiler.strip_tags.php index e56bf931..af2c3911 100644 --- a/libs/plugins/modifiercompiler.strip_tags.php +++ b/libs/plugins/modifiercompiler.strip_tags.php @@ -21,7 +21,7 @@ */ function smarty_modifiercompiler_strip_tags($params) { - if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') == 'true') { + if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') === 'true') { return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})"; } else { return 'strip_tags(' . $params[ 0 ] . ')'; diff --git a/libs/plugins/modifiercompiler.unescape.php b/libs/plugins/modifiercompiler.unescape.php index a3409bc7..396ad7ea 100644 --- a/libs/plugins/modifiercompiler.unescape.php +++ b/libs/plugins/modifiercompiler.unescape.php @@ -26,7 +26,7 @@ function smarty_modifiercompiler_unescape($params) if (!isset($params[ 2 ])) { $params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\''; } else { - $params[ 2 ] = "'" . $params[ 2 ] . "'"; + $params[ 2 ] = "'{$params[ 2 ]}'"; } switch (trim($params[ 1 ], '"\'')) { diff --git a/libs/plugins/outputfilter.trimwhitespace.php b/libs/plugins/outputfilter.trimwhitespace.php index 1a67123a..70a66d3d 100644 --- a/libs/plugins/outputfilter.trimwhitespace.php +++ b/libs/plugins/outputfilter.trimwhitespace.php @@ -24,7 +24,7 @@ function smarty_outputfilter_trimwhitespace($source) $_offset = 0; // Unify Line-Breaks to \n - $source = preg_replace("/\015\012|\015|\012/", "\n", $source); + $source = preg_replace('/\015\012|\015|\012/', "\n", $source); // capture Internet Explorer and KnockoutJS Conditional Comments if (preg_match_all('##is', $source, $matches, diff --git a/libs/plugins/shared.make_timestamp.php b/libs/plugins/shared.make_timestamp.php index 67f86244..02881166 100644 --- a/libs/plugins/shared.make_timestamp.php +++ b/libs/plugins/shared.make_timestamp.php @@ -25,7 +25,7 @@ function smarty_make_timestamp($string) (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface) ) { return (int) $string->format('U'); // PHP 5.2 BC - } elseif (strlen($string) == 14 && ctype_digit($string)) { + } elseif (strlen($string) === 14 && ctype_digit($string)) { // it is mysql timestamp format of YYYYMMDDHHMMSS? return mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2), substr($string, 4, 2), substr($string, 6, 2), substr($string, 0, 4)); @@ -35,7 +35,7 @@ function smarty_make_timestamp($string) } else { // strtotime should handle it $time = strtotime($string); - if ($time == - 1 || $time === false) { + if ($time === - 1 || $time === false) { // strtotime() was not able to parse $string, use "now": return time(); } diff --git a/libs/plugins/shared.mb_unicode.php b/libs/plugins/shared.mb_unicode.php index 0f790b56..7450148a 100644 --- a/libs/plugins/shared.mb_unicode.php +++ b/libs/plugins/shared.mb_unicode.php @@ -20,12 +20,12 @@ function smarty_mb_to_unicode($string, $encoding = null) { if ($encoding) { - $expanded = mb_convert_encoding($string, "UTF-32BE", $encoding); + $expanded = mb_convert_encoding($string, 'UTF-32BE', $encoding); } else { - $expanded = mb_convert_encoding($string, "UTF-32BE"); + $expanded = mb_convert_encoding($string, 'UTF-32BE'); } - return unpack("N*", $expanded); + return unpack('N*', $expanded); } /** @@ -46,8 +46,8 @@ function smarty_mb_from_unicode($unicode, $encoding = null) $encoding = mb_internal_encoding(); } foreach ((array) $unicode as $utf32be) { - $character = pack("N*", $utf32be); - $t .= mb_convert_encoding($character, $encoding, "UTF-32BE"); + $character = pack('N*', $utf32be); + $t .= mb_convert_encoding($character, $encoding, 'UTF-32BE'); } return $t; diff --git a/libs/sysplugins/smarty_cacheresource_custom.php b/libs/sysplugins/smarty_cacheresource_custom.php index b3f4c1b2..7a5920f4 100644 --- a/libs/sysplugins/smarty_cacheresource_custom.php +++ b/libs/sysplugins/smarty_cacheresource_custom.php @@ -138,7 +138,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource $_smarty_tpl->compile_id, $content, $timestamp); } if (isset($content)) { - eval("?>" . $content); + eval('?>' . $content); $cached->content = null; return true; } diff --git a/libs/sysplugins/smarty_cacheresource_keyvaluestore.php b/libs/sysplugins/smarty_cacheresource_keyvaluestore.php index 47e010a7..ff065a27 100644 --- a/libs/sysplugins/smarty_cacheresource_keyvaluestore.php +++ b/libs/sysplugins/smarty_cacheresource_keyvaluestore.php @@ -104,7 +104,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource } } if (isset($content)) { - eval("?>" . $content); + eval('?>' . $content); return true; } @@ -273,8 +273,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource */ protected function addMetaTimestamp(&$content) { - $mt = explode(" ", microtime()); - $ts = pack("NN", $mt[ 1 ], (int) ($mt[ 0 ] * 100000000)); + $mt = explode(' ', microtime()); + $ts = pack('NN', $mt[ 1 ], (int) ($mt[ 0 ] * 100000000)); $content = $ts . $content; } @@ -371,7 +371,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource /** * Translate a CacheID into the list of applicable InvalidationKeys. - * Splits "some|chain|into|an|array" into array( '#clearAll#', 'some', 'some|chain', 'some|chain|into', ... ) + * Splits 'some|chain|into|an|array' into array( '#clearAll#', 'some', 'some|chain', 'some|chain|into', ... ) * * @param string $cid CacheID to translate * @param string $resource_name template name diff --git a/libs/sysplugins/smarty_data.php b/libs/sysplugins/smarty_data.php index b9f5de9a..743b117b 100644 --- a/libs/sysplugins/smarty_data.php +++ b/libs/sysplugins/smarty_data.php @@ -61,8 +61,8 @@ class Smarty_Data extends Smarty_Internal_Data foreach ($_parent as $_key => $_val) { $this->tpl_vars[ $_key ] = new Smarty_Variable($_val); } - } elseif ($_parent != null) { - throw new SmartyException("Wrong type for template variables"); + } elseif ($_parent !== null) { + throw new SmartyException('Wrong type for template variables'); } } } diff --git a/libs/sysplugins/smarty_internal_block.php b/libs/sysplugins/smarty_internal_block.php index 596b6a30..780319f1 100644 --- a/libs/sysplugins/smarty_internal_block.php +++ b/libs/sysplugins/smarty_internal_block.php @@ -67,7 +67,7 @@ class Smarty_Internal_Block /** * Smarty_Internal_Block constructor. - * - if outer level {block} of child template ($state == 1) save it as child root block + * - if outer level {block} of child template ($state === 1) save it as child root block * - otherwise process inheritance and render * * @param string $name block name diff --git a/libs/sysplugins/smarty_internal_cacheresource_file.php b/libs/sysplugins/smarty_internal_cacheresource_file.php index 942c003c..f6ef0930 100644 --- a/libs/sysplugins/smarty_internal_cacheresource_file.php +++ b/libs/sysplugins/smarty_internal_cacheresource_file.php @@ -93,7 +93,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource { $_smarty_tpl->cached->valid = false; if ($update && defined('HHVM_VERSION')) { - eval("?>" . file_get_contents($_smarty_tpl->cached->filepath)); + eval('?>' . file_get_contents($_smarty_tpl->cached->filepath)); return true; } else { return @include $_smarty_tpl->cached->filepath; @@ -116,7 +116,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource $_template->smarty) === true ) { if (function_exists('opcache_invalidate') && - (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api"))) < 1 + (!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api'))) < 1 ) { opcache_invalidate($_template->cached->filepath, true); } else if (function_exists('apc_compile_file')) { diff --git a/libs/sysplugins/smarty_internal_compile_assign.php b/libs/sysplugins/smarty_internal_compile_assign.php index 3bd33847..5ec7a183 100644 --- a/libs/sysplugins/smarty_internal_compile_assign.php +++ b/libs/sysplugins/smarty_internal_compile_assign.php @@ -71,7 +71,7 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase $_scope = $compiler->convertScope($_attr, $this->valid_scopes); } // optional parameter - $_params = ""; + $_params = ''; if ($_nocache || $_scope) { $_params .= ' ,' . var_export($_nocache, true); } diff --git a/libs/sysplugins/smarty_internal_compile_block.php b/libs/sysplugins/smarty_internal_compile_block.php index e3239031..753e6d8e 100644 --- a/libs/sysplugins/smarty_internal_compile_block.php +++ b/libs/sysplugins/smarty_internal_compile_block.php @@ -67,7 +67,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher if (!isset($compiler->_cache['blockNesting'])) { $compiler->_cache['blockNesting'] = 0; } - if ($compiler->_cache['blockNesting'] == 0) { + if ($compiler->_cache['blockNesting'] === 0) { // make sure that inheritance gets initialized in template code $this->registerInit($compiler); $this->option_flags = array('hide', 'nocache', 'append', 'prepend'); @@ -115,12 +115,12 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher { $name = isset($parameter[1]) ? $compiler->getId($parameter[1]) : false; if (!$name) { - $compiler->trigger_template_error("invalid \"\$smarty.block\" expected \"\$smarty.block.child\" or \"\$smarty.block.parent\"", + $compiler->trigger_template_error("invalid '\$smarty.block' expected '\$smarty.block.child' or '\$smarty.block.parent'", null, true); } if (!isset($compiler->_cache['blockNesting'])) { - $compiler->trigger_template_error(" \"\$smarty.block.{$name}\" used outside {block} tags ", + $compiler->trigger_template_error(" '\$smarty.block.{$name}' used outside {block} tags ", $compiler->parser->lex->taglineno); } $compiler->has_code = true; @@ -134,7 +134,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher return '$_smarty_tpl->inheritance->callParent($_smarty_tpl, $this, null, true)'; break; default: - $compiler->trigger_template_error("invalid \"\$smarty.block.{$name}\" expected \"\$smarty.block.child\" or \"\$smarty.block.parent\"", + $compiler->trigger_template_error("invalid '\$smarty.block.{$name}' expected '\$smarty.block.child' or '\$smarty.block.parent'", null, true); } @@ -166,7 +166,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_ $_assign = isset($_attr['assign']) ? $_attr['assign'] : null; unset($_attr['assign'], $_attr['name']); foreach ($_attr as $name => $stat) { - if ((is_bool($stat) && $stat !== false) || (!is_bool($stat) && $stat != 'false')) { + if ((is_bool($stat) && $stat !== false) || (!is_bool($stat) && $stat !== 'false')) { $_block[ $name ] = 'true'; } } @@ -225,14 +225,14 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_ $compiler->nocache = $_nocache; $compiler->parser->current_buffer = $_buffer; $output = "_cache['blockNesting'] == 1) { + if ($compiler->_cache['blockNesting'] === 1) { $output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name);\n"; } else { $output .= "\$_smarty_tpl->inheritance->instanceBlock(\$_smarty_tpl, '$_className', $_name, \$this->tplIndex);\n"; } $output .= "?>\n"; $compiler->_cache['blockNesting']--; - if ($compiler->_cache['blockNesting'] == 0) { + if ($compiler->_cache['blockNesting'] === 0) { unset($compiler->_cache['blockNesting']); } $compiler->has_code = true; diff --git a/libs/sysplugins/smarty_internal_compile_break.php b/libs/sysplugins/smarty_internal_compile_break.php index ce162cb5..8879dff9 100644 --- a/libs/sysplugins/smarty_internal_compile_break.php +++ b/libs/sysplugins/smarty_internal_compile_break.php @@ -99,7 +99,7 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase } $stack_count --; } - if ($level_count != 0) { + if ($level_count !== 0) { $compiler->trigger_template_error("cannot {$tag} {$levels} level(s)", null, true); } if ($lastTag === 'foreach' && $tag === 'break') { diff --git a/libs/sysplugins/smarty_internal_compile_call.php b/libs/sysplugins/smarty_internal_compile_call.php index 739df5ec..eb444d35 100644 --- a/libs/sysplugins/smarty_internal_compile_call.php +++ b/libs/sysplugins/smarty_internal_compile_call.php @@ -57,7 +57,7 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase // output will be stored in a smarty variable instead of being displayed $_assign = $_attr[ 'assign' ]; } - //$_name = trim($_attr['name'], "'\""); + //$_name = trim($_attr['name'], "''"); $_name = $_attr[ 'name' ]; unset($_attr[ 'name' ], $_attr[ 'assign' ], $_attr[ 'nocache' ]); // set flag (compiled code of {function} must be included in cache file @@ -74,7 +74,7 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase $_paramsArray[] = "'$_key'=>$_value"; } } - $_params = 'array(' . implode(",", $_paramsArray) . ')'; + $_params = 'array(' . implode(',', $_paramsArray) . ')'; //$compiler->suppressNocacheProcessing = true; // was there an assign attribute if (isset($_assign)) { diff --git a/libs/sysplugins/smarty_internal_compile_eval.php b/libs/sysplugins/smarty_internal_compile_eval.php index 97a3c29c..550f194e 100644 --- a/libs/sysplugins/smarty_internal_compile_eval.php +++ b/libs/sysplugins/smarty_internal_compile_eval.php @@ -58,13 +58,12 @@ class Smarty_Internal_Compile_Eval extends Smarty_Internal_CompileBase } // create template object - $_output = "\$_template = new {$compiler->smarty->template_class}('eval:'." . $_attr[ 'var' ] . - ", \$_smarty_tpl->smarty, \$_smarty_tpl);"; + $_output = "\$_template = new {$compiler->smarty->template_class}('eval:'.{$_attr[ 'var' ]}, \$_smarty_tpl->smarty, \$_smarty_tpl);"; //was there an assign attribute? if (isset($_assign)) { $_output .= "\$_smarty_tpl->assign($_assign,\$_template->fetch());"; } else { - $_output .= "echo \$_template->fetch();"; + $_output .= 'echo $_template->fetch();'; } return ""; diff --git a/libs/sysplugins/smarty_internal_compile_extends.php b/libs/sysplugins/smarty_internal_compile_extends.php index 5e0b5899..7617f3af 100644 --- a/libs/sysplugins/smarty_internal_compile_extends.php +++ b/libs/sysplugins/smarty_internal_compile_extends.php @@ -64,18 +64,18 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh // add code to initialize inheritance $this->registerInit($compiler, true); $file = trim($_attr[ 'file' ], '\'"'); - if (strlen($file) > 8 && substr($file, 0, 8) == 'extends:') { + if (strlen($file) > 8 && substr($file, 0, 8) === 'extends:') { // generate code for each template $files = array_reverse(explode('|', substr($file, 8))); $i = 0; foreach ($files as $file) { - if ($file[ 0 ] == '"') { + if ($file[ 0 ] === '"') { $file = trim($file, '".'); } else { $file = "'{$file}'"; } $i ++; - if ($i == count($files) && isset($_attr[ 'extends_resource' ])) { + if ($i === count($files) && isset($_attr[ 'extends_resource' ])) { $this->compileEndChild($compiler); } $this->compileInclude($compiler, $file); @@ -104,14 +104,14 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inh $inlineUids = ''; if (isset($template) && $compiler->smarty->merge_compiled_includes) { $code = $compiler->compileTag('include', array($template, array('scope' => 'parent'))); - if (preg_match("/([,][\s]*['][a-z0-9]+['][,][\s]*[']content.*['])[)]/", $code, $match)) { + if (preg_match('/([,][\s]*[\'][a-z0-9]+[\'][,][\s]*[\']content.*[\'])[)]/', $code, $match)) { $inlineUids = $match[ 1 ]; } } $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser, - "inheritance->endChild(\$_smarty_tpl" . + 'inheritance->endChild($_smarty_tpl' . (isset($template) ? - ', ' . $template . $inlineUids : + ", {$template}{$inlineUids}" : '') . ");\n?>\n"); } diff --git a/libs/sysplugins/smarty_internal_compile_for.php b/libs/sysplugins/smarty_internal_compile_for.php index e5e7c61c..f899769b 100644 --- a/libs/sysplugins/smarty_internal_compile_for.php +++ b/libs/sysplugins/smarty_internal_compile_for.php @@ -35,7 +35,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase public function compile($args, $compiler, $parameter) { $compiler->loopNesting ++; - if ($parameter == 0) { + if ($parameter === 0) { $this->required_attributes = array('start', 'to'); $this->optional_attributes = array('max', 'step'); } else { @@ -47,7 +47,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase $_attr = $this->getAttributes($compiler, $args); $output = "tpl_vars[$var]->total > 0) {\n"; $output .= "for (\$_smarty_tpl->tpl_vars[$var]->value{$index} = $_statement[value], \$_smarty_tpl->tpl_vars[$var]->iteration = 1;\$_smarty_tpl->tpl_vars[$var]->iteration <= \$_smarty_tpl->tpl_vars[$var]->total;\$_smarty_tpl->tpl_vars[$var]->value{$index} += \$_smarty_tpl->tpl_vars[$var]->step, \$_smarty_tpl->tpl_vars[$var]->iteration++) {\n"; - $output .= "\$_smarty_tpl->tpl_vars[$var]->first = \$_smarty_tpl->tpl_vars[$var]->iteration == 1;"; - $output .= "\$_smarty_tpl->tpl_vars[$var]->last = \$_smarty_tpl->tpl_vars[$var]->iteration == \$_smarty_tpl->tpl_vars[$var]->total;"; + $output .= "\$_smarty_tpl->tpl_vars[$var]->first = \$_smarty_tpl->tpl_vars[$var]->iteration === 1;"; + $output .= "\$_smarty_tpl->tpl_vars[$var]->last = \$_smarty_tpl->tpl_vars[$var]->iteration === \$_smarty_tpl->tpl_vars[$var]->total;"; } - $output .= "?>"; + $output .= '?>'; $this->openTag($compiler, 'for', array('for', $compiler->nocache)); // maybe nocache because of nocache variables @@ -161,7 +161,7 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase list($openTag, $compiler->nocache) = $this->closeTag($compiler, array('for', 'forelse')); $output = "\n"; diff --git a/libs/sysplugins/smarty_internal_compile_foreach.php b/libs/sysplugins/smarty_internal_compile_foreach.php index 932d1b03..b6971a19 100644 --- a/libs/sysplugins/smarty_internal_compile_foreach.php +++ b/libs/sysplugins/smarty_internal_compile_foreach.php @@ -118,7 +118,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo $fromName = $compiler->getVariableName($_attr[ 'from' ]); if ($fromName) { foreach (array('item', 'key') as $a) { - if (isset($attributes[ $a ]) && $attributes[ $a ] == $fromName) { + if (isset($attributes[ $a ]) && $attributes[ $a ] === $fromName) { $compiler->trigger_template_error("'{$a}' and 'from' may not have same variable name '{$fromName}'", null, true); } @@ -137,7 +137,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo if (!empty($this->matchResults[ 'named' ])) { $namedAttr = $this->matchResults[ 'named' ]; } - if (isset($_attr[ 'properties' ]) && preg_match_all("/['](.*?)[']/", $_attr[ 'properties' ], $match)) { + if (isset($_attr[ 'properties' ]) && preg_match_all('/[\'](.*?)[\']/', $_attr[ 'properties' ], $match)) { foreach ($match[ 1 ] as $prop) { if (in_array($prop, $this->itemProperties)) { $itemAttr[ $prop ] = true; @@ -229,7 +229,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo $output .= "{$itemVar}->first = !{$itemVar}->index;\n"; } if (isset($itemAttr[ 'last' ])) { - $output .= "{$itemVar}->last = {$itemVar}->iteration == {$itemVar}->total;\n"; + $output .= "{$itemVar}->last = {$itemVar}->iteration === {$itemVar}->total;\n"; } if (isset($foreachVar)) { if (isset($namedAttr[ 'iteration' ])) { @@ -242,13 +242,13 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo $output .= "{$foreachVar}->value['first'] = !{$foreachVar}->value['index'];\n"; } if (isset($namedAttr[ 'last' ])) { - $output .= "{$foreachVar}->value['last'] = {$foreachVar}->value['iteration'] == {$foreachVar}->value['total'];\n"; + $output .= "{$foreachVar}->value['last'] = {$foreachVar}->value['iteration'] === {$foreachVar}->value['total'];\n"; } } if (!empty($itemAttr)) { $output .= "{$local}saved = {$itemVar};\n"; } - $output .= "?>"; + $output .= '?>'; return $output; } @@ -290,7 +290,7 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase list($openTag, $nocache, $local, $itemVar, $restore) = $this->closeTag($compiler, array('foreach')); $this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $local, $itemVar, 0)); $output = "\n"; @@ -327,7 +327,7 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase $this->closeTag($compiler, array('foreach', 'foreachelse')); $output = " 0) { diff --git a/libs/sysplugins/smarty_internal_compile_function.php b/libs/sysplugins/smarty_internal_compile_function.php index 3badf8ce..bcb1f8aa 100644 --- a/libs/sysplugins/smarty_internal_compile_function.php +++ b/libs/sysplugins/smarty_internal_compile_function.php @@ -59,7 +59,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase $compiler->trigger_template_error('nocache option not allowed', null, true); } unset($_attr[ 'nocache' ]); - $_name = trim($_attr[ 'name' ], "'\""); + $_name = trim($_attr[ 'name' ], '\'"'); $compiler->parent_compiler->tpl_function[ $_name ] = array(); $save = array($_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code, $compiler->template->caching); @@ -100,7 +100,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $this->compiler = $compiler; $saved_data = $this->closeTag($compiler, array('function')); $_attr = $saved_data[ 0 ]; - $_name = trim($_attr[ 'name' ], "'\""); + $_name = trim($_attr[ 'name' ], '\'"'); $compiler->parent_compiler->tpl_function[ $_name ][ 'compiled_filepath' ] = $compiler->parent_compiler->template->compiled->filepath; $compiler->parent_compiler->tpl_function[ $_name ][ 'uid' ] = $compiler->template->source->uid; @@ -116,7 +116,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase } } if (!empty($_paramsArray)) { - $_params = 'array(' . implode(",", $_paramsArray) . ')'; + $_params = 'array(' . implode(',', $_paramsArray) . ')'; $_paramsCode = "\$params = array_merge($_params, \$params);\n"; } else { $_paramsCode = ''; @@ -198,7 +198,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase /** * Remove nocache code - * + * * @param $match * * @return string diff --git a/libs/sysplugins/smarty_internal_compile_if.php b/libs/sysplugins/smarty_internal_compile_if.php index bf4e04e3..82436c26 100644 --- a/libs/sysplugins/smarty_internal_compile_if.php +++ b/libs/sysplugins/smarty_internal_compile_if.php @@ -34,8 +34,8 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase // must whole block be nocache ? $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; - if (!array_key_exists("if condition", $parameter)) { - $compiler->trigger_template_error("missing if condition", null, true); + if (!isset($parameter['if condition'])) { + $compiler->trigger_template_error('missing if condition', null, true); } if (is_array($parameter[ 'if condition' ])) { @@ -49,9 +49,9 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase $compiler->setNocacheInVariable($var); } $prefixVar = $compiler->getNewPrefixVariable(); - $_output = "\n"; + $_output = "\n"; $assignAttr = array(); - $assignAttr[][ 'value' ] = "{$prefixVar}"; + $assignAttr[][ 'value' ] = $prefixVar; $assignCompiler = new Smarty_Internal_Compile_Assign(); if (is_array($parameter[ 'if condition' ][ 'var' ])) { $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; @@ -90,7 +90,7 @@ class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif')); $this->openTag($compiler, 'else', array($nesting, $compiler->tag_nocache)); - return ""; + return ''; } } @@ -119,8 +119,8 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif')); - if (!array_key_exists("if condition", $parameter)) { - $compiler->trigger_template_error("missing elseif condition", null, true); + if (!isset($parameter['if condition'])) { + $compiler->trigger_template_error('missing elseif condition', null, true); } $assignCode = ''; @@ -137,10 +137,10 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase $compiler->setNocacheInVariable($var); } $prefixVar = $compiler->getNewPrefixVariable(); - $assignCode = "\n"; + $assignCode = "\n"; $assignCompiler = new Smarty_Internal_Compile_Assign(); $assignAttr = array(); - $assignAttr[][ 'value' ] = "{$prefixVar}"; + $assignAttr[][ 'value' ] = $prefixVar; if (is_array($parameter[ 'if condition' ][ 'var' ])) { $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ]; $assignCode .= $assignCompiler->compile($assignAttr, $compiler, diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/libs/sysplugins/smarty_internal_compile_include.php index 02b09f7a..f6d456cb 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/libs/sysplugins/smarty_internal_compile_include.php @@ -312,7 +312,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase $compiled_code .= $tpl->compiler->postFilter($tpl->compiler->blockOrFunctionCode); $compiled_code .= ""; + $compiled_code .= '?>'; unset($tpl->compiler); if ($tpl->compiled->has_nocache_code) { // replace nocache_hash diff --git a/libs/sysplugins/smarty_internal_compile_include_php.php b/libs/sysplugins/smarty_internal_compile_include_php.php index ce96b7ec..e0aca93b 100644 --- a/libs/sysplugins/smarty_internal_compile_include_php.php +++ b/libs/sysplugins/smarty_internal_compile_include_php.php @@ -81,7 +81,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase } } } - if ($_filepath == false) { + if ($_filepath === false) { $compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", null, true); } if (isset($compiler->smarty->security_policy)) { @@ -93,7 +93,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase } $_once = '_once'; if (isset($_attr[ 'once' ])) { - if ($_attr[ 'once' ] == 'false') { + if ($_attr[ 'once' ] === 'false') { $_once = ''; } } diff --git a/libs/sysplugins/smarty_internal_compile_insert.php b/libs/sysplugins/smarty_internal_compile_insert.php index bcab8a81..bac0c801 100644 --- a/libs/sysplugins/smarty_internal_compile_insert.php +++ b/libs/sysplugins/smarty_internal_compile_insert.php @@ -70,7 +70,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase // output will be stored in a smarty variable instead of being displayed $_assign = $_attr[ 'assign' ]; // create variable to make sure that the compiler knows about its nocache status - $var = trim($_attr[ 'assign' ], "'"); + $var = trim($_attr[ 'assign' ], '\''); if (isset($compiler->template->tpl_vars[ $var ])) { $compiler->template->tpl_vars[ $var ]->nocache = true; } else { @@ -101,7 +101,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase } } } - if ($_filepath == false) { + if ($_filepath === false) { $compiler->trigger_template_error("{insert} missing script file '{$_script}'", null, true); } // code for script file loading diff --git a/libs/sysplugins/smarty_internal_compile_private_block_plugin.php b/libs/sysplugins/smarty_internal_compile_private_block_plugin.php index 49837e66..7f8a379c 100644 --- a/libs/sysplugins/smarty_internal_compile_private_block_plugin.php +++ b/libs/sysplugins/smarty_internal_compile_private_block_plugin.php @@ -46,14 +46,14 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi */ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $function = null) { - if (!isset($tag[ 5 ]) || substr($tag, - 5) != 'close') { + if (!isset($tag[ 5 ]) || substr($tag, - 5) !== 'close') { // opening tag of block plugin // check and get attributes $_attr = $this->getAttributes($compiler, $args); $this->nesting ++; unset($_attr[ 'nocache' ]); list($callback, $_paramsArray, $callable) = $this->setup($compiler, $_attr, $tag, $function); - $_params = 'array(' . implode(",", $_paramsArray) . ')'; + $_params = 'array(' . implode(',', $_paramsArray) . ')'; // compile code $output = " $parameter[ 'modifier_list' ], 'value' => 'ob_get_clean()')) . ";\n"; } - $output = "smarty->_cache['_tag_stack']);"; - $output .= "?>"; + $output = "smarty->_cache[\'_tag_stack\']);?>'; } return $output . "\n"; } diff --git a/libs/sysplugins/smarty_internal_compile_private_foreachsection.php b/libs/sysplugins/smarty_internal_compile_private_foreachsection.php index 2fcd8578..6a2ac07d 100644 --- a/libs/sysplugins/smarty_internal_compile_private_foreachsection.php +++ b/libs/sysplugins/smarty_internal_compile_private_foreachsection.php @@ -175,7 +175,7 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com if ($compiler !== $nextCompiler) { // get template source $_content = $nextCompiler->template->source->getContent(); - if ($_content != '') { + if ($_content !== '') { // run pre filter if required if ((isset($nextCompiler->smarty->autoload_filters[ 'pre' ]) || isset($nextCompiler->smarty->registered_filters[ 'pre' ])) diff --git a/libs/sysplugins/smarty_internal_compile_private_function_plugin.php b/libs/sysplugins/smarty_internal_compile_private_function_plugin.php index 7ecf61d2..a6b4b295 100644 --- a/libs/sysplugins/smarty_internal_compile_private_function_plugin.php +++ b/libs/sysplugins/smarty_internal_compile_private_function_plugin.php @@ -60,7 +60,7 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co $_paramsArray[] = "'$_key'=>$_value"; } } - $_params = 'array(' . implode(",", $_paramsArray) . ')'; + $_params = 'array(' . implode(',', $_paramsArray) . ')'; // compile code $output = "{$function}({$_params},\$_smarty_tpl)"; if (!empty($parameter[ 'modifierlist' ])) { diff --git a/libs/sysplugins/smarty_internal_compile_private_modifier.php b/libs/sysplugins/smarty_internal_compile_private_modifier.php index 3a39c2ba..ad442a3f 100644 --- a/libs/sysplugins/smarty_internal_compile_private_modifier.php +++ b/libs/sysplugins/smarty_internal_compile_private_modifier.php @@ -143,7 +143,7 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa } } if (!isset($compiler->known_modifier_type[ $modifier ])) { - $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", null, true); + $compiler->trigger_template_error("unknown modifier '{$modifier}'", null, true); } } diff --git a/libs/sysplugins/smarty_internal_compile_private_object_function.php b/libs/sysplugins/smarty_internal_compile_private_object_function.php index 4ef108fb..c10d1222 100644 --- a/libs/sysplugins/smarty_internal_compile_private_object_function.php +++ b/libs/sysplugins/smarty_internal_compile_private_object_function.php @@ -62,10 +62,10 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co $_paramsArray[] = "'$_key'=>$_value"; } } - $_params = 'array(' . implode(",", $_paramsArray) . ')'; + $_params = 'array(' . implode(',', $_paramsArray) . ')'; $output = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params},\$_smarty_tpl)"; } else { - $_params = implode(",", $_attr); + $_params = implode(',', $_attr); $output = "\$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params})"; } } else { diff --git a/libs/sysplugins/smarty_internal_compile_private_php.php b/libs/sysplugins/smarty_internal_compile_private_php.php index 9080c487..1d100f0d 100644 --- a/libs/sysplugins/smarty_internal_compile_private_php.php +++ b/libs/sysplugins/smarty_internal_compile_private_php.php @@ -40,38 +40,34 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase // check and get attributes $_attr = $this->getAttributes($compiler, $args); $compiler->has_code = false; - if ($_attr[ 'type' ] == 'xml') { + if ($_attr[ 'type' ] === 'xml') { $compiler->tag_nocache = true; $output = addcslashes($_attr[ 'code' ], "'\\"); $compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, - $compiler->processNocacheCode("", + $compiler->processNocacheCode("", true))); return ''; } - if ($_attr[ 'type' ] != 'tag') { - if ($compiler->php_handling == Smarty::PHP_REMOVE) { + if ($_attr[ 'type' ] !== 'tag') { + if ($compiler->php_handling === Smarty::PHP_REMOVE) { return ''; - } elseif ($compiler->php_handling == Smarty::PHP_QUOTE) { + } elseif ($compiler->php_handling === Smarty::PHP_QUOTE) { $output = preg_replace_callback('#(<\?(?:php|=)?)|(<%)|()|(\?>)|(%>)|(<\/script>)#i', array($this, 'quote'), $_attr[ 'code' ]); $compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Text($output)); return ''; - } elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr[ 'type' ] == 'unmatched') { + } elseif ($compiler->php_handling === Smarty::PHP_PASSTHRU || $_attr[ 'type' ] === 'unmatched') { $compiler->tag_nocache = true; $output = addcslashes($_attr[ 'code' ], "'\\"); $compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, - $compiler->processNocacheCode("", + $compiler->processNocacheCode("", true))); return ''; - } elseif ($compiler->php_handling == Smarty::PHP_ALLOW) { + } elseif ($compiler->php_handling === Smarty::PHP_ALLOW) { if (!($compiler->smarty instanceof SmartyBC)) { $compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it', null, true); @@ -91,10 +87,10 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase $rdel = preg_quote($compiler->smarty->right_delimiter, '#'); preg_match("#^({$ldel}php\\s*)((.)*?)({$rdel})#", $_attr[ 'code' ], $match); if (!empty($match[ 2 ])) { - if ('nocache' == trim($match[ 2 ])) { + if ('nocache' === trim($match[ 2 ])) { $compiler->tag_nocache = true; } else { - $compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", null, true); + $compiler->trigger_template_error("illegal value of option flag '{$match[2]}'", null, true); } } return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), @@ -144,16 +140,16 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase return; } $closeTag = "{$lex->smarty->left_delimiter}/php{$lex->smarty->right_delimiter}"; - if ($lex->value == $closeTag) { + if ($lex->value === $closeTag) { $lex->compiler->trigger_template_error("unexpected closing tag '{$closeTag}'"); } $lex->phpType = 'tag'; } - if ($lex->phpType == 'unmatched') { + if ($lex->phpType === 'unmatched') { return; } - if (($lex->phpType == 'php' || $lex->phpType == 'asp') && - ($lex->compiler->php_handling == Smarty::PHP_PASSTHRU || $lex->compiler->php_handling == Smarty::PHP_QUOTE) + if (($lex->phpType === 'php' || $lex->phpType === 'asp') && + ($lex->compiler->php_handling === Smarty::PHP_PASSTHRU || $lex->compiler->php_handling === Smarty::PHP_QUOTE) ) { return; } @@ -173,7 +169,7 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase $body = false; } else { $start = $pos + strlen($value); - $phpCommentStart = $value == '/*'; + $phpCommentStart = $value === '/*'; if ($phpCommentStart) { $phpCommentEnd = preg_match('~([*][/])~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start); if ($phpCommentEnd) { diff --git a/libs/sysplugins/smarty_internal_compile_private_print_expression.php b/libs/sysplugins/smarty_internal_compile_private_print_expression.php index 55d70915..7e39a355 100644 --- a/libs/sysplugins/smarty_internal_compile_private_print_expression.php +++ b/libs/sysplugins/smarty_internal_compile_private_print_expression.php @@ -67,7 +67,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C preg_match_all('/(\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|"[^"\\\\]*(?:\\\\.[^"\\\\]*)*"|:|[^:]+)/', $single_default_modifier, $mod_array); for ($i = 0, $count = count($mod_array[ 0 ]); $i < $count; $i ++) { - if ($mod_array[ 0 ][ $i ] != ':') { + if ($mod_array[ 0 ][ $i ] !== ':') { $modifierlist[ $key ][] = $mod_array[ 0 ][ $i ]; } } @@ -110,7 +110,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C } } foreach ($compiler->variable_filters as $filter) { - if (count($filter) == 1 && + if (count($filter) === 1 && ($result = $this->compile_output_filter($compiler, $filter[ 0 ], $output)) !== false ) { $output = $result; diff --git a/libs/sysplugins/smarty_internal_compile_private_registered_block.php b/libs/sysplugins/smarty_internal_compile_private_registered_block.php index 987bc96f..bd88f1bf 100644 --- a/libs/sysplugins/smarty_internal_compile_private_registered_block.php +++ b/libs/sysplugins/smarty_internal_compile_private_registered_block.php @@ -61,7 +61,7 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C if (is_int($_key)) { $_paramsArray[] = "$_key=>$_value"; } elseif ($compiler->template->caching && in_array($_key, $tag_info[ 2 ])) { - $_value = str_replace("'", "^#^", $_value); + $_value = str_replace('\'', "^#^", $_value); $_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^"; } else { $_paramsArray[] = "'$_key'=>$_value"; diff --git a/libs/sysplugins/smarty_internal_compile_private_registered_function.php b/libs/sysplugins/smarty_internal_compile_private_registered_function.php index 48c719e0..14a04c3b 100644 --- a/libs/sysplugins/smarty_internal_compile_private_registered_function.php +++ b/libs/sysplugins/smarty_internal_compile_private_registered_function.php @@ -56,13 +56,13 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna if (is_int($_key)) { $_paramsArray[] = "$_key=>$_value"; } elseif ($compiler->template->caching && in_array($_key, $tag_info[ 2 ])) { - $_value = str_replace("'", "^#^", $_value); + $_value = str_replace('\'', "^#^", $_value); $_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^"; } else { $_paramsArray[] = "'$_key'=>$_value"; } } - $_params = 'array(' . implode(",", $_paramsArray) . ')'; + $_params = 'array(' . implode(',', $_paramsArray) . ')'; // compile code if ($is_registered) { $output = diff --git a/libs/sysplugins/smarty_internal_compile_private_special_variable.php b/libs/sysplugins/smarty_internal_compile_private_special_variable.php index 967b186f..7982a005 100644 --- a/libs/sysplugins/smarty_internal_compile_private_special_variable.php +++ b/libs/sysplugins/smarty_internal_compile_private_special_variable.php @@ -114,7 +114,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C case 'rdelim': return "\$_smarty_tpl->smarty->right_delimiter"; default: - $compiler->trigger_template_error('$smarty.' . trim($_index[ 0 ], "'") . ' is not defined'); + $compiler->trigger_template_error('$smarty.' . trim($_index[ 0 ], '\'') . ' is not defined'); break; } if (isset($_index[ 1 ])) { diff --git a/libs/sysplugins/smarty_internal_compile_section.php b/libs/sysplugins/smarty_internal_compile_section.php index c530cc76..e3e4dc34 100644 --- a/libs/sysplugins/smarty_internal_compile_section.php +++ b/libs/sysplugins/smarty_internal_compile_section.php @@ -143,10 +143,10 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo } if (isset($namedAttr[ 'loop' ])) { $initNamedProperty[ 'loop' ] = "'loop' => {$v}"; - if ($t == 1) { + if ($t === 1) { $v = "{$sectionVar}->value['loop']"; } - } elseif ($t == 1) { + } elseif ($t === 1) { $initLocal[ 'loop' ] = $v; $v = "{$local}loop"; } @@ -163,11 +163,11 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo case 'step': if (is_numeric($attr_value)) { $v = (int) $attr_value; - $v = ($v == 0) ? 1 : $v; + $v = ($v === 0) ? 1 : $v; $t = 0; break; } - $initLocal[ 'step' ] = "((int)@$attr_value) == 0 ? 1 : (int)@$attr_value"; + $initLocal[ 'step' ] = "((int)@$attr_value) === 0 ? 1 : (int)@$attr_value"; $v = "{$local}step"; $t = 2; break; @@ -183,7 +183,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo $t = 3; break; } - if ($t == 3 && $compiler->getId($attr_value)) { + if ($t === 3 && $compiler->getId($attr_value)) { $t = 1; } $propValue[ $attr_name ] = $v; @@ -199,8 +199,8 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo $incFor[ 'iteration' ] = "{$propValue['iteration']}++"; $initFor[ 'iteration' ] = "{$propValue['iteration']} = 1"; - if ($propType[ 'step' ] == 0) { - if ($propValue[ 'step' ] == 1) { + if ($propType[ 'step' ] === 0) { + if ($propValue[ 'step' ] === 1) { $incFor[ 'index' ] = "{$sectionVar}->value['index']++"; } elseif ($propValue[ 'step' ] > 1) { $incFor[ 'index' ] = "{$sectionVar}->value['index'] += {$propValue['step']}"; @@ -214,7 +214,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo if (!isset($propValue[ 'max' ])) { $propValue[ 'max' ] = $propValue[ 'loop' ]; $propType[ 'max' ] = $propType[ 'loop' ]; - } elseif ($propType[ 'max' ] != 0) { + } elseif ($propType[ 'max' ] !== 0) { $propValue[ 'max' ] = "{$propValue['max']} < 0 ? {$propValue['loop']} : {$propValue['max']}"; $propType[ 'max' ] = 1; } else { @@ -227,11 +227,11 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo if (!isset($propValue[ 'start' ])) { $start_code = array(1 => "{$propValue['step']} > 0 ? ", 2 => '0', 3 => ' : ', 4 => $propValue[ 'loop' ], 5 => ' - 1'); - if ($propType[ 'loop' ] == 0) { + if ($propType[ 'loop' ] === 0) { $start_code[ 5 ] = ''; $start_code[ 4 ] = $propValue[ 'loop' ] - 1; } - if ($propType[ 'step' ] == 0) { + if ($propType[ 'step' ] === 0) { if ($propValue[ 'step' ] > 0) { $start_code = array(1 => '0'); $propType[ 'start' ] = 0; @@ -249,9 +249,9 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo 5 => ' : ', 6 => '-1', 7 => ', ', 8 => "{$propValue['start']} + {$propValue['loop']}", 10 => ')', 11 => ' : ', 12 => 'min(', 13 => $propValue[ 'start' ], 14 => ', ', 15 => "{$propValue['step']} > 0 ? ", 16 => $propValue[ 'loop' ], 17 => ' : ', - 18 => $propType[ 'loop' ] == 0 ? $propValue[ 'loop' ] - 1 : "{$propValue['loop']} - 1", + 18 => $propType[ 'loop' ] === 0 ? $propValue[ 'loop' ] - 1 : "{$propValue['loop']} - 1", 19 => ')'); - if ($propType[ 'step' ] == 0) { + if ($propType[ 'step' ] === 0) { $start_code[ 3 ] = $start_code[ 5 ] = $start_code[ 15 ] = $start_code[ 17 ] = ''; if ($propValue[ 'step' ] > 0) { $start_code[ 6 ] = $start_code[ 18 ] = ''; @@ -259,8 +259,8 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo $start_code[ 4 ] = $start_code[ 16 ] = ''; } } - if ($propType[ 'start' ] == 0) { - if ($propType[ 'loop' ] == 0) { + if ($propType[ 'start' ] === 0) { + if ($propType[ 'loop' ] === 0) { $start_code[ 8 ] = $propValue[ 'start' ] + $propValue[ 'loop' ]; } $propType[ 'start' ] = $propType[ 'step' ] + $propType[ 'loop' ]; @@ -269,7 +269,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo for ($i = 11; $i <= 19; $i ++) { $start_code[ $i ] = ''; } - if ($propType[ 'start' ] == 0) { + if ($propType[ 'start' ] === 0) { $start_code = array(max($propValue[ 'step' ] > 0 ? 0 : - 1, $propValue[ 'start' ] + $propValue[ 'loop' ])); } @@ -277,7 +277,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo for ($i = 1; $i <= 11; $i ++) { $start_code[ $i ] = ''; } - if ($propType[ 'start' ] == 0) { + if ($propType[ 'start' ] === 0) { $start_code = array(min($propValue[ 'step' ] > 0 ? $propValue[ 'loop' ] : $propValue[ 'loop' ] - 1, $propValue[ 'start' ])); @@ -286,7 +286,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo } $propValue[ 'start' ] = join('', $start_code); } - if ($propType[ 'start' ] != 0) { + if ($propType[ 'start' ] !== 0) { $initLocal[ 'start' ] = $propValue[ 'start' ]; $propValue[ 'start' ] = "{$local}start"; } @@ -299,7 +299,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo } else { $propType[ 'total' ] = $propType[ 'start' ] + $propType[ 'loop' ] + $propType[ 'step' ] + $propType[ 'max' ]; - if ($propType[ 'total' ] == 0) { + if ($propType[ 'total' ] === 0) { $propValue[ 'total' ] = min(ceil(($propValue[ 'step' ] > 0 ? $propValue[ 'loop' ] - $propValue[ 'start' ] : (int) $propValue[ 'start' ] + 1) / abs($propValue[ 'step' ])), $propValue[ 'max' ]); @@ -311,17 +311,17 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo if (!isset($propValue[ 'max' ])) { $total_code[ 1 ] = $total_code[ 17 ] = ''; } - if ($propType[ 'loop' ] + $propType[ 'start' ] == 0) { + if ($propType[ 'loop' ] + $propType[ 'start' ] === 0) { $total_code[ 5 ] = $propValue[ 'loop' ] - $propValue[ 'start' ]; $total_code[ 6 ] = $total_code[ 7 ] = ''; } - if ($propType[ 'start' ] == 0) { + if ($propType[ 'start' ] === 0) { $total_code[ 9 ] = (int) $propValue[ 'start' ] + 1; $total_code[ 10 ] = ''; } - if ($propType[ 'step' ] == 0) { + if ($propType[ 'step' ] === 0) { $total_code[ 13 ] = $total_code[ 15 ] = ''; - if ($propValue[ 'step' ] == 1 || $propValue[ 'step' ] == - 1) { + if ($propValue[ 'step' ] === 1 || $propValue[ 'step' ] === - 1) { $total_code[ 2 ] = $total_code[ 12 ] = $total_code[ 14 ] = $total_code[ 16 ] = ''; } elseif ($propValue[ 'step' ] < 0) { $total_code[ 14 ] = - $propValue[ 'step' ]; @@ -358,9 +358,9 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo $_vars = 'array(' . join(', ', $initNamedProperty) . ')'; $output .= "{$sectionVar} = new Smarty_Variable({$_vars});\n"; - $cond_code = "{$propValue['total']} != 0"; - if ($propType[ 'total' ] == 0) { - if ($propValue[ 'total' ] == 0) { + $cond_code = "{$propValue['total']} !== 0"; + if ($propType[ 'total' ] === 0) { + if ($propValue[ 'total' ] === 0) { $cond_code = 'false'; } else { $cond_code = 'true'; @@ -369,7 +369,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo if ($propType[ 'show' ] > 0) { $output .= "{$local}show = {$propValue['show']} ? {$cond_code} : false;\n"; $output .= "if ({$local}show) {\n"; - } elseif ($propValue[ 'show' ] == 'true') { + } elseif ($propValue[ 'show' ] === 'true') { $output .= "if ({$cond_code}) {\n"; } else { $output .= "if (false) {\n"; @@ -388,10 +388,10 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo $output .= "{$sectionVar}->value['index_next'] = {$propValue['index']} + {$propValue['step']};\n"; } if (isset($namedAttr[ 'first' ])) { - $output .= "{$sectionVar}->value['first'] = ({$propValue['iteration']} == 1);\n"; + $output .= "{$sectionVar}->value['first'] = ({$propValue['iteration']} === 1);\n"; } if (isset($namedAttr[ 'last' ])) { - $output .= "{$sectionVar}->value['last'] = ({$propValue['iteration']} == {$propValue['total']});\n"; + $output .= "{$sectionVar}->value['last'] = ({$propValue['iteration']} === {$propValue['total']});\n"; } $output .= "?>"; @@ -455,7 +455,7 @@ class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase $this->closeTag($compiler, array('section', 'sectionelse')); $output = ""; + $_output = ""; $_output .= $assignCompiler->compile($assignAttr, $compiler, array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])); } else { $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ]; - $_output = ""; + $_output = ""; $_output .= $assignCompiler->compile($assignAttr, $compiler, array()); } diff --git a/libs/sysplugins/smarty_internal_compilebase.php b/libs/sysplugins/smarty_internal_compilebase.php index 3fae8acd..656672b9 100644 --- a/libs/sysplugins/smarty_internal_compilebase.php +++ b/libs/sysplugins/smarty_internal_compilebase.php @@ -46,14 +46,14 @@ abstract class Smarty_Internal_CompileBase /** * Mapping array for boolean option value - * + * * @var array */ public $optionMap = array(1 => true, 0 => false, 'true' => true, 'false' => false); /** * Mapping array with attributes as key - * + * * @var array */ public $mapCache = array(); @@ -117,11 +117,11 @@ abstract class Smarty_Internal_CompileBase // check if all required attributes present foreach ($this->required_attributes as $attr) { if (!isset($_indexed_attr[ $attr ])) { - $compiler->trigger_template_error("missing \"" . $attr . "\" attribute", null, true); + $compiler->trigger_template_error("missing '{$attr}' attribute", null, true); } } // check for not allowed attributes - if ($this->optional_attributes != array('_any')) { + if ($this->optional_attributes !== array('_any')) { if (!isset($this->mapCache[ 'all' ])) { $this->mapCache[ 'all' ] = array_fill_keys(array_merge($this->required_attributes, $this->optional_attributes, @@ -129,7 +129,7 @@ abstract class Smarty_Internal_CompileBase } foreach ($_indexed_attr as $key => $dummy) { if (!isset($this->mapCache[ 'all' ][ $key ]) && $key !== 0) { - $compiler->trigger_template_error("unexpected \"" . $key . "\" attribute", null, true); + $compiler->trigger_template_error("unexpected '{$key}' attribute", null, true); } } } @@ -183,13 +183,12 @@ abstract class Smarty_Internal_CompileBase } } // wrong nesting of tags - $compiler->trigger_template_error("unclosed {$compiler->smarty->left_delimiter}" . $_openTag . - "{$compiler->smarty->right_delimiter} tag"); + $compiler->trigger_template_error("unclosed '{$compiler->smarty->left_delimiter}{$_openTag}{$compiler->smarty->right_delimiter}' tag"); return; } // wrong nesting of tags - $compiler->trigger_template_error("unexpected closing tag", null, true); + $compiler->trigger_template_error('unexpected closing tag', null, true); return; } diff --git a/libs/sysplugins/smarty_internal_config_file_compiler.php b/libs/sysplugins/smarty_internal_config_file_compiler.php index 6b5d1e75..ada38869 100644 --- a/libs/sysplugins/smarty_internal_config_file_compiler.php +++ b/libs/sysplugins/smarty_internal_config_file_compiler.php @@ -152,7 +152,7 @@ class Smarty_Internal_Config_File_Compiler $template_header = "template->source->filepath . "\" */ ?>\n"; + $template_header .= " compiled from '{$this->template->source->filepath}' */ ?>\n"; $code = 'smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' . var_export($this->config_data, true) . '); ?>'; diff --git a/libs/sysplugins/smarty_internal_data.php b/libs/sysplugins/smarty_internal_data.php index 58febbf2..37b917b1 100644 --- a/libs/sysplugins/smarty_internal_data.php +++ b/libs/sysplugins/smarty_internal_data.php @@ -29,7 +29,7 @@ * @method Smarty_Internal_Data clearConfig(string $varName = null) * @method Smarty_Internal_Data configLoad(string $config_file, mixed $sections = null, string $scope = 'local') */ -class Smarty_Internal_Data +abstract class Smarty_Internal_Data { /** * This object type (Smarty = 1, template = 2, data = 4) @@ -55,7 +55,7 @@ class Smarty_Internal_Data /** * parent template (if any) * - * @var Smarty|Smarty_Internal_Template|Smarty_Internal_Data + * @var Smarty|Smarty_Internal_Template|Smarty_Data */ public $parent = null; @@ -101,7 +101,7 @@ class Smarty_Internal_Data $this->assign($_key, $_val, $nocache); } } else { - if ($tpl_var != '') { + if ($tpl_var !== '') { if ($this->_objType === 2) { /** @var Smarty_Internal_Template $this */ $this->_assignInScope($tpl_var, $value, $nocache); diff --git a/libs/sysplugins/smarty_internal_debug.php b/libs/sysplugins/smarty_internal_debug.php index 20d72381..c826a178 100644 --- a/libs/sysplugins/smarty_internal_debug.php +++ b/libs/sysplugins/smarty_internal_debug.php @@ -213,7 +213,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data // init properties by hand as user may have edited the original Smarty class $debObj->setPluginsDir(is_dir(__DIR__ . '/../plugins') ? __DIR__ . '/../plugins' : $smarty->getPluginsDir()); $debObj->force_compile = false; - $debObj->compile_check = true; + $debObj->compile_check = Smarty::COMPILECHECK_ON; $debObj->left_delimiter = '{'; $debObj->right_delimiter = '}'; $debObj->security_policy = null; @@ -227,7 +227,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data $debObj->autoload_filters = array(); $debObj->default_modifiers = array(); $debObj->escape_html = true; - $debObj->caching = false; + $debObj->caching = Smarty::CACHING_OFF; $debObj->compile_id = null; $debObj->cache_id = null; // prepare information of assigned variables @@ -242,7 +242,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data if ($obj->_isTplObj()) { $_template->assign('template_name', $obj->source->type . ':' . $obj->source->name); } - if ($obj->_objType == 1 || $full) { + if ($obj->_objType === 1 || $full) { $_template->assign('template_data', $this->template_data[ $this->index ]); } else { $_template->assign('template_data', null); @@ -250,7 +250,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data $_template->assign('assigned_vars', $_assigned_vars); $_template->assign('config_vars', $_config_vars); $_template->assign('execution_time', microtime(true) - $smarty->start_time); - $_template->assign('display_mode', $debugging == 2 || !$full); + $_template->assign('display_mode', $debugging === 2 || !$full); $_template->assign('offset', $this->offset * 50); echo $_template->fetch(); if (isset($full)) { @@ -284,15 +284,15 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data $tpl_vars = array(); foreach ($obj->tpl_vars as $key => $var) { foreach ($var as $varkey => $varvalue) { - if ($varkey == 'value') { + if ($varkey === 'value') { $tpl_vars[ $key ][ $varkey ] = $varvalue; } else { - if ($varkey == 'nocache') { - if ($varvalue == true) { + if ($varkey === 'nocache') { + if ($varvalue === true) { $tpl_vars[ $key ][ $varkey ] = $varvalue; } } else { - if ($varkey != 'scope' || $varvalue !== 0) { + if ($varkey !== 'scope' || $varvalue !== 0) { $tpl_vars[ $key ][ 'attributes' ][ $varkey ] = $varvalue; } } @@ -326,15 +326,15 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data foreach (Smarty::$global_tpl_vars as $key => $var) { if (!array_key_exists($key, $tpl_vars)) { foreach ($var as $varkey => $varvalue) { - if ($varkey == 'value') { + if ($varkey === 'value') { $tpl_vars[ $key ][ $varkey ] = $varvalue; } else { - if ($varkey == 'nocache') { - if ($varvalue == true) { + if ($varkey === 'nocache') { + if ($varvalue === true) { $tpl_vars[ $key ][ $varkey ] = $varvalue; } } else { - if ($varkey != 'scope' || $varvalue !== 0) { + if ($varkey !== 'scope' || $varvalue !== 0) { $tpl_vars[ $key ][ 'attributes' ][ $varkey ] = $varvalue; } } @@ -359,7 +359,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data { static $_is_stringy = array('string' => true, 'eval' => true); // calculate Uid if not already done - if ($template->source->uid == '') { + if ($template->source->uid === '') { $template->source->filepath; } $key = $template->source->uid; @@ -389,7 +389,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data public function ignore(Smarty_Internal_Template $template) { // calculate Uid if not already done - if ($template->source->uid == '') { + if ($template->source->uid === '') { $template->source->filepath; } $this->ignore_uid[ $template->source->uid ] = true; diff --git a/libs/sysplugins/smarty_internal_extension_handler.php b/libs/sysplugins/smarty_internal_extension_handler.php index cdda69fa..4d7b04fa 100644 --- a/libs/sysplugins/smarty_internal_extension_handler.php +++ b/libs/sysplugins/smarty_internal_extension_handler.php @@ -111,9 +111,9 @@ class Smarty_Internal_Extension_Handler } if ($propertyType) { $obj = $propertyType === 1 ? $data : $smarty; - if ($match[2] == 'get') { + if ($match[2] === 'get') { return $obj->$property; - } else if ($match[2] == 'set') { + } else if ($match[2] === 'set') { return $obj->$property = $args[0]; } } @@ -154,7 +154,7 @@ class Smarty_Internal_Extension_Handler public function __get($property_name) { // object properties of runtime template extensions will start with '_' - if ($property_name[0] == '_') { + if ($property_name[0] === '_') { $class = 'Smarty_Internal_Runtime' . $this->upperCase($property_name); } else { $class = 'Smarty_Internal_Method_' . $this->upperCase($property_name); diff --git a/libs/sysplugins/smarty_internal_method_append.php b/libs/sysplugins/smarty_internal_method_append.php index af693591..a1422cf5 100644 --- a/libs/sysplugins/smarty_internal_method_append.php +++ b/libs/sysplugins/smarty_internal_method_append.php @@ -38,12 +38,12 @@ class Smarty_Internal_Method_Append if (is_array($tpl_var)) { // $tpl_var is an array, ignore $value foreach ($tpl_var as $_key => $_val) { - if ($_key != '') { + if ($_key !== '') { $this->append($data, $_key, $_val, $merge, $nocache); } } } else { - if ($tpl_var != '' && isset($value)) { + if ($tpl_var !== '' && isset($value)) { if (!isset($data->tpl_vars[ $tpl_var ])) { $tpl_var_inst = $data->ext->getTemplateVars->_getVariable($data, $tpl_var, null, true, false); if ($tpl_var_inst instanceof Smarty_Undefined_Variable) { diff --git a/libs/sysplugins/smarty_internal_method_appendbyref.php b/libs/sysplugins/smarty_internal_method_appendbyref.php index 532ac950..9185a8e8 100644 --- a/libs/sysplugins/smarty_internal_method_appendbyref.php +++ b/libs/sysplugins/smarty_internal_method_appendbyref.php @@ -27,7 +27,7 @@ class Smarty_Internal_Method_AppendByRef */ public static function appendByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $merge = false) { - if ($tpl_var != '' && isset($value)) { + if ($tpl_var !== '' && isset($value)) { if (!isset($data->tpl_vars[ $tpl_var ])) { $data->tpl_vars[ $tpl_var ] = new Smarty_Variable(); } diff --git a/libs/sysplugins/smarty_internal_method_assignbyref.php b/libs/sysplugins/smarty_internal_method_assignbyref.php index 0060bbc5..1c513ce9 100644 --- a/libs/sysplugins/smarty_internal_method_assignbyref.php +++ b/libs/sysplugins/smarty_internal_method_assignbyref.php @@ -24,7 +24,7 @@ class Smarty_Internal_Method_AssignByRef */ public function assignByRef(Smarty_Internal_Data $data, $tpl_var, &$value, $nocache) { - if ($tpl_var != '') { + if ($tpl_var !== '') { $data->tpl_vars[ $tpl_var ] = new Smarty_Variable(null, $nocache); $data->tpl_vars[ $tpl_var ]->value = &$value; if ($data->_isTplObj() && $data->scope) { diff --git a/libs/sysplugins/smarty_internal_method_assignglobal.php b/libs/sysplugins/smarty_internal_method_assignglobal.php index 3c2b2604..0e169041 100644 --- a/libs/sysplugins/smarty_internal_method_assignglobal.php +++ b/libs/sysplugins/smarty_internal_method_assignglobal.php @@ -30,7 +30,7 @@ class Smarty_Internal_Method_AssignGlobal */ public function assignGlobal(Smarty_Internal_Data $data, $varName, $value = null, $nocache = false) { - if ($varName != '') { + if ($varName !== '') { Smarty::$global_tpl_vars[ $varName ] = new Smarty_Variable($value, $nocache); $ptr = $data; while ($ptr->_isTplObj()) { diff --git a/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php b/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php index 6a3292d0..c019c59d 100644 --- a/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php +++ b/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php @@ -44,7 +44,7 @@ class Smarty_Internal_Method_ClearCompiledTemplate $_dir_sep = $smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^'; if (isset($resource_name)) { $_save_stat = $smarty->caching; - $smarty->caching = false; + $smarty->caching = Smarty::CACHING_OFF; /* @var Smarty_Internal_Template $tpl */ $tpl = $smarty->createTemplate($resource_name); $smarty->caching = $_save_stat; @@ -104,7 +104,7 @@ class Smarty_Internal_Method_ClearCompiledTemplate $_resource_part_2_length) === 0)) ) { if (isset($exp_time)) { - if (is_file($_filepath) && time() - @filemtime($_filepath) >= $exp_time) { + if (is_file($_filepath) && time() - filemtime($_filepath) >= $exp_time) { $unlink = true; } } else { @@ -114,7 +114,7 @@ class Smarty_Internal_Method_ClearCompiledTemplate if ($unlink && is_file($_filepath) && @unlink($_filepath)) { $_count++; if (function_exists('opcache_invalidate') - && (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1) + && (!function_exists('ini_get') || strlen(ini_get('opcache.restrict_api')) < 1) ) { opcache_invalidate($_filepath, true); } else if (function_exists('apc_delete_file')) { diff --git a/libs/sysplugins/smarty_internal_method_compilealltemplates.php b/libs/sysplugins/smarty_internal_method_compilealltemplates.php index 95486085..99b9df46 100644 --- a/libs/sysplugins/smarty_internal_method_compilealltemplates.php +++ b/libs/sysplugins/smarty_internal_method_compilealltemplates.php @@ -72,10 +72,10 @@ class Smarty_Internal_Method_CompileAllTemplates $_dir_2 = new RecursiveIteratorIterator($_dir_1); foreach ($_dir_2 as $_fileinfo) { $_file = $_fileinfo->getFilename(); - if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) { + if (substr(basename($_fileinfo->getPathname()), 0, 1) === '.' || strpos($_file, '.svn') !== false) { continue; } - if (!substr_compare($_file, $extension, -strlen($extension)) == 0) { + if (!substr_compare($_file, $extension, -strlen($extension)) === 0) { continue; } if ($_fileinfo->getPath() !== substr($_dir, 0, -1)) { @@ -85,7 +85,7 @@ class Smarty_Internal_Method_CompileAllTemplates flush(); $_start_time = microtime(true); $_smarty = clone $smarty; - // + // $_smarty->_cache = array(); $_smarty->ext = new Smarty_Internal_Extension_Handler(); $_smarty->ext->objType = $_smarty->_objType; @@ -113,7 +113,7 @@ class Smarty_Internal_Method_CompileAllTemplates // free memory unset($_tpl); $_smarty->_clearTemplateCache(); - if ($max_errors !== null && $_error_count == $max_errors) { + if ($max_errors !== null && $_error_count === $max_errors) { echo "\n

too many errors\n"; exit(); } diff --git a/libs/sysplugins/smarty_internal_method_configload.php b/libs/sysplugins/smarty_internal_method_configload.php index d33c3d15..eb8672fe 100644 --- a/libs/sysplugins/smarty_internal_method_configload.php +++ b/libs/sysplugins/smarty_internal_method_configload.php @@ -83,7 +83,7 @@ class Smarty_Internal_Method_ConfigLoad $this->_assignConfigVars($tpl->parent->config_vars, $tpl, $new_config_vars); $tagScope = $tpl->source->scope; if ($tagScope >= 0) { - if ($tagScope == Smarty::SCOPE_LOCAL) { + if ($tagScope === Smarty::SCOPE_LOCAL) { $this->_updateVarStack($tpl, $new_config_vars); $tagScope = 0; if (!$tpl->scope) { diff --git a/libs/sysplugins/smarty_internal_method_gettags.php b/libs/sysplugins/smarty_internal_method_gettags.php index f195fc46..afaa4b91 100644 --- a/libs/sysplugins/smarty_internal_method_gettags.php +++ b/libs/sysplugins/smarty_internal_method_gettags.php @@ -53,11 +53,11 @@ class Smarty_Internal_Method_GetTags $tpl->_cache[ 'used_tags' ] = array(); $tpl->smarty->merge_compiled_includes = false; $tpl->smarty->disableSecurity(); - $tpl->caching = false; + $tpl->caching = Smarty::CACHING_OFF; $tpl->loadCompiler(); $tpl->compiler->compileTemplate($tpl); return $tpl->_cache[ 'used_tags' ]; } - throw new SmartyException("Missing template specification"); + throw new SmartyException('Missing template specification'); } } \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_method_loadfilter.php b/libs/sysplugins/smarty_internal_method_loadfilter.php index d092d876..239fd6dd 100644 --- a/libs/sysplugins/smarty_internal_method_loadfilter.php +++ b/libs/sysplugins/smarty_internal_method_loadfilter.php @@ -58,7 +58,7 @@ class Smarty_Internal_Method_LoadFilter return true; } } - throw new SmartyException("{$type}filter \"{$name}\" not found or callable"); + throw new SmartyException("{$type}filter '{$name}' not found or callable"); } /** @@ -71,7 +71,7 @@ class Smarty_Internal_Method_LoadFilter public function _checkFilterType($type) { if (!isset($this->filterTypes[ $type ])) { - throw new SmartyException("Illegal filter type \"{$type}\""); + throw new SmartyException("Illegal filter type '{$type}'"); } } } \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_method_loadplugin.php b/libs/sysplugins/smarty_internal_method_loadplugin.php index 50f3bfc2..2454d9c9 100644 --- a/libs/sysplugins/smarty_internal_method_loadplugin.php +++ b/libs/sysplugins/smarty_internal_method_loadplugin.php @@ -76,7 +76,7 @@ class Smarty_Internal_Method_LoadPlugin } } $_file_names = array($_plugin_filename); - if ($_lower_filename != $_plugin_filename) { + if ($_lower_filename !== $_plugin_filename) { $_file_names[] = $_lower_filename; } $_p_dirs = $smarty->getPluginsDir(); diff --git a/libs/sysplugins/smarty_internal_method_mustcompile.php b/libs/sysplugins/smarty_internal_method_mustcompile.php index 0950ba9c..62c16f62 100644 --- a/libs/sysplugins/smarty_internal_method_mustcompile.php +++ b/libs/sysplugins/smarty_internal_method_mustcompile.php @@ -41,7 +41,7 @@ class Smarty_Internal_Method_MustCompile if ($_template->mustCompile === null) { $_template->mustCompile = (!$_template->source->handler->uncompiled && ($_template->smarty->force_compile || $_template->source->handler->recompiled || - !$_template->compiled->exists || ($_template->smarty->compile_check && + !$_template->compiled->exists || ($_template->compile_check && $_template->compiled->getTimeStamp() < $_template->source->getTimeStamp()))); } diff --git a/libs/sysplugins/smarty_internal_method_registerdefaultconfighandler.php b/libs/sysplugins/smarty_internal_method_registerdefaultconfighandler.php index 43088a1d..c8c5ae73 100644 --- a/libs/sysplugins/smarty_internal_method_registerdefaultconfighandler.php +++ b/libs/sysplugins/smarty_internal_method_registerdefaultconfighandler.php @@ -35,7 +35,7 @@ class Smarty_Internal_Method_RegisterDefaultConfigHandler if (is_callable($callback)) { $smarty->default_config_handler_func = $callback; } else { - throw new SmartyException("Default config handler not callable"); + throw new SmartyException('Default config handler not callable'); } return $obj; } diff --git a/libs/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php b/libs/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php index 569ea106..4c5d396e 100644 --- a/libs/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php +++ b/libs/sysplugins/smarty_internal_method_registerdefaulttemplatehandler.php @@ -35,7 +35,7 @@ class Smarty_Internal_Method_RegisterDefaultTemplateHandler if (is_callable($callback)) { $smarty->default_template_handler_func = $callback; } else { - throw new SmartyException("Default template handler not callable"); + throw new SmartyException('Default template handler not callable'); } return $obj; } @@ -62,7 +62,7 @@ class Smarty_Internal_Method_RegisterDefaultTemplateHandler if ($source->exists) { $source->timestamp = filemtime($_return); } else { - throw new SmartyException("Default handler: Unable to load " . + throw new SmartyException('Default handler: Unable to load ' . ($source->isConfig ? 'config' : 'template') . " default file '{$_return}' for '{$source->type}:{$source->name}'"); } diff --git a/libs/sysplugins/smarty_internal_method_registerfilter.php b/libs/sysplugins/smarty_internal_method_registerfilter.php index ea8f75a8..77e41f37 100644 --- a/libs/sysplugins/smarty_internal_method_registerfilter.php +++ b/libs/sysplugins/smarty_internal_method_registerfilter.php @@ -46,7 +46,7 @@ class Smarty_Internal_Method_RegisterFilter $this->_checkFilterType($type); $name = isset($name) ? $name : $this->_getFilterName($callback); if (!is_callable($callback)) { - throw new SmartyException("{$type}filter \"{$name}\" not callable"); + throw new SmartyException("{$type}filter '{$name}' not callable"); } $smarty->registered_filters[ $type ][ $name ] = $callback; return $obj; @@ -82,7 +82,7 @@ class Smarty_Internal_Method_RegisterFilter public function _checkFilterType($type) { if (!isset($this->filterTypes[ $type ])) { - throw new SmartyException("Illegal filter type \"{$type}\""); + throw new SmartyException("Illegal filter type '{$type}'"); } } } \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_method_registerplugin.php b/libs/sysplugins/smarty_internal_method_registerplugin.php index 91f06592..64bf0ef1 100644 --- a/libs/sysplugins/smarty_internal_method_registerplugin.php +++ b/libs/sysplugins/smarty_internal_method_registerplugin.php @@ -40,9 +40,9 @@ class Smarty_Internal_Method_RegisterPlugin { $smarty = $obj->_getSmartyObj(); if (isset($smarty->registered_plugins[ $type ][ $name ])) { - throw new SmartyException("Plugin tag \"{$name}\" already registered"); + throw new SmartyException("Plugin tag '{$name}' already registered"); } elseif (!is_callable($callback)) { - throw new SmartyException("Plugin \"{$name}\" not callable"); + throw new SmartyException("Plugin '{$name}' not callable"); } else { $smarty->registered_plugins[ $type ][ $name ] = array($callback, (bool) $cacheable, (array) $cache_attr); } diff --git a/libs/sysplugins/smarty_internal_method_setautoloadfilters.php b/libs/sysplugins/smarty_internal_method_setautoloadfilters.php index ebcfe727..29653b08 100644 --- a/libs/sysplugins/smarty_internal_method_setautoloadfilters.php +++ b/libs/sysplugins/smarty_internal_method_setautoloadfilters.php @@ -65,7 +65,7 @@ class Smarty_Internal_Method_SetAutoloadFilters public function _checkFilterType($type) { if (!isset($this->filterTypes[ $type ])) { - throw new SmartyException("Illegal filter type \"{$type}\""); + throw new SmartyException("Illegal filter type '{$type}'"); } } } \ No newline at end of file diff --git a/libs/sysplugins/smarty_internal_nocache_insert.php b/libs/sysplugins/smarty_internal_nocache_insert.php index 65fc143c..2629d51f 100644 --- a/libs/sysplugins/smarty_internal_nocache_insert.php +++ b/libs/sysplugins/smarty_internal_nocache_insert.php @@ -30,7 +30,7 @@ class Smarty_Internal_Nocache_Insert public static function compile($_function, $_attr, $_template, $_script, $_assign = null) { $_output = 'assign('{$_assign}' , {$_function} (" . var_export($_attr, true) . - ",\$_smarty_tpl), true);?>"; + ',\$_smarty_tpl), true);?>'; } else { - $_output .= "echo {$_function}(" . var_export($_attr, true) . ",\$_smarty_tpl);?>"; + $_output .= "echo {$_function}(" . var_export($_attr, true) . ',$_smarty_tpl);?>'; } $_tpl = $_template; while ($_tpl->_isSubTpl()) { $_tpl = $_tpl->parent; } - return "/*%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/" . $_output . - "/*/%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/"; + return "/*%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/{$_output}/*/%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/"; } } diff --git a/libs/sysplugins/smarty_internal_parsetree_code.php b/libs/sysplugins/smarty_internal_parsetree_code.php index d0f0b3fd..7bd0bc45 100644 --- a/libs/sysplugins/smarty_internal_parsetree_code.php +++ b/libs/sysplugins/smarty_internal_parsetree_code.php @@ -37,6 +37,6 @@ class Smarty_Internal_ParseTree_Code extends Smarty_Internal_ParseTree */ public function to_smarty_php(Smarty_Internal_Templateparser $parser) { - return sprintf("(%s)", $this->data); + return sprintf('(%s)', $this->data); } } diff --git a/libs/sysplugins/smarty_internal_parsetree_dq.php b/libs/sysplugins/smarty_internal_parsetree_dq.php index 8c2e0d99..a57e629c 100644 --- a/libs/sysplugins/smarty_internal_parsetree_dq.php +++ b/libs/sysplugins/smarty_internal_parsetree_dq.php @@ -74,8 +74,8 @@ class Smarty_Internal_ParseTree_Dq extends Smarty_Internal_ParseTree { $code = ''; foreach ($this->subtrees as $subtree) { - if ($code !== "") { - $code .= "."; + if ($code !== '') { + $code .= '.'; } if ($subtree instanceof Smarty_Internal_ParseTree_Tag) { $more_php = $subtree->assign_to_var($parser); diff --git a/libs/sysplugins/smarty_internal_parsetree_tag.php b/libs/sysplugins/smarty_internal_parsetree_tag.php index 9058aabf..8e19ec29 100644 --- a/libs/sysplugins/smarty_internal_parsetree_tag.php +++ b/libs/sysplugins/smarty_internal_parsetree_tag.php @@ -62,7 +62,7 @@ class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree $var = $parser->compiler->getNewPrefixVariable(); $tmp = $parser->compiler->appendCode('', $this->data); $tmp = $parser->compiler->appendCode($tmp, ""); - $parser->compiler->prefix_code[] = sprintf("%s", $tmp); + $parser->compiler->prefix_code[] = sprintf('%s', $tmp); return $var; } diff --git a/libs/sysplugins/smarty_internal_parsetree_template.php b/libs/sysplugins/smarty_internal_parsetree_template.php index f6032351..26612d4c 100644 --- a/libs/sysplugins/smarty_internal_parsetree_template.php +++ b/libs/sysplugins/smarty_internal_parsetree_template.php @@ -91,14 +91,14 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text) { $subtree = $this->subtrees[ $key ]->to_smarty_php($parser); while ($key + 1 < $cnt && ($this->subtrees[ $key + 1 ] instanceof Smarty_Internal_ParseTree_Text || - $this->subtrees[ $key + 1 ]->data == '')) { + $this->subtrees[ $key + 1 ]->data === '')) { $key ++; - if ($this->subtrees[ $key ]->data == '') { + if ($this->subtrees[ $key ]->data === '') { continue; } $subtree .= $this->subtrees[ $key ]->to_smarty_php($parser); } - if ($subtree == '') { + if ($subtree === '') { continue; } $code .= preg_replace('/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/', "\n", @@ -108,14 +108,14 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Tag) { $subtree = $this->subtrees[ $key ]->to_smarty_php($parser); while ($key + 1 < $cnt && ($this->subtrees[ $key + 1 ] instanceof Smarty_Internal_ParseTree_Tag || - $this->subtrees[ $key + 1 ]->data == '')) { + $this->subtrees[ $key + 1 ]->data === '')) { $key ++; - if ($this->subtrees[ $key ]->data == '') { + if ($this->subtrees[ $key ]->data === '') { continue; } $subtree = $parser->compiler->appendCode($subtree, $this->subtrees[ $key ]->to_smarty_php($parser)); } - if ($subtree == '') { + if ($subtree === '') { continue; } $code .= $subtree; diff --git a/libs/sysplugins/smarty_internal_resource_extends.php b/libs/sysplugins/smarty_internal_resource_extends.php index 147b5851..23a62472 100644 --- a/libs/sysplugins/smarty_internal_resource_extends.php +++ b/libs/sysplugins/smarty_internal_resource_extends.php @@ -42,7 +42,7 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource foreach ($components as $component) { /* @var \Smarty_Template_Source $_s */ $_s = Smarty_Template_Source::load(null, $smarty, $component); - if ($_s->type == 'php') { + if ($_s->type === 'php') { throw new SmartyException("Resource type {$_s->type} cannot be used with the extends resource type"); } $sources[ $_s->uid ] = $_s; diff --git a/libs/sysplugins/smarty_internal_resource_php.php b/libs/sysplugins/smarty_internal_resource_php.php index 6e9351d9..6f685abe 100644 --- a/libs/sysplugins/smarty_internal_resource_php.php +++ b/libs/sysplugins/smarty_internal_resource_php.php @@ -85,10 +85,10 @@ class Smarty_Internal_Resource_Php extends Smarty_Internal_Resource_File public function renderUncompiled(Smarty_Template_Source $source, Smarty_Internal_Template $_template) { if (!$source->smarty->allow_php_templates) { - throw new SmartyException("PHP templates are disabled"); + throw new SmartyException('PHP templates are disabled'); } if (!$source->exists) { - throw new SmartyException("Unable to load template {$source->type} '{$source->name}'" . + throw new SmartyException("Unable to load template '{$source->type}:{$source->name}'" . ($_template->_isSubTpl() ? " in '{$_template->parent->template_resource}'" : '')); } diff --git a/libs/sysplugins/smarty_internal_runtime_cacheresourcefile.php b/libs/sysplugins/smarty_internal_runtime_cacheresourcefile.php index 59863ad0..a9ff5789 100644 --- a/libs/sysplugins/smarty_internal_runtime_cacheresourcefile.php +++ b/libs/sysplugins/smarty_internal_runtime_cacheresourcefile.php @@ -32,7 +32,7 @@ class Smarty_Internal_Runtime_CacheResourceFile $_dir_sep = $smarty->use_sub_dirs ? '/' : '^'; $_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0; $_dir = $smarty->getCacheDir(); - if ($_dir == '/') { //We should never want to delete this! + if ($_dir === '/') { //We should never want to delete this! return 0; } $_dir_length = strlen($_dir); @@ -47,7 +47,7 @@ class Smarty_Internal_Runtime_CacheResourceFile } if (isset($resource_name)) { $_save_stat = $smarty->caching; - $smarty->caching = true; + $smarty->caching = Smarty::CACHING_LIFETIME_CURRENT; $tpl = new $smarty->template_class($resource_name, $smarty); $smarty->caching = $_save_stat; // remove from template cache @@ -64,7 +64,7 @@ class Smarty_Internal_Runtime_CacheResourceFile $_cacheDirs = new RecursiveDirectoryIterator($_dir); $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST); foreach ($_cache as $_file) { - if (substr(basename($_file->getPathname()), 0, 1) == '.') { + if (substr(basename($_file->getPathname()), 0, 1) === '.') { continue; } $_filepath = (string)$_file; @@ -83,13 +83,13 @@ class Smarty_Internal_Runtime_CacheResourceFile $_parts_count = count($_parts); // check name if (isset($resource_name)) { - if ($_parts[ $_parts_count - 1 ] != $_resourcename_parts) { + if ($_parts[ $_parts_count - 1 ] !== $_resourcename_parts) { continue; } } // check compile id if (isset($_compile_id) && (!isset($_parts[ $_parts_count - 2 - $_compile_id_offset ]) || - $_parts[ $_parts_count - 2 - $_compile_id_offset ] != $_compile_id) + $_parts[ $_parts_count - 2 - $_compile_id_offset ] !== $_compile_id) ) { continue; } @@ -102,7 +102,7 @@ class Smarty_Internal_Runtime_CacheResourceFile continue; } for ($i = 0; $i < $_cache_id_parts_count; $i++) { - if ($_parts[ $i ] != $_cache_id_parts[ $i ]) { + if ($_parts[ $i ] !== $_cache_id_parts[ $i ]) { continue 2; } } @@ -112,11 +112,11 @@ class Smarty_Internal_Runtime_CacheResourceFile if (isset($exp_time)) { if ($exp_time < 0) { preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_filepath), $match); - if ($_time < (@filemtime($_filepath) + $match[ 1 ])) { + if ($_time < (filemtime($_filepath) + $match[ 1 ])) { continue; } } else { - if ($_time - @filemtime($_filepath) < $exp_time) { + if ($_time - filemtime($_filepath) < $exp_time) { continue; } } diff --git a/libs/sysplugins/smarty_internal_runtime_capture.php b/libs/sysplugins/smarty_internal_runtime_capture.php index 18da7e8a..80ffa35b 100644 --- a/libs/sysplugins/smarty_internal_runtime_capture.php +++ b/libs/sysplugins/smarty_internal_runtime_capture.php @@ -130,7 +130,7 @@ class Smarty_Internal_Runtime_Capture */ public function error(Smarty_Internal_Template $_template) { - throw new SmartyException("Not matching {capture}{/capture} in \"{$_template->template_resource}\""); + throw new SmartyException("Not matching {capture}{/capture} in '{$_template->template_resource}'"); } /** diff --git a/libs/sysplugins/smarty_internal_runtime_codeframe.php b/libs/sysplugins/smarty_internal_runtime_codeframe.php index fb1e9510..5dd560b2 100644 --- a/libs/sysplugins/smarty_internal_runtime_codeframe.php +++ b/libs/sysplugins/smarty_internal_runtime_codeframe.php @@ -42,15 +42,16 @@ class Smarty_Internal_Runtime_CodeFrame } $output = "source->filepath) . "\" */\n\n"; + "\n from '" . str_replace('*/','* /',$_template->source->filepath) . "' */\n\n"; $output .= "/* @var Smarty_Internal_Template \$_smarty_tpl */\n"; $dec = "\$_smarty_tpl->_decodeProperties(\$_smarty_tpl, " . var_export($properties, true) . ',' . - ($cache ? 'true' : 'false') . ")"; + ($cache ? 'true' : 'false') . ')'; $output .= "if ({$dec}) {\n"; $output .= "function {$properties['unifunc']} (Smarty_Internal_Template \$_smarty_tpl) {\n"; if (!$cache && !empty($compiler->tpl_function)) { - $output .= "\$_smarty_tpl->smarty->ext->_tplFunction->registerTplFunctions(\$_smarty_tpl, " . - var_export($compiler->tpl_function, true) . ");\n"; + $output .= '$_smarty_tpl->smarty->ext->_tplFunction->registerTplFunctions($_smarty_tpl, '; + $output .= var_export($compiler->tpl_function, true); + $output .= ");\n"; } if ($cache && isset($_template->smarty->ext->_tplFunction)) { $output .= "\$_smarty_tpl->smarty->ext->_tplFunction->registerTplFunctions(\$_smarty_tpl, " . diff --git a/libs/sysplugins/smarty_internal_runtime_filterhandler.php b/libs/sysplugins/smarty_internal_runtime_filterhandler.php index f6cfa7c4..9d7d2db2 100644 --- a/libs/sysplugins/smarty_internal_runtime_filterhandler.php +++ b/libs/sysplugins/smarty_internal_runtime_filterhandler.php @@ -48,11 +48,11 @@ class Smarty_Internal_Runtime_FilterHandler // loaded class of filter plugin $callback = array($plugin_name, 'execute'); } else { - throw new SmartyException("Auto load {$type}-filter plugin method \"{$plugin_name}::execute\" not callable"); + throw new SmartyException("Auto load {$type}-filter plugin method '{$plugin_name}::execute' not callable"); } } else { // nothing found, throw exception - throw new SmartyException("Unable to auto load {$type}-filter plugin \"{$plugin_name}\""); + throw new SmartyException("Unable to auto load {$type}-filter plugin '{$plugin_name}'"); } $content = call_user_func($callback, $content, $template); } diff --git a/libs/sysplugins/smarty_internal_runtime_inheritance.php b/libs/sysplugins/smarty_internal_runtime_inheritance.php index cca2c74a..84607ad6 100644 --- a/libs/sysplugins/smarty_internal_runtime_inheritance.php +++ b/libs/sysplugins/smarty_internal_runtime_inheritance.php @@ -70,7 +70,7 @@ class Smarty_Internal_Runtime_Inheritance public function init(Smarty_Internal_Template $tpl, $initChild, $blockNames = array()) { // if called while executing parent template it must be a sub-template with new inheritance root - if ($initChild && $this->state == 3 && (strpos($tpl->template_resource, 'extendsall') === false)) { + if ($initChild && $this->state === 3 && (strpos($tpl->template_resource, 'extendsall') === false)) { $tpl->inheritance = new Smarty_Internal_Runtime_Inheritance(); $tpl->inheritance->init($tpl, $initChild, $blockNames); return; @@ -90,7 +90,7 @@ class Smarty_Internal_Runtime_Inheritance // $tpl->endRenderCallbacks[ 'inheritance' ] = array($this, 'subTemplateEnd'); } // if state was waiting for parent change state to parent - if ($this->state == 2) { + if ($this->state === 2) { $this->state = 3; } } @@ -131,7 +131,7 @@ class Smarty_Internal_Runtime_Inheritance /** * Smarty_Internal_Block constructor. - * - if outer level {block} of child template ($state == 1) save it as child root block + * - if outer level {block} of child template ($state === 1) save it as child root block * - otherwise process inheritance and render * * @param \Smarty_Internal_Template $tpl @@ -147,7 +147,7 @@ class Smarty_Internal_Runtime_Inheritance if (isset($this->childRoot[ $name ])) { $block->child = $this->childRoot[ $name ]; } - if ($this->state == 1) { + if ($this->state === 1) { $this->childRoot[ $name ] = $block; return; } @@ -226,7 +226,7 @@ class Smarty_Internal_Runtime_Inheritance } /** - * Render parent block on $smarty.block.parent or {block append/prepend} * + * Render parent block on $smarty.block.parent or {block append/prepend} * * @param \Smarty_Internal_Template $tpl * @param \Smarty_Internal_Block $block diff --git a/libs/sysplugins/smarty_internal_runtime_updatecache.php b/libs/sysplugins/smarty_internal_runtime_updatecache.php index ceee3b71..fbed94b3 100644 --- a/libs/sysplugins/smarty_internal_runtime_updatecache.php +++ b/libs/sysplugins/smarty_internal_runtime_updatecache.php @@ -91,15 +91,15 @@ class Smarty_Internal_Runtime_UpdateCache $_template->smarty->_debug->start_cache($_template); } $this->removeNoCacheHash($cached, $_template, $no_output_filter); - $compile_check = $_template->smarty->compile_check; - $_template->smarty->compile_check = false; + $compile_check = (int)$_template->compile_check; + $_template->compile_check = Smarty::COMPILECHECK_OFF; if ($_template->_isSubTpl()) { $_template->compiled->unifunc = $_template->parent->compiled->unifunc; } if (!$_template->cached->processed) { $_template->cached->process($_template, true); } - $_template->smarty->compile_check = $compile_check; + $_template->compile_check = $compile_check; $cached->getRenderedTemplateCode($_template); if ($_template->smarty->debugging) { $_template->smarty->_debug->end_cache($_template); @@ -117,8 +117,7 @@ class Smarty_Internal_Runtime_UpdateCache */ public function writeCachedContent(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template, $content) { - if ($_template->source->handler->recompiled || !($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || - $_template->caching == Smarty::CACHING_LIFETIME_SAVED) + if ($_template->source->handler->recompiled || !$_template->caching ) { // don't write cache file return false; diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index 15c79f6a..d26f7c7a 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -110,7 +110,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase public static $tplObjCache = array(); /** - * Template object cache for Smarty::isCached() == true + * Template object cache for Smarty::isCached() === true * * @var Smarty_Internal_Template[] */ @@ -150,11 +150,9 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase // Smarty parameter $this->cache_id = $_cache_id === null ? $this->smarty->cache_id : $_cache_id; $this->compile_id = $_compile_id === null ? $this->smarty->compile_id : $_compile_id; - $this->caching = $_caching === null ? $this->smarty->caching : $_caching; - if ($this->caching === true) { - $this->caching = Smarty::CACHING_LIFETIME_CURRENT; - } + $this->caching = (int)($_caching === null ? $this->smarty->caching : $_caching); $this->cache_lifetime = $_cache_lifetime === null ? $this->smarty->cache_lifetime : $_cache_lifetime; + $this->compile_check = (int)$smarty->compile_check; $this->parent = $_parent; // Template resource $this->template_resource = $template_resource; @@ -190,12 +188,10 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase } // disable caching for evaluated code if ($this->source->handler->recompiled) { - $this->caching = false; + $this->caching = Smarty::CACHING_OFF; } // read from cache or render - $isCacheTpl = - $this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED; - if ($isCacheTpl) { + if ($this->caching === Smarty::CACHING_LIFETIME_CURRENT || $this->caching === Smarty::CACHING_LIFETIME_SAVED) { if (!isset($this->cached) || $this->cached->cache_id !== $this->cache_id || $this->cached->compile_id !== $this->compile_id ) { @@ -283,7 +279,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase $smarty = &$this->smarty; $_templateId = $smarty->_getTemplateId($template, $cache_id, $compile_id, $caching, $tpl); // recursive call ? - if (isset($tpl->templateId) ? $tpl->templateId : $tpl->_getTemplateId() != $_templateId) { + if (isset($tpl->templateId) ? $tpl->templateId : $tpl->_getTemplateId() !== $_templateId) { // already in template cache? if (isset(self::$tplObjCache[ $_templateId ])) { // copy data from cached object @@ -298,7 +294,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase } else { unset($tpl->compiled); } - if ($caching != 9999 && isset($cachedTpl->cached)) { + if ($caching !== 9999 && isset($cachedTpl->cached)) { $tpl->cached = $cachedTpl->cached; } else { unset($tpl->cached); @@ -320,7 +316,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase $tpl->source = Smarty_Template_Source::load($tpl); unset($tpl->compiled); } - if ($caching != 9999) { + if ($caching !== 9999) { unset($tpl->cached); } } @@ -348,7 +344,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase $tpl->tpl_vars[ $_key ] = new Smarty_Variable($_val, $this->isRenderingCache); } } - if ($tpl->caching == 9999) { + if ($tpl->caching === 9999) { if (!isset($tpl->compiled)) { $this->loadCompiled(true); } @@ -456,12 +452,12 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase } $is_valid = true; if (!empty($properties[ 'file_dependency' ]) && - ((!$cache && $tpl->smarty->compile_check) || $tpl->smarty->compile_check == 1) + ((!$cache && $tpl->compile_check) || $tpl->compile_check === Smarty::COMPILECHECK_ON) ) { // check file dependencies at compiled code foreach ($properties[ 'file_dependency' ] as $_file_to_check) { - if ($_file_to_check[ 2 ] == 'file' || $_file_to_check[ 2 ] == 'php') { - if ($tpl->source->filepath == $_file_to_check[ 0 ]) { + if ($_file_to_check[ 2 ] === 'file' || $_file_to_check[ 2 ] === 'php') { + if ($tpl->source->filepath === $_file_to_check[ 0 ]) { // do not recheck current template continue; //$mtime = $tpl->source->getTimeStamp(); @@ -546,7 +542,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase */ public function capture_error() { - throw new SmartyException("Not matching {capture} open/close in \"{$this->template_resource}\""); + throw new SmartyException("Not matching {capture} open/close in '{$this->template_resource}'"); } /** diff --git a/libs/sysplugins/smarty_internal_templatebase.php b/libs/sysplugins/smarty_internal_templatebase.php index ca2b4496..6b959404 100644 --- a/libs/sysplugins/smarty_internal_templatebase.php +++ b/libs/sysplugins/smarty_internal_templatebase.php @@ -67,9 +67,16 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data /** * caching enabled * - * @var boolean + * @var int */ - public $caching = false; + public $caching = Smarty::CACHING_OFF; + + /** + * check template for modifications? + * + * @var int + */ + public $compile_check = Smarty::COMPILECHECK_ON; /** * cache lifetime in seconds @@ -180,26 +187,28 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data $saveVars = false; $template = $smarty->createTemplate($template, $cache_id, $compile_id, $parent ? $parent : $this, false); - if ($this->_objType == 1) { + if ($this->_objType === 1) { // set caching in template object $template->caching = $this->caching; } } + // make sure we have integer values + $template->caching = (int)$template->caching; // fetch template content $level = ob_get_level(); try { $_smarty_old_error_level = isset($smarty->error_reporting) ? error_reporting($smarty->error_reporting) : null; - if ($this->_objType == 2) { + if ($this->_objType === 2) { /* @var Smarty_Internal_Template $this */ $template->tplFunctions = $this->tplFunctions; $template->inheritance = $this->inheritance; } /* @var Smarty_Internal_Template $parent */ - if (isset($parent->_objType) && ($parent->_objType == 2) && !empty($parent->tplFunctions)) { + if (isset($parent->_objType) && ($parent->_objType === 2) && !empty($parent->tplFunctions)) { $template->tplFunctions = array_merge($parent->tplFunctions, $template->tplFunctions); } - if ($function == 2) { + if ($function === 2) { if ($template->caching) { // return cache status of template if (!isset($template->cached)) { @@ -327,11 +336,19 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data } /** - * @param boolean $caching + * @param int $compile_check + */ + public function setCompileCheck($compile_check) + { + $this->compile_check = (int)$compile_check; + } + + /** + * @param int $caching */ public function setCaching($caching) { - $this->caching = $caching; + $this->caching = (int)$caching; } /** diff --git a/libs/sysplugins/smarty_internal_templatecompilerbase.php b/libs/sysplugins/smarty_internal_templatecompilerbase.php index f34ce4ac..5ca53662 100644 --- a/libs/sysplugins/smarty_internal_templatecompilerbase.php +++ b/libs/sysplugins/smarty_internal_templatecompilerbase.php @@ -500,7 +500,7 @@ abstract class Smarty_Internal_TemplateCompilerBase */ public function compileVariable($variable) { - if (strpos($variable, '(') == 0) { + if (!strpos($variable, '(')) { // not a variable variable $var = trim($variable, '\''); $this->tag_nocache = $this->tag_nocache | @@ -554,11 +554,11 @@ abstract class Smarty_Internal_TemplateCompilerBase foreach ($parameter as $p) { $pa[] = (strpos($p, '(') === false) ? ('isset(' . $p . ')') : ('(' . $p . ' !== null )'); } - return "(" . implode(' && ', $pa) . ")"; + return '(' . implode(' && ', $pa) . ')'; } else { $isset_par = str_replace("')->value", "',null,true,false)->value", $par); } - return $name . "(" . $isset_par . ")"; + return $name . '(' . $isset_par . ')'; } else if (in_array($func_name, array('empty', 'reset', @@ -571,7 +571,7 @@ abstract class Smarty_Internal_TemplateCompilerBase } if ($func_name === 'empty') { if ($parHasFuction && version_compare(PHP_VERSION, '5.5.0', '<')) { - return '(' . $parameter[ 0 ] . ' == false )'; + return '(' . $parameter[ 0 ] . ' === false )'; } else { return $func_name . '(' . str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')'; @@ -580,10 +580,10 @@ abstract class Smarty_Internal_TemplateCompilerBase return $func_name . '(' . $parameter[ 0 ] . ')'; } } else { - return $name . "(" . implode(',', $parameter) . ")"; + return $name . '(' . implode(',', $parameter) . ')'; } } else { - $this->trigger_template_error("unknown function \"" . $name . "\""); + $this->trigger_template_error("unknown function '{$name}'"); } } } @@ -808,7 +808,7 @@ abstract class Smarty_Internal_TemplateCompilerBase } require_once $script; } else { - $this->trigger_template_error("Default plugin handler: Returned script file \"{$script}\" for \"{$tag}\" not found"); + $this->trigger_template_error("Default plugin handler: Returned script file '{$script}' for '{$tag}' not found"); } } if (is_callable($callback)) { @@ -817,7 +817,7 @@ abstract class Smarty_Internal_TemplateCompilerBase array()); return true; } else { - $this->trigger_template_error("Default plugin handler: Returned callback for \"{$tag}\" not callable"); + $this->trigger_template_error("Default plugin handler: Returned callback for '{$tag}' not callable"); } } return false; @@ -863,9 +863,8 @@ abstract class Smarty_Internal_TemplateCompilerBase ) { $this->template->compiled->has_nocache_code = true; $_output = addcslashes($content, '\'\\'); - $_output = str_replace("^#^", "'", $_output); - $_output = "nocache_hash}%%*/" . $_output . - "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n"; + $_output = str_replace('^#^', '\'', $_output); + $_output = "nocache_hash}%%*/{$_output}/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n"; // make sure we include modifier plugins for nocache code foreach ($this->modifier_plugins as $plugin_name => $dummy) { if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ])) { @@ -944,11 +943,11 @@ abstract class Smarty_Internal_TemplateCompilerBase { $_scope = 0; if (isset($_attr[ 'scope' ])) { - $_scopeName = trim($_attr[ 'scope' ], "'\""); + $_scopeName = trim($_attr[ 'scope' ], '\'"'); if (is_numeric($_scopeName) && in_array($_scopeName, $validScopes)) { $_scope = $_scopeName; } else if (is_string($_scopeName)) { - $_scopeName = trim($_scopeName, "'\""); + $_scopeName = trim($_scopeName, '\'"'); $_scope = isset($validScopes[ $_scopeName ]) ? $validScopes[ $_scopeName ] : false; } else { $_scope = false; @@ -971,7 +970,7 @@ abstract class Smarty_Internal_TemplateCompilerBase public function makeNocacheCode($code) { return "echo '/*%%SmartyNocache:{$this->nocache_hash}%%*//*/%%SmartyNocache:{$this->nocache_hash}%%*/';\n"; } @@ -1137,7 +1136,7 @@ abstract class Smarty_Internal_TemplateCompilerBase { if (array_pop($this->_tag_stack_count) !== $this->getTagStackCount()) { $tag = $this->getOpenBlockTag(); - $this->trigger_template_error("unclosed \"{{$tag}}\" in doubled quoted string", + $this->trigger_template_error("unclosed '{{$tag}}' in doubled quoted string", null, true); } @@ -1326,7 +1325,7 @@ abstract class Smarty_Internal_TemplateCompilerBase $this->template->smarty->ext->_tplFunction->getTplFunction($this->template, $tag) !== false) ) { // template defined by {template} tag - $args[ '_attr' ][ 'name' ] = "'" . $tag . "'"; + $args[ '_attr' ][ 'name' ] = "'{$tag}'"; $_output = $this->callTagCompiler('call', $args, $parameter); } } @@ -1434,7 +1433,7 @@ abstract class Smarty_Internal_TemplateCompilerBase return $plugin_object->compile($args, $this); } } - throw new SmartyException("Plugin \"{$tag}\" not callable"); + throw new SmartyException("Plugin '{$tag}' not callable"); } else { if ($function = $this->getPlugin($tag, $plugin_type)) { if (!isset($this->smarty->security_policy) || @@ -1553,10 +1552,10 @@ abstract class Smarty_Internal_TemplateCompilerBase return $plugin_object->compile($args, $this); } } - throw new SmartyException("Plugin \"{$tag}\" not callable"); + throw new SmartyException("Plugin '{$tag}' not callable"); } } - $this->trigger_template_error("unknown tag \"" . $tag . "\"", null, true); + $this->trigger_template_error("unknown tag '{$tag}'", null, true); } } } diff --git a/libs/sysplugins/smarty_internal_testinstall.php b/libs/sysplugins/smarty_internal_testinstall.php index 7213b5d5..ac353b77 100644 --- a/libs/sysplugins/smarty_internal_testinstall.php +++ b/libs/sysplugins/smarty_internal_testinstall.php @@ -200,7 +200,7 @@ class Smarty_Internal_TestInstall } else { $errors[ 'plugins_dir' ] = $message; } - } else if ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) { + } else if ($_core_plugins_dir && $_core_plugins_dir === realpath($plugin_dir)) { $_core_plugins_available = true; if ($errors === null) { echo "$plugin_dir is OK.\n"; diff --git a/libs/sysplugins/smarty_resource_recompiled.php b/libs/sysplugins/smarty_resource_recompiled.php index 1465124c..322cdabf 100644 --- a/libs/sysplugins/smarty_resource_recompiled.php +++ b/libs/sysplugins/smarty_resource_recompiled.php @@ -49,7 +49,7 @@ abstract class Smarty_Resource_Recompiled extends Smarty_Resource $_smarty_tpl->loadCompiler(); // call compiler try { - eval("?>" . $_smarty_tpl->compiler->compileTemplate($_smarty_tpl)); + eval('?>' . $_smarty_tpl->compiler->compileTemplate($_smarty_tpl)); } catch (Exception $e) { unset($_smarty_tpl->compiler); diff --git a/libs/sysplugins/smarty_resource_uncompiled.php b/libs/sysplugins/smarty_resource_uncompiled.php index 554f3aea..a11e2c14 100644 --- a/libs/sysplugins/smarty_resource_uncompiled.php +++ b/libs/sysplugins/smarty_resource_uncompiled.php @@ -29,7 +29,7 @@ abstract class Smarty_Resource_Uncompiled extends Smarty_Resource * @var bool */ public $hasCompiledHandler = true; - + /** * populate compiled object with compiled filepath * diff --git a/libs/sysplugins/smarty_security.php b/libs/sysplugins/smarty_security.php index 60abd2ef..e501cd82 100644 --- a/libs/sysplugins/smarty_security.php +++ b/libs/sysplugins/smarty_security.php @@ -322,7 +322,7 @@ class Smarty_Security // fall back return $this->isTrustedStaticClass($class_name, $compiler); } - if ($params[ 2 ] == 'method') { + if ($params[ 2 ] === 'method') { $allowed = $this->trusted_static_methods; $name = substr($params[ 0 ], 0, strpos($params[ 0 ], '(')); } else { @@ -627,7 +627,7 @@ class Smarty_Security $this->_checkDir($this->smarty->_realpath($filepath, true), $this->_php_resource_dir); return true; } - + /** * Check if file is inside a valid directory * @@ -680,7 +680,7 @@ class Smarty_Security } elseif (is_object($security_class)) { throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security."); } - if ($security_class == null) { + if ($security_class === null) { $security_class = $smarty->security_class; } if (!class_exists($security_class)) { diff --git a/libs/sysplugins/smarty_template_cached.php b/libs/sysplugins/smarty_template_cached.php index 59eb09ad..45c83c89 100644 --- a/libs/sysplugins/smarty_template_cached.php +++ b/libs/sysplugins/smarty_template_cached.php @@ -107,8 +107,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base $_template->cached = new Smarty_Template_Cached($_template); $_template->cached->handler->populate($_template->cached, $_template); // caching enabled ? - if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || - $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || $_template->source->handler->recompiled + if (!$_template->caching || $_template->source->handler->recompiled ) { $_template->cached->valid = false; } @@ -164,13 +163,13 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base } else { $this->valid = true; } - if ($this->valid && $_template->caching == Smarty::CACHING_LIFETIME_CURRENT && + if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_CURRENT && $_template->cache_lifetime >= 0 && time() > ($this->timestamp + $_template->cache_lifetime) ) { // lifetime expired $this->valid = false; } - if ($this->valid && $_template->smarty->compile_check == 1 && + if ($this->valid && $_template->compile_check === Smarty::COMPILECHECK_ON && $_template->source->getTimeStamp() > $this->timestamp ) { $this->valid = false; diff --git a/libs/sysplugins/smarty_template_compiled.php b/libs/sysplugins/smarty_template_compiled.php index d82d23b1..7ca2ebcb 100644 --- a/libs/sysplugins/smarty_template_compiled.php +++ b/libs/sysplugins/smarty_template_compiled.php @@ -136,22 +136,22 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base $source->handler->process($_smarty_tpl); } else if (!$source->handler->uncompiled) { if (!$this->exists || $smarty->force_compile || - ($smarty->compile_check && $source->getTimeStamp() > $this->getTimeStamp()) + ($_smarty_tpl->compile_check && $source->getTimeStamp() > $this->getTimeStamp()) ) { $this->compileTemplateSource($_smarty_tpl); - $compileCheck = $smarty->compile_check; - $smarty->compile_check = false; + $compileCheck = $_smarty_tpl->compile_check; + $_smarty_tpl->compile_check = Smarty::COMPILECHECK_OFF; $this->loadCompiledTemplate($_smarty_tpl); - $smarty->compile_check = $compileCheck; + $_smarty_tpl->compile_check = $compileCheck; } else { $_smarty_tpl->mustCompile = true; @include($this->filepath); if ($_smarty_tpl->mustCompile) { $this->compileTemplateSource($_smarty_tpl); - $compileCheck = $smarty->compile_check; - $smarty->compile_check = false; + $compileCheck = $_smarty_tpl->compile_check; + $_smarty_tpl->compile_check = Smarty::COMPILECHECK_OFF; $this->loadCompiledTemplate($_smarty_tpl); - $smarty->compile_check = $compileCheck; + $_smarty_tpl->compile_check = $compileCheck; } } $_smarty_tpl->_subTemplateRegister(); @@ -250,7 +250,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base apc_compile_file($this->filepath); } if (defined('HHVM_VERSION')) { - eval("?>" . file_get_contents($this->filepath)); + eval('?>' . file_get_contents($this->filepath)); } else { include($this->filepath); } diff --git a/libs/sysplugins/smarty_undefined_variable.php b/libs/sysplugins/smarty_undefined_variable.php index 67e8714f..e064f655 100644 --- a/libs/sysplugins/smarty_undefined_variable.php +++ b/libs/sysplugins/smarty_undefined_variable.php @@ -28,6 +28,6 @@ class Smarty_Undefined_Variable extends Smarty_Variable */ public function __toString() { - return ""; + return ''; } }