mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-02 17:34:26 +02:00
Use PHP 7 Null Coalescing Operator (??)
This commit is contained in:
@@ -771,7 +771,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
$this->_normalizeTemplateConfig($isConfig);
|
||||
}
|
||||
if ($index !== null) {
|
||||
return isset($dir[ $index ]) ? $dir[ $index ] : null;
|
||||
return ($dir[ $index ] ?? null);
|
||||
}
|
||||
return $dir;
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@
|
||||
function smarty_function_counter($params, $template)
|
||||
{
|
||||
static $counters = array();
|
||||
$name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default';
|
||||
$name = $params[ 'name' ] ?? 'default';
|
||||
if (!isset($counters[ $name ])) {
|
||||
$counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1);
|
||||
}
|
||||
|
@@ -156,7 +156,7 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
|
||||
$_val = $output[ $_i ] ?? '';
|
||||
$_html_result[] =
|
||||
smarty_function_html_radios_output(
|
||||
$name,
|
||||
|
@@ -187,9 +187,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
'd' => 'Day'
|
||||
) as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName =
|
||||
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
|
||||
date($_elementKey);
|
||||
$$_variableName = $params[ 'time' ][ $prefix . $_elementName ] ?? date($_elementKey);
|
||||
}
|
||||
} elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) {
|
||||
// $_REQUEST given
|
||||
@@ -258,9 +256,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
if ($year_id !== null || $all_id !== null) {
|
||||
$_html_years .= ' id="' . smarty_function_escape_special_chars(
|
||||
$year_id !== null ?
|
||||
($year_id ? $year_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
($year_id ?? $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($year_size) {
|
||||
@@ -268,7 +265,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_years .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($year_empty) || isset($all_empty)) {
|
||||
$_html_years .= '<option value="">' . (isset($year_empty) ? $year_empty : $all_empty) . '</option>' .
|
||||
$_html_years .= '<option value="">' . ($year_empty ?? $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
$op = $start_year > $end_year ? -1 : 1;
|
||||
@@ -293,9 +290,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
if ($month_id !== null || $all_id !== null) {
|
||||
$_html_months .= ' id="' . smarty_function_escape_special_chars(
|
||||
$month_id !== null ?
|
||||
($month_id ? $month_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
($month_id ?? $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($month_size) {
|
||||
@@ -303,14 +299,14 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_months .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($month_empty) || isset($all_empty)) {
|
||||
$_html_months .= '<option value="">' . (isset($month_empty) ? $month_empty : $all_empty) . '</option>' .
|
||||
$_html_months .= '<option value="">' . ($month_empty ?? $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -339,7 +335,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_days .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($day_empty) || isset($all_empty)) {
|
||||
$_html_days .= '<option value="">' . (isset($day_empty) ? $day_empty : $all_empty) . '</option>' .
|
||||
$_html_days .= '<option value="">' . ($day_empty ?? $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
for ($i = 1; $i <= 31; $i++) {
|
||||
|
@@ -147,9 +147,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
's' => 'Second'
|
||||
) as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName =
|
||||
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
|
||||
date($_elementKey);
|
||||
$$_variableName = $params[ 'time' ][ $prefix . $_elementName ] ?? date($_elementKey);
|
||||
}
|
||||
$_meridian =
|
||||
isset($params[ 'time' ][ $prefix . 'Meridian' ]) ? (' ' . $params[ 'time' ][ $prefix . 'Meridian' ]) :
|
||||
@@ -199,7 +197,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
if ($hour_id !== null || $all_id !== null) {
|
||||
$_html_hours .= ' id="' .
|
||||
smarty_function_escape_special_chars(
|
||||
$hour_id !== null ? ($hour_id ? $hour_id : $_name) :
|
||||
$hour_id !== null ? ($hour_id ?? $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
@@ -208,7 +206,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_hours .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($hour_empty) || isset($all_empty)) {
|
||||
$_html_hours .= '<option value="">' . (isset($hour_empty) ? $hour_empty : $all_empty) . '</option>' .
|
||||
$_html_hours .= '<option value="">' . ($hour_empty ?? $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
$start = $use_24_hours ? 0 : 1;
|
||||
@@ -241,9 +239,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
if ($minute_id !== null || $all_id !== null) {
|
||||
$_html_minutes .= ' id="' . smarty_function_escape_special_chars(
|
||||
$minute_id !== null ?
|
||||
($minute_id ? $minute_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
($minute_id ?? $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($minute_size) {
|
||||
@@ -251,7 +248,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($minute_empty) || isset($all_empty)) {
|
||||
$_html_minutes .= '<option value="">' . (isset($minute_empty) ? $minute_empty : $all_empty) . '</option>' .
|
||||
$_html_minutes .= '<option value="">' . ($minute_empty ?? $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
$selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
|
||||
@@ -279,9 +276,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
if ($second_id !== null || $all_id !== null) {
|
||||
$_html_seconds .= ' id="' . smarty_function_escape_special_chars(
|
||||
$second_id !== null ?
|
||||
($second_id ? $second_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
($second_id ?? $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($second_size) {
|
||||
@@ -289,7 +285,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($second_empty) || isset($all_empty)) {
|
||||
$_html_seconds .= '<option value="">' . (isset($second_empty) ? $second_empty : $all_empty) . '</option>' .
|
||||
$_html_seconds .= '<option value="">' . ($second_empty ?? $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
$selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
|
||||
@@ -317,10 +313,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
if ($meridian_id !== null || $all_id !== null) {
|
||||
$_html_meridian .= ' id="' . smarty_function_escape_special_chars(
|
||||
$meridian_id !== null ?
|
||||
($meridian_id ? $meridian_id :
|
||||
$_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
($meridian_id ?? $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($meridian_size) {
|
||||
@@ -328,7 +322,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($meridian_empty) || isset($all_empty)) {
|
||||
$_html_meridian .= '<option value="">' . (isset($meridian_empty) ? $meridian_empty : $all_empty) .
|
||||
$_html_meridian .= '<option value="">' . ($meridian_empty ?? $all_empty) .
|
||||
'</option>' . $option_separator;
|
||||
}
|
||||
$_html_meridian .= '<option value="am"' . ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') .
|
||||
|
@@ -117,7 +117,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
$cached->content,
|
||||
$timestamp
|
||||
);
|
||||
$cached->timestamp = isset($timestamp) ? $timestamp : false;
|
||||
$cached->timestamp = $timestamp ?? false;
|
||||
$cached->exists = !!$cached->timestamp;
|
||||
}
|
||||
|
||||
@@ -138,8 +138,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
if (!$cached) {
|
||||
$cached = $_smarty_tpl->cached;
|
||||
}
|
||||
$content = $cached->content ? $cached->content : null;
|
||||
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
||||
$content = $cached->content ?? null;
|
||||
$timestamp = $cached->timestamp ?? null;
|
||||
if ($content === null || !$timestamp) {
|
||||
$this->fetch(
|
||||
$_smarty_tpl->cached->filepath,
|
||||
@@ -187,7 +187,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
*/
|
||||
public function readCachedContent(Smarty_Internal_Template $_template)
|
||||
{
|
||||
$content = $_template->cached->content ? $_template->cached->content : null;
|
||||
$content = $_template->cached->content ?? null;
|
||||
$timestamp = null;
|
||||
if ($content === null) {
|
||||
$timestamp = null;
|
||||
|
@@ -102,8 +102,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
if (!$cached) {
|
||||
$cached = $_smarty_tpl->cached;
|
||||
}
|
||||
$content = $cached->content ? $cached->content : null;
|
||||
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
||||
$content = $cached->content ?? null;
|
||||
$timestamp = $cached->timestamp ?? null;
|
||||
if ($content === null || !$timestamp) {
|
||||
if (!$this->fetch(
|
||||
$_smarty_tpl->cached->filepath,
|
||||
@@ -148,7 +148,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
*/
|
||||
public function readCachedContent(Smarty_Internal_Template $_template)
|
||||
{
|
||||
$content = $_template->cached->content ? $_template->cached->content : null;
|
||||
$content = $_template->cached->content ?? null;
|
||||
$timestamp = null;
|
||||
if ($content === null) {
|
||||
if (!$this->fetch(
|
||||
|
@@ -112,7 +112,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
|
||||
$_block = $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ];
|
||||
unset($compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ]);
|
||||
$_name = $_attr[ 'name' ];
|
||||
$_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null;
|
||||
$_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')) {
|
||||
|
@@ -63,9 +63,9 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args, $parameter, 'capture');
|
||||
$buffer = isset($_attr[ 'name' ]) ? $_attr[ 'name' ] : "'default'";
|
||||
$assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : 'null';
|
||||
$append = isset($_attr[ 'append' ]) ? $_attr[ 'append' ] : 'null';
|
||||
$buffer = $_attr[ 'name' ] ?? "'default'";
|
||||
$assign = $_attr[ 'assign' ] ?? 'null';
|
||||
$append = $_attr[ 'append' ] ?? 'null';
|
||||
$compiler->_cache[ 'capture_stack' ][] = array($compiler->nocache);
|
||||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
|
@@ -63,7 +63,7 @@ class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase
|
||||
if ($this->blockType === 'Child') {
|
||||
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ][ 'callsChild' ] = 'true';
|
||||
}
|
||||
$_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null;
|
||||
$_assign = $_attr[ 'assign' ] ?? null;
|
||||
$output = "<?php \n";
|
||||
if (isset($_assign)) {
|
||||
$output .= "ob_start();\n";
|
||||
|
@@ -157,7 +157,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
$output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
||||
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n";
|
||||
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";\n?>";
|
||||
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash ?? '', ob_get_clean());\n";
|
||||
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash, ob_get_clean());\n";
|
||||
$output .= "}\n}\n";
|
||||
$output .= $compiler->cStyleComment("/ {$_funcName}_nocache ") . "\n\n";
|
||||
$output .= "?>\n";
|
||||
|
@@ -196,7 +196,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
}
|
||||
$has_compiled_template = false;
|
||||
if ($merge_compiled_includes) {
|
||||
$c_id = isset($_attr[ 'compile_id' ]) ? $_attr[ 'compile_id' ] : $compiler->template->compile_id;
|
||||
$c_id = $_attr[ 'compile_id' ] ?? $compiler->template->compile_id;
|
||||
// we must observe different compile_id and caching
|
||||
$t_hash = sha1($c_id . ($_caching ? '--caching' : '--nocaching'));
|
||||
$compiler->smarty->allow_ambiguous_resources = true;
|
||||
@@ -314,7 +314,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
} else {
|
||||
$basename = $tpl->source->handler->getBasename($tpl->source);
|
||||
$sourceInfo = $tpl->source->type . ':' .
|
||||
($basename ? $basename : $tpl->source->name);
|
||||
($basename ?? $tpl->source->name);
|
||||
}
|
||||
// get compiled code
|
||||
$compiled_code = "<?php\n\n";
|
||||
|
@@ -193,7 +193,7 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->yyTraceFILE,
|
||||
"%sState push %s\n",
|
||||
$this->yyTracePrompt,
|
||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
|
||||
);
|
||||
}
|
||||
array_push($this->_yy_stack, $this->_yy_state);
|
||||
@@ -203,7 +203,7 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->yyTraceFILE,
|
||||
"%snew State %s\n",
|
||||
$this->yyTracePrompt,
|
||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->yyTraceFILE,
|
||||
"%sState pop %s\n",
|
||||
$this->yyTracePrompt,
|
||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
|
||||
);
|
||||
}
|
||||
$this->_yy_state = array_pop($this->_yy_stack);
|
||||
@@ -224,7 +224,7 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->yyTraceFILE,
|
||||
"%snew State %s\n",
|
||||
$this->yyTracePrompt,
|
||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -237,7 +237,7 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->yyTraceFILE,
|
||||
"%sState set %s\n",
|
||||
$this->yyTracePrompt,
|
||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -220,8 +220,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
$debObj->debugging = false;
|
||||
$debObj->debugging_ctrl = 'NONE';
|
||||
$debObj->error_reporting = E_ALL & ~E_NOTICE;
|
||||
$debObj->debug_tpl =
|
||||
isset($smarty->debug_tpl) ? $smarty->debug_tpl : 'file:' . dirname(__FILE__) . '/../debug.tpl';
|
||||
$debObj->debug_tpl = $smarty->debug_tpl ?? 'file:' . dirname(__FILE__) . '/../debug.tpl';
|
||||
$debObj->registered_plugins = array();
|
||||
$debObj->registered_resources = array();
|
||||
$debObj->registered_filters = array();
|
||||
|
@@ -66,7 +66,7 @@ class Smarty_Internal_Extension_Handler
|
||||
public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args)
|
||||
{
|
||||
/* @var Smarty $data ->smarty */
|
||||
$smarty = isset($data->smarty) ? $data->smarty : $data;
|
||||
$smarty = $data->smarty ?? $data;
|
||||
if (!isset($smarty->ext->$name)) {
|
||||
if (preg_match('/^((set|get)|(.*?))([A-Z].*)$/', $name, $match)) {
|
||||
$basename = $this->upperCase($match[ 4 ]);
|
||||
|
@@ -30,7 +30,7 @@ class Smarty_Internal_Method_GetAutoloadFilters extends Smarty_Internal_Method_S
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if ($type !== null) {
|
||||
$this->_checkFilterType($type);
|
||||
return isset($smarty->autoload_filters[ $type ]) ? $smarty->autoload_filters[ $type ] : array();
|
||||
return ($smarty->autoload_filters[ $type ] ?? array());
|
||||
}
|
||||
return $smarty->autoload_filters;
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ class Smarty_Internal_Method_GetStreamVariable
|
||||
fclose($fp);
|
||||
return $_result;
|
||||
}
|
||||
$smarty = isset($data->smarty) ? $data->smarty : $data;
|
||||
$smarty = $data->smarty ?? $data;
|
||||
if ($smarty->error_unassigned) {
|
||||
throw new SmartyException('Undefined stream variable "' . $variable . '"');
|
||||
} else {
|
||||
|
@@ -44,7 +44,7 @@ class Smarty_Internal_Method_RegisterFilter
|
||||
{
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$this->_checkFilterType($type);
|
||||
$name = isset($name) ? $name : $this->_getFilterName($callback);
|
||||
$name = $name ?? $this->_getFilterName($callback);
|
||||
if (!is_callable($callback)) {
|
||||
throw new SmartyException("{$type}filter '{$name}' not callable");
|
||||
}
|
||||
|
@@ -150,7 +150,7 @@ class Smarty_Internal_Runtime_Capture
|
||||
public function getBuffer(Smarty_Internal_Template $_template, $name = null)
|
||||
{
|
||||
if (isset($name)) {
|
||||
return isset($this->namedBuffer[ $name ]) ? $this->namedBuffer[ $name ] : null;
|
||||
return ($this->namedBuffer[ $name ] ?? null);
|
||||
} else {
|
||||
return $this->namedBuffer;
|
||||
}
|
||||
|
@@ -120,14 +120,12 @@ class Smarty_Internal_Runtime_GetIncludePath
|
||||
public function getIncludePath($dirs, $file, Smarty $smarty)
|
||||
{
|
||||
//if (!(isset($this->_has_stream_include) ? $this->_has_stream_include : $this->_has_stream_include = false)) {
|
||||
if (!(isset($this->_has_stream_include) ? $this->_has_stream_include :
|
||||
$this->_has_stream_include = function_exists('stream_resolve_include_path'))
|
||||
) {
|
||||
if (!($this->_has_stream_include ?? ($this->_has_stream_include = function_exists('stream_resolve_include_path')))) {
|
||||
$this->isNewIncludePath($smarty);
|
||||
}
|
||||
// try PHP include_path
|
||||
foreach ($dirs as $dir) {
|
||||
$dir_n = isset($this->number[ $dir ]) ? $this->number[ $dir ] : $this->number[ $dir ] = $this->counter++;
|
||||
$dir_n = $this->number[ $dir ] ?? ($this->number[ $dir ] = $this->counter++);
|
||||
if (isset($this->isFile[ $dir_n ][ $file ])) {
|
||||
if ($this->isFile[ $dir_n ][ $file ]) {
|
||||
return $this->isFile[ $dir_n ][ $file ];
|
||||
@@ -153,14 +151,13 @@ class Smarty_Internal_Runtime_GetIncludePath
|
||||
$this->_user_dirs[ $dir_n ] = $dir;
|
||||
}
|
||||
if ($this->_has_stream_include) {
|
||||
$path = stream_resolve_include_path($dir . (isset($file) ? $file : ''));
|
||||
$path = stream_resolve_include_path($dir . ($file ?? ''));
|
||||
if ($path) {
|
||||
return $this->isFile[ $dir_n ][ $file ] = $path;
|
||||
}
|
||||
} else {
|
||||
foreach ($this->_include_dirs as $key => $_i_path) {
|
||||
$path = isset($this->isPath[ $key ][ $dir_n ]) ? $this->isPath[ $key ][ $dir_n ] :
|
||||
$this->isPath[ $key ][ $dir_n ] = is_dir($_dir_path = $_i_path . $dir) ? $_dir_path : false;
|
||||
$path = $this->isPath[ $key ][ $dir_n ] ?? ($this->isPath[ $key ][ $dir_n ] = is_dir($_dir_path = $_i_path . $dir) ? $_dir_path : false);
|
||||
if ($path === false) {
|
||||
continue;
|
||||
}
|
||||
|
@@ -141,7 +141,7 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
*/
|
||||
public function instanceBlock(Smarty_Internal_Template $tpl, $className, $name, $tplIndex = null)
|
||||
{
|
||||
$block = new $className($name, isset($tplIndex) ? $tplIndex : $this->tplIndex);
|
||||
$block = new $className($name, ($tplIndex ?? $this->tplIndex));
|
||||
if (isset($this->childRoot[ $name ])) {
|
||||
$block->child = $this->childRoot[ $name ];
|
||||
}
|
||||
|
@@ -21,8 +21,7 @@ class Smarty_Internal_Runtime_TplFunction
|
||||
*/
|
||||
public function callTemplateFunction(Smarty_Internal_Template $tpl, $name, $params, $nocache)
|
||||
{
|
||||
$funcParam = isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
|
||||
(isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : null);
|
||||
$funcParam = $tpl->tplFunctions[ $name ] ?? ($tpl->smarty->tplFunctions[ $name ] ?? null);
|
||||
if (isset($funcParam)) {
|
||||
if (!$tpl->caching || ($tpl->caching && $nocache)) {
|
||||
$function = $funcParam[ 'call_name' ];
|
||||
@@ -84,8 +83,7 @@ class Smarty_Internal_Runtime_TplFunction
|
||||
public function getTplFunction(Smarty_Internal_Template $tpl, $name = null)
|
||||
{
|
||||
if (isset($name)) {
|
||||
return isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
|
||||
(isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : false);
|
||||
return ($tpl->tplFunctions[ $name ] ?? ($tpl->smarty->tplFunctions[ $name ] ?? false));
|
||||
} else {
|
||||
return empty($tpl->tplFunctions) ? $tpl->smarty->tplFunctions : $tpl->tplFunctions;
|
||||
}
|
||||
|
@@ -221,7 +221,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
$this->smarty->ext->_cacheModify->cacheModifiedCheck(
|
||||
$this->cached,
|
||||
$this,
|
||||
isset($content) ? $content : ob_get_clean()
|
||||
($content ?? ob_get_clean())
|
||||
);
|
||||
} else {
|
||||
if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled)
|
||||
@@ -292,7 +292,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 (($tpl->templateId ?? $tpl->_getTemplateId()) !== $_templateId) {
|
||||
// already in template cache?
|
||||
if (isset(self::$tplObjCache[ $_templateId ])) {
|
||||
// copy data from cached object
|
||||
@@ -537,7 +537,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
} else {
|
||||
$tpl->mustCompile = !$is_valid;
|
||||
$resource = $tpl->compiled;
|
||||
$resource->includes = isset($properties[ 'includes' ]) ? $properties[ 'includes' ] : array();
|
||||
$resource->includes = $properties[ 'includes' ] ?? array();
|
||||
}
|
||||
if ($is_valid) {
|
||||
$resource->unifunc = $properties[ 'unifunc' ];
|
||||
@@ -579,8 +579,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public function _getTemplateId()
|
||||
{
|
||||
return isset($this->templateId) ? $this->templateId : $this->templateId =
|
||||
$this->smarty->_getTemplateId($this->template_resource, $this->cache_id, $this->compile_id);
|
||||
return ($this->templateId ?? ($this->templateId =
|
||||
$this->smarty->_getTemplateId($this->template_resource, $this->cache_id, $this->compile_id)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -186,7 +186,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
} else {
|
||||
// get template object
|
||||
$saveVars = false;
|
||||
$template = $smarty->createTemplate($template, $cache_id, $compile_id, $parent ? $parent : $this, false);
|
||||
$template = $smarty->createTemplate($template, $cache_id, $compile_id, ($parent ?? $this), false);
|
||||
if ($this->_objType === 1) {
|
||||
// set caching in template object
|
||||
$template->caching = $this->caching;
|
||||
|
@@ -428,8 +428,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
$this->smarty->_debug->start_compile($this->template);
|
||||
}
|
||||
$this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
|
||||
$nocache = isset($nocache) ? $nocache : false;
|
||||
$this->parent_compiler = $parent_compiler ?? $this;
|
||||
$nocache = $nocache ?? false;
|
||||
if (empty($template->compiled->nocache_hash)) {
|
||||
$template->compiled->nocache_hash = $this->nocache_hash;
|
||||
} else {
|
||||
@@ -1029,7 +1029,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$_scope = $_scopeName;
|
||||
} elseif (is_string($_scopeName)) {
|
||||
$_scopeName = trim($_scopeName, '\'"');
|
||||
$_scope = isset($validScopes[ $_scopeName ]) ? $validScopes[ $_scopeName ] : false;
|
||||
$_scope = $validScopes[ $_scopeName ] ?? false;
|
||||
} else {
|
||||
$_scope = false;
|
||||
}
|
||||
|
@@ -54,7 +54,7 @@ abstract class Smarty_Resource_Custom extends Smarty_Resource
|
||||
$source->timestamp = $mtime;
|
||||
} else {
|
||||
$this->fetch($source->name, $content, $timestamp);
|
||||
$source->timestamp = isset($timestamp) ? $timestamp : false;
|
||||
$source->timestamp = $timestamp ?? false;
|
||||
if (isset($content)) {
|
||||
$source->content = $content;
|
||||
}
|
||||
|
@@ -230,7 +230,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
||||
if (!$_template->source->handler->recompiled) {
|
||||
return file_get_contents($this->filepath);
|
||||
}
|
||||
return isset($this->content) ? $this->content : false;
|
||||
return ($this->content ?? false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -135,9 +135,7 @@ class Smarty_Template_Source
|
||||
*/
|
||||
public function __construct(Smarty $smarty, $resource, $type, $name)
|
||||
{
|
||||
$this->handler =
|
||||
isset($smarty->_cache[ 'resource_handlers' ][ $type ]) ? $smarty->_cache[ 'resource_handlers' ][ $type ] :
|
||||
Smarty_Resource::load($smarty, $type);
|
||||
$this->handler = $smarty->_cache[ 'resource_handlers' ][ $type ] ?? Smarty_Resource::load($smarty, $type);
|
||||
$this->smarty = $smarty;
|
||||
$this->resource = $resource;
|
||||
$this->type = $type;
|
||||
@@ -208,6 +206,6 @@ class Smarty_Template_Source
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return isset($this->content) ? $this->content : $this->handler->getContent($this);
|
||||
return ($this->content ?? $this->handler->getContent($this));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user