code cleanup and optimizations 3.1.32-dev-34

This commit is contained in:
Uwe Tews
2017-11-06 01:02:56 +01:00
parent 3799714d53
commit 3fc8abeb98
99 changed files with 600 additions and 621 deletions

View File

@@ -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,8 +99,7 @@
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

View File

@@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.32-dev-32';
const SMARTY_VERSION = '3.1.32-dev-34';
/**
* define variable scopes
*/
@@ -166,14 +166,6 @@ class Smarty extends Smarty_Internal_TemplateBase
const PLUGIN_COMPILER = 'compiler';
const PLUGIN_MODIFIER = 'modifier';
const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler';
/**
* Resource caching modes
* (not used since 3.1.30)
*/
const RESOURCE_CACHE_OFF = 0;
const RESOURCE_CACHE_AUTOMATIC = 1; // cache template objects by rules
const RESOURCE_CACHE_TEMPLATE = 2; // cache all template objects
const RESOURCE_CACHE_ON = 4; // cache source and compiled resources
/**
* assigned global tpl vars
*/
@@ -283,12 +275,6 @@ class Smarty extends Smarty_Internal_TemplateBase
* @var boolean
*/
public $force_compile = false;
/**
* check template for modifications?
*
* @var boolean
*/
public $compile_check = true;
/**
* use sub dirs for compiled/cached files?
*
@@ -980,10 +966,10 @@ class Smarty extends Smarty_Internal_TemplateBase
$tpl->tpl_vars[ $_key ] = new Smarty_Variable($_val);
}
}
if ($this->debugging || $this->debugging_ctrl == 'URL') {
if ($this->debugging || $this->debugging_ctrl === 'URL') {
$tpl->smarty->_debug = new Smarty_Internal_Debug();
// check URL debugging control
if (!$this->debugging && $this->debugging_ctrl == 'URL') {
if (!$this->debugging && $this->debugging_ctrl === 'URL') {
$tpl->smarty->_debug->debugUrl($tpl->smarty);
}
}
@@ -1100,14 +1086,6 @@ class Smarty extends Smarty_Internal_TemplateBase
Smarty_Internal_Template::$tplObjCache = array();
}
/**
* @param boolean $compile_check
*/
public function setCompileCheck($compile_check)
{
$this->compile_check = $compile_check;
}
/**
* @param boolean $use_sub_dirs
*/

View File

@@ -75,11 +75,11 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
break;
default:
trigger_error("textformat: unknown attribute '$_key'");
trigger_error("textformat: unknown attribute '{$_key}'");
}
}
if ($style == 'email') {
if ($style === 'email') {
$wrap = 72;
}
// split into paragraphs

View File

@@ -63,7 +63,7 @@ function smarty_function_counter($params, $template)
$counter[ 'direction' ] = $params[ 'direction' ];
}
if ($counter[ 'direction' ] == "down") {
if ($counter[ 'direction' ] === 'down') {
$counter[ 'count' ] -= $counter[ 'skip' ];
} else {
$counter[ 'count' ] += $counter[ 'skip' ];

View File

@@ -55,12 +55,12 @@ function smarty_function_cycle($params, $template)
if (!isset($params[ 'values' ])) {
if (!isset($cycle_vars[ $name ][ 'values' ])) {
trigger_error("cycle: missing 'values' parameter");
trigger_error('cycle: missing \'values\' parameter');
return;
}
} else {
if (isset($cycle_vars[ $name ][ 'values' ]) && $cycle_vars[ $name ][ 'values' ] != $params[ 'values' ]) {
if (isset($cycle_vars[ $name ][ 'values' ]) && $cycle_vars[ $name ][ 'values' ] !== $params[ 'values' ]) {
$cycle_vars[ $name ][ 'index' ] = 0;
}
$cycle_vars[ $name ][ 'values' ] = $params[ 'values' ];

View File

@@ -25,7 +25,7 @@
function smarty_function_fetch($params, $template)
{
if (empty($params[ 'file' ])) {
trigger_error("[plugin] fetch parameter 'file' cannot be empty", E_USER_NOTICE);
trigger_error('[plugin] fetch parameter \'file\' cannot be empty', E_USER_NOTICE);
return;
}
@@ -55,15 +55,15 @@ function smarty_function_fetch($params, $template)
}
$content = '';
if ($protocol == 'http') {
if ($protocol === 'http') {
// http fetch
if ($uri_parts = parse_url($params[ 'file' ])) {
// set defaults
$host = $server_name = $uri_parts[ 'host' ];
$timeout = 30;
$accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
$agent = "Smarty Template Engine " . Smarty::SMARTY_VERSION;
$referer = "";
$accept = 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
$agent = 'Smarty Template Engine ' . Smarty::SMARTY_VERSION;
$referer = '';
$uri = !empty($uri_parts[ 'path' ]) ? $uri_parts[ 'path' ] : '/';
$uri .= !empty($uri_parts[ 'query' ]) ? '?' . $uri_parts[ 'query' ] : '';
$_is_proxy = false;
@@ -81,29 +81,29 @@ function smarty_function_fetch($params, $template)
// loop through parameters, setup headers
foreach ($params as $param_key => $param_value) {
switch ($param_key) {
case "file":
case "assign":
case "assign_headers":
case 'file':
case 'assign':
case 'assign_headers':
break;
case "user":
case 'user':
if (!empty($param_value)) {
$user = $param_value;
}
break;
case "pass":
case 'pass':
if (!empty($param_value)) {
$pass = $param_value;
}
break;
case "accept":
case 'accept':
if (!empty($param_value)) {
$accept = $param_value;
}
break;
case "header":
case 'header':
if (!empty($param_value)) {
if (!preg_match('![\w\d-]+: .+!', $param_value)) {
trigger_error("[plugin] invalid header format '" . $param_value . "'", E_USER_NOTICE);
trigger_error("[plugin] invalid header format '{$param_value}'", E_USER_NOTICE);
return;
} else {
@@ -111,41 +111,41 @@ function smarty_function_fetch($params, $template)
}
}
break;
case "proxy_host":
case 'proxy_host':
if (!empty($param_value)) {
$proxy_host = $param_value;
}
break;
case "proxy_port":
case 'proxy_port':
if (!preg_match('!\D!', $param_value)) {
$proxy_port = (int) $param_value;
} else {
trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE);
trigger_error("[plugin] invalid value for attribute '{$param_key }'", E_USER_NOTICE);
return;
}
break;
case "agent":
case 'agent':
if (!empty($param_value)) {
$agent = $param_value;
}
break;
case "referer":
case 'referer':
if (!empty($param_value)) {
$referer = $param_value;
}
break;
case "timeout":
case 'timeout':
if (!preg_match('!\D!', $param_value)) {
$timeout = (int) $param_value;
} else {
trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE);
trigger_error("[plugin] invalid value for attribute '{$param_key}'", E_USER_NOTICE);
return;
}
break;
default:
trigger_error("[plugin] unrecognized attribute '" . $param_key . "'", E_USER_NOTICE);
trigger_error("[plugin] unrecognized attribute '{$param_key}'", E_USER_NOTICE);
return;
}
@@ -185,7 +185,7 @@ function smarty_function_fetch($params, $template)
}
}
if (!empty($user) && !empty($pass)) {
fputs($fp, "Authorization: BASIC " . base64_encode("$user:$pass") . "\r\n");
fputs($fp, 'Authorization: BASIC ' . base64_encode("$user:$pass") . "\r\n");
}
fputs($fp, "\r\n");

View File

@@ -90,11 +90,11 @@ function smarty_function_html_checkboxes($params, $template)
$selected = array();
foreach ($_val as $_sel) {
if (is_object($_sel)) {
if (method_exists($_sel, "__toString")) {
if (method_exists($_sel, '__toString')) {
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
} else {
trigger_error("html_checkboxes: selected attribute contains an object of class '" .
get_class($_sel) . "' without __toString() method", E_USER_NOTICE);
trigger_error('html_checkboxes: selected attribute contains an object of class \'' .
get_class($_sel) . '\' without __toString() method', E_USER_NOTICE);
continue;
}
} else {
@@ -103,11 +103,11 @@ function smarty_function_html_checkboxes($params, $template)
$selected[ $_sel ] = true;
}
} elseif (is_object($_val)) {
if (method_exists($_val, "__toString")) {
if (method_exists($_val, '__toString')) {
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
} else {
trigger_error("html_checkboxes: selected attribute is an object of class '" . get_class($_val) .
"' without __toString() method", E_USER_NOTICE);
trigger_error('html_checkboxes: selected attribute is an object of class \'' . get_class($_val) .
'\' without __toString() method', E_USER_NOTICE);
}
} else {
$selected = smarty_function_escape_special_chars((string) $_val);
@@ -130,7 +130,7 @@ function smarty_function_html_checkboxes($params, $template)
case 'readonly':
if (!empty($params[ 'strict' ])) {
if (!is_scalar($_val)) {
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
E_USER_NOTICE);
}
@@ -146,7 +146,7 @@ function smarty_function_html_checkboxes($params, $template)
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
} else {
trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
trigger_error("html_checkboxes: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
}
break;
}
@@ -198,11 +198,11 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
$_output = '';
if (is_object($value)) {
if (method_exists($value, "__toString")) {
if (method_exists($value, '__toString')) {
$value = (string) $value->__toString();
} else {
trigger_error("html_options: value is an object of class '" . get_class($value) .
"' without __toString() method", E_USER_NOTICE);
trigger_error('html_options: value is an object of class \'' . get_class($value) .
'\' without __toString() method', E_USER_NOTICE);
return '';
}
@@ -211,11 +211,11 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
}
if (is_object($output)) {
if (method_exists($output, "__toString")) {
if (method_exists($output, '__toString')) {
$output = (string) $output->__toString();
} else {
trigger_error("html_options: output is an object of class '" . get_class($output) .
"' without __toString() method", E_USER_NOTICE);
trigger_error('html_options: output is an object of class \'' . get_class($output) .
'\' without __toString() method', E_USER_NOTICE);
return '';
}

View File

@@ -67,7 +67,7 @@ function smarty_function_html_image($params, $template)
if (!is_array($_val)) {
$$_key = smarty_function_escape_special_chars($_val);
} else {
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
throw new SmartyException ("html_image: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
}
break;
@@ -81,19 +81,19 @@ function smarty_function_html_image($params, $template)
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
} else {
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
throw new SmartyException ("html_image: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
}
break;
}
}
if (empty($file)) {
trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE);
trigger_error('html_image: missing \'file\' parameter', E_USER_NOTICE);
return;
}
if ($file[ 0 ] == '/') {
if ($file[ 0 ] === '/') {
$_image_path = $basedir . $file;
} else {
$_image_path = $file;
@@ -127,15 +127,15 @@ function smarty_function_html_image($params, $template)
// FIXME: (rodneyrehm) getimagesize() loads the complete file off a remote resource, use custom [jpg,png,gif]header reader!
if (!$_image_data = @getimagesize($_image_path)) {
if (!file_exists($_image_path)) {
trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
trigger_error("html_image: unable to find '{$_image_path}'", E_USER_NOTICE);
return;
} elseif (!is_readable($_image_path)) {
trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
trigger_error("html_image: unable to read '{$_image_path}'", E_USER_NOTICE);
return;
} else {
trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
trigger_error("html_image: '{$_image_path}' is not a valid image file", E_USER_NOTICE);
return;
}

View File

@@ -74,11 +74,11 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
$selected = array();
foreach ($_val as $_sel) {
if (is_object($_sel)) {
if (method_exists($_sel, "__toString")) {
if (method_exists($_sel, '__toString')) {
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
} else {
trigger_error("html_options: selected attribute contains an object of class '" .
get_class($_sel) . "' without __toString() method", E_USER_NOTICE);
trigger_error('html_options: selected attribute contains an object of class \'' .
get_class($_sel) . '\' without __toString() method', E_USER_NOTICE);
continue;
}
} else {
@@ -87,11 +87,11 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
$selected[ $_sel ] = true;
}
} elseif (is_object($_val)) {
if (method_exists($_val, "__toString")) {
if (method_exists($_val, '__toString')) {
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
} else {
trigger_error("html_options: selected attribute is an object of class '" . get_class($_val) .
"' without __toString() method", E_USER_NOTICE);
trigger_error('html_options: selected attribute is an object of class \'' . get_class($_val) .
'\' without __toString() method', E_USER_NOTICE);
}
} else {
$selected = smarty_function_escape_special_chars((string) $_val);
@@ -105,7 +105,7 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
case 'readonly':
if (!empty($params[ 'strict' ])) {
if (!is_scalar($_val)) {
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '{$_key}' will actually add the attribute",
E_USER_NOTICE);
}
@@ -121,7 +121,7 @@ function smarty_function_html_options($params, Smarty_Internal_Template $templat
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
} else {
trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
trigger_error("html_options: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
}
break;
}
@@ -182,11 +182,11 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
$_html_class = !empty($class) ? ' class="' . $class . ' option"' : '';
$_html_id = !empty($id) ? ' id="' . $id . '-' . $idx . '"' : '';
if (is_object($value)) {
if (method_exists($value, "__toString")) {
if (method_exists($value, '__toString')) {
$value = smarty_function_escape_special_chars((string) $value->__toString());
} else {
trigger_error("html_options: value is an object of class '" . get_class($value) .
"' without __toString() method", E_USER_NOTICE);
trigger_error('html_options: value is an object of class \'' . get_class($value) .
'\' without __toString() method', E_USER_NOTICE);
return '';
}

View File

@@ -73,11 +73,11 @@ function smarty_function_html_radios($params, $template)
if (is_array($_val)) {
trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
} elseif (is_object($_val)) {
if (method_exists($_val, "__toString")) {
if (method_exists($_val, '__toString')) {
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
} else {
trigger_error("html_radios: selected attribute is an object of class '" . get_class($_val) .
"' without __toString() method", E_USER_NOTICE);
trigger_error('html_radios: selected attribute is an object of class \'' . get_class($_val) .
'\' without __toString() method', E_USER_NOTICE);
}
} else {
$selected = (string) $_val;
@@ -115,7 +115,7 @@ function smarty_function_html_radios($params, $template)
case 'readonly':
if (!empty($params[ 'strict' ])) {
if (!is_scalar($_val)) {
trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
trigger_error("html_options: {$_key} attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute",
E_USER_NOTICE);
}
@@ -131,7 +131,7 @@ function smarty_function_html_radios($params, $template)
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
} else {
trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
trigger_error("html_radios: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
}
break;
}
@@ -185,11 +185,11 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
$_output = '';
if (is_object($value)) {
if (method_exists($value, "__toString")) {
if (method_exists($value, '__toString')) {
$value = (string) $value->__toString();
} else {
trigger_error("html_options: value is an object of class '" . get_class($value) .
"' without __toString() method", E_USER_NOTICE);
trigger_error('html_options: value is an object of class \'' . get_class($value) .
'\' without __toString() method', E_USER_NOTICE);
return '';
}
@@ -198,11 +198,11 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
}
if (is_object($output)) {
if (method_exists($output, "__toString")) {
if (method_exists($output, '__toString')) {
$output = (string) $output->__toString();
} else {
trigger_error("html_options: output is an object of class '" . get_class($output) .
"' without __toString() method", E_USER_NOTICE);
trigger_error('html_options: output is an object of class \'' . get_class($output) .
'\' without __toString() method', E_USER_NOTICE);
return '';
}

View File

@@ -65,18 +65,18 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
}
/* Default values. */
$prefix = "Date_";
$prefix = 'Date_';
$start_year = null;
$end_year = null;
$display_days = true;
$display_months = true;
$display_years = true;
$month_format = "%B";
$month_format = '%B';
/* Write months as numbers by default GL */
$month_value_format = "%m";
$day_format = "%02d";
$month_value_format = '%m';
$day_format = '%02d';
/* Write day values using this format MB */
$day_value_format = "%d";
$day_value_format = '%d';
$year_as_text = false;
/* Display years in reverse order? Ie. 2000,1999,.... */
$reverse_years = false;
@@ -122,10 +122,10 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
break;
case 'month_names':
if (is_array($_value) && count($_value) == 12) {
if (is_array($_value) && count($_value) === 12) {
$$_key = $_value;
} else {
trigger_error("html_select_date: month_names must be an array of 12 strings", E_USER_NOTICE);
trigger_error('html_select_date: month_names must be an array of 12 strings', E_USER_NOTICE);
}
break;
@@ -170,7 +170,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
if (!is_array($_value)) {
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
} else {
trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
trigger_error("html_select_date: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
}
break;
}
@@ -220,9 +220,9 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
$t = $$key;
if ($t === null) {
$$key = (int) $_current_year;
} elseif ($t[ 0 ] == '+') {
} elseif ($t[ 0 ] === '+') {
$$key = (int) ($_current_year + (int) trim(substr($t, 1)));
} elseif ($t[ 0 ] == '-') {
} elseif ($t[ 0 ] === '-') {
$$key = (int) ($_current_year - (int) trim(substr($t, 1)));
} else {
$$key = (int) $$key;
@@ -310,8 +310,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
for ($i = 1; $i <= 12; $i ++) {
$_val = sprintf('%02d', $i);
$_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[ $i ]) :
($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[ $i ]));
$_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[ $i ]);
($month_format === '%m' ? $_val : strftime($month_format, $_month_timestamps[ $i ]));
$_value = $month_value_format === '%m' ? $_val : strftime($month_value_format, $_month_timestamps[ $i ]);
$_html_months .= '<option value="' . $_value . '"' . ($_val == $_month ? ' selected="selected"' : '') .
'>' . $_text . '</option>' . $option_separator;
}
@@ -348,8 +348,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
for ($i = 1; $i <= 31; $i ++) {
$_val = sprintf('%02d', $i);
$_text = $day_format == '%02d' ? $_val : sprintf($day_format, $i);
$_value = $day_value_format == '%02d' ? $_val : sprintf($day_value_format, $i);
$_text = $day_format === '%02d' ? $_val : sprintf($day_format, $i);
$_value = $day_value_format === '%02d' ? $_val : sprintf($day_value_format, $i);
$_html_days .= '<option value="' . $_value . '"' . ($_val == $_day ? ' selected="selected"' : '') . '>' .
$_text . '</option>' . $option_separator;
}

View File

@@ -34,7 +34,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
$template->smarty->_cache[ '_required_smt' ] = true;
}
$prefix = "Time_";
$prefix = 'Time_';
$field_array = null;
$field_separator = "\n";
$option_separator = "\n";
@@ -143,7 +143,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
if (!is_array($_value)) {
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
} else {
trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
trigger_error("html_select_date: extra attribute '{$_key}' cannot be an array", E_USER_NOTICE);
}
break;
}
@@ -224,8 +224,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$end = $use_24_hours ? 23 : 12;
for ($i = $start; $i <= $end; $i ++) {
$_val = sprintf('%02d', $i);
$_text = $hour_format == '%02d' ? $_val : sprintf($hour_format, $i);
$_value = $hour_value_format == '%02d' ? $_val : sprintf($hour_value_format, $i);
$_text = $hour_format === '%02d' ? $_val : sprintf($hour_format, $i);
$_value = $hour_value_format === '%02d' ? $_val : sprintf($hour_value_format, $i);
if (!$use_24_hours) {
$_hour12 = $_hour == 0 ? 12 : ($_hour <= 12 ? $_hour : $_hour - 12);
@@ -271,8 +271,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
for ($i = 0; $i <= 59; $i += $minute_interval) {
$_val = sprintf('%02d', $i);
$_text = $minute_format == '%02d' ? $_val : sprintf($minute_format, $i);
$_value = $minute_value_format == '%02d' ? $_val : sprintf($minute_value_format, $i);
$_text = $minute_format === '%02d' ? $_val : sprintf($minute_format, $i);
$_value = $minute_value_format === '%02d' ? $_val : sprintf($minute_value_format, $i);
$_html_minutes .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') .
'>' . $_text . '</option>' . $option_separator;
}
@@ -312,8 +312,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
$selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
for ($i = 0; $i <= 59; $i += $second_interval) {
$_val = sprintf('%02d', $i);
$_text = $second_format == '%02d' ? $_val : sprintf($second_format, $i);
$_value = $second_value_format == '%02d' ? $_val : sprintf($second_value_format, $i);
$_text = $second_format === '%02d' ? $_val : sprintf($second_format, $i);
$_value = $second_value_format === '%02d' ? $_val : sprintf($second_value_format, $i);
$_html_seconds .= '<option value="' . $_value . '"' . ($selected === $i ? ' selected="selected"' : '') .
'>' . $_text . '</option>' . $option_separator;
}

View File

@@ -127,7 +127,7 @@ function smarty_function_html_table($params)
}
if (is_array($cols)) {
$cols = ($hdir == 'right') ? $cols : array_reverse($cols);
$cols = ($hdir === 'right') ? $cols : array_reverse($cols);
$output .= "<thead><tr>\n";
for ($r = 0; $r < $cols_count; $r ++) {
@@ -141,11 +141,11 @@ function smarty_function_html_table($params)
$output .= "<tbody>\n";
for ($r = 0; $r < $rows; $r ++) {
$output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n";
$rx = ($vdir == 'down') ? $r * $cols_count : ($rows - 1 - $r) * $cols_count;
$rx = ($vdir === 'down') ? $r * $cols_count : ($rows - 1 - $r) * $cols_count;
for ($c = 0; $c < $cols_count; $c ++) {
$x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count - 1 - $c;
if ($inner != 'cols') {
$x = ($hdir === 'right') ? $rx + $c : $rx + $cols_count - 1 - $c;
if ($inner !== 'cols') {
/* shuffle x to loop over rows*/
$x = floor($x / $cols_count) + ($x % $cols_count) * $rows;
}

View File

@@ -103,7 +103,7 @@ function smarty_function_mailto($params)
return;
}
// FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed!
if ($encode == 'javascript') {
if ($encode === 'javascript') {
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
$js_encode = '';
@@ -112,7 +112,7 @@ function smarty_function_mailto($params)
}
return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>';
} elseif ($encode == 'javascript_charcode') {
} elseif ($encode === 'javascript_charcode') {
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
for ($x = 0, $y = strlen($string); $x < $y; $x ++) {
@@ -123,7 +123,7 @@ function smarty_function_mailto($params)
implode(',', $ord) . "))" . "}\n" . "</script>\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);

View File

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

View File

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

View File

@@ -28,7 +28,7 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth =
switch (gettype($var)) {
case 'array' :
$results = '<b>Array (' . count($var) . ')</b>';
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;

View File

@@ -27,7 +27,7 @@
*/
function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false)
{
if ($length == 0) {
if ($length === 0) {
return '';
}

View File

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

View File

@@ -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 ] . ')';

View File

@@ -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 ], '"\'')) {

View File

@@ -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('#<!--((\[[^\]]+\]>.*?<!\[[^\]]+\])|(\s*/?ko\s+.+))-->#is', $source, $matches,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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 = "<?php \n";
if ($compiler->_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;

View File

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

View File

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

View File

@@ -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 "<?php $_output ?>";

View File

@@ -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,
"<?php \$_smarty_tpl->inheritance->endChild(\$_smarty_tpl" .
'<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl' .
(isset($template) ?
', ' . $template . $inlineUids :
", {$template}{$inlineUids}" :
'') . ");\n?>\n");
}

View File

@@ -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 = "<?php\n";
if ($parameter == 1) {
if ($parameter === 1) {
foreach ($_attr[ 'start' ] as $_statement) {
if (is_array($_statement[ 'var' ])) {
$var = $_statement[ 'var' ][ 'var' ];
@@ -89,10 +89,10 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
}
$output .= "if (\$_smarty_tpl->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 = "<?php }\n";
if ($openTag != 'forelse') {
if ($openTag !== 'forelse') {
$output .= "}\n";
}
$output .= "?>\n";

View File

@@ -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 = "<?php\n";
if ($restore == 2) {
if ($restore === 2) {
$output .= "{$itemVar} = {$local}saved;\n";
}
$output .= "}\n} else {\n?>\n";
@@ -327,7 +327,7 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
$this->closeTag($compiler, array('foreach', 'foreachelse'));
$output = "<?php\n";
if ($restore == 2) {
if ($restore === 2) {
$output .= "{$itemVar} = {$local}saved;\n";
}
if ($restore > 0) {

View File

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

View File

@@ -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 = "<?php {$prefixVar} = " . $parameter[ 'if condition' ][ 'value' ] . ";?>\n";
$_output = "<?php {$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]};?>\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 "<?php } else { ?>";
return '<?php } else { ?>';
}
}
@@ -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 = "<?php {$prefixVar} = " . $parameter[ 'if condition' ][ 'value' ] . ";?>\n";
$assignCode = "<?php {$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]};?>\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,

View File

@@ -312,7 +312,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
$compiled_code .= $tpl->compiler->postFilter($tpl->compiler->blockOrFunctionCode);
$compiled_code .= "<?php\n\n";
$compiled_code .= "/* End inline template \"{$sourceInfo}\" =============================*/\n";
$compiled_code .= "?>";
$compiled_code .= '?>';
unset($tpl->compiler);
if ($tpl->compiled->has_nocache_code) {
// replace nocache_hash

View File

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

View File

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

View File

@@ -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 = "<?php ";
@@ -90,11 +90,8 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
array('modifierlist' => $parameter[ 'modifier_list' ],
'value' => 'ob_get_clean()')) . ";\n";
}
$output = "<?php " . $mod_content . "\$_block_repeat=false;\n" . $mod_pre .
"echo {$callback}({$_params}, " . $mod_content2 .
", \$_smarty_tpl, \$_block_repeat);\n" . $mod_post . "}\n";
$output .= "array_pop(\$_smarty_tpl->smarty->_cache['_tag_stack']);";
$output .= "?>";
$output = "<?php {$mod_content}\$_block_repeat=false;\n{$mod_pre}echo {$callback}({$_params}, {$mod_content2}, \$_smarty_tpl, \$_block_repeat);\n{$mod_post}}\n";
$output .= 'array_pop($_smarty_tpl->smarty->_cache[\'_tag_stack\']);?>';
}
return $output . "\n";
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -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("<?php echo '" .
$output .
"';?>",
$compiler->processNocacheCode("<?php echo '{$output}';?>",
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\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/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("<?php echo '" .
$output .
"';?>",
$compiler->processNocacheCode("<?php echo '{$output}';?>",
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) {

View File

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

View File

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

View File

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

View File

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

View File

@@ -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 = "<?php\n";
if ($openTag == 'sectionelse') {
if ($openTag === 'sectionelse') {
$output .= "}\n";
} else {
$output .= "}\n}\n";

View File

@@ -55,12 +55,12 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
$assignAttr[][ 'value' ] = "{$prefixVar}";
if (is_array($parameter[ 'if condition' ][ 'var' ])) {
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
$_output = "<?php while ({$prefixVar} = " . $parameter[ 'if condition' ][ 'value' ] . ") {?>";
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
$_output .= $assignCompiler->compile($assignAttr, $compiler,
array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ]));
} else {
$assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
$_output = "<?php while ({$prefixVar} = " . $parameter[ 'if condition' ][ 'value' ] . ") {?>";
$_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
$_output .= $assignCompiler->compile($assignAttr, $compiler, array());
}

View File

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

View File

@@ -152,7 +152,7 @@ class Smarty_Internal_Config_File_Compiler
$template_header =
"<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
"\n";
$template_header .= " compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
$template_header .= " compiled from '{$this->template->source->filepath}' */ ?>\n";
$code = '<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' .
var_export($this->config_data, true) . '); ?>';

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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)) {
@@ -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<br><br>too many errors\n";
exit();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -30,7 +30,7 @@ class Smarty_Internal_Nocache_Insert
public static function compile($_function, $_attr, $_template, $_script, $_assign = null)
{
$_output = '<?php ';
if ($_script != 'null') {
if ($_script !== 'null') {
// script which must be included
// code for script file loading
$_output .= "require_once '{$_script}';";
@@ -38,16 +38,15 @@ class Smarty_Internal_Nocache_Insert
// call insert
if (isset($_assign)) {
$_output .= "\$_smarty_tpl->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}%%*/";
}
}

View File

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

View File

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

View File

@@ -62,7 +62,7 @@ class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree
$var = $parser->compiler->getNewPrefixVariable();
$tmp = $parser->compiler->appendCode('<?php ob_start();?>', $this->data);
$tmp = $parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>");
$parser->compiler->prefix_code[] = sprintf("%s", $tmp);
$parser->compiler->prefix_code[] = sprintf('%s', $tmp);
return $var;
}

View File

@@ -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))/', "<?php echo '\$1'; ?>\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;

View File

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

View File

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

View File

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

View File

@@ -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}'");
}
/**

View File

@@ -42,15 +42,16 @@ class Smarty_Internal_Runtime_CodeFrame
}
$output = "<?php\n";
$output .= "/* Smarty version {$properties[ 'version' ]}, created on " . strftime("%Y-%m-%d %H:%M:%S") .
"\n from \"" . str_replace('*/','* /',$_template->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, " .

View File

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

View File

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

View File

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

View File

@@ -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}'");
}
/**

View File

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

View File

@@ -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 = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/" . $_output .
"/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n";
$_output = str_replace('^#^', '\'', $_output);
$_output = "<?php echo '/*%%SmartyNocache:{$this->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}%%*/<?php " .
str_replace("^#^", "'", addcslashes($code, '\'\\')) .
str_replace('^#^', '\'', addcslashes($code, '\'\\')) .
"?>/*/%%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);
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -28,6 +28,6 @@ class Smarty_Undefined_Variable extends Smarty_Variable
*/
public function __toString()
{
return "";
return '';
}
}