replace unneeded instanceof conditions

This commit is contained in:
uwetews
2015-08-23 01:50:05 +02:00
parent 6eed7732df
commit a413a2a2e1
5 changed files with 13 additions and 13 deletions

View File

@@ -163,7 +163,7 @@ class Smarty_Internal_Data
if ($varname != '') {
Smarty::$global_tpl_vars[$varname] = new Smarty_Variable($value, $nocache);
$ptr = $this;
while ($ptr instanceof Smarty_Internal_Template) {
while ($ptr->_objType == 2) {
$ptr->tpl_vars[$varname] = clone Smarty::$global_tpl_vars[$varname];
$ptr = $ptr->parent;
}

View File

@@ -200,7 +200,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$savedIndex = $this->index;
$this->index = 9999;
}
if ($obj instanceof Smarty) {
if ($obj->_objType == 1) {
$smarty = $obj;
} else {
$smarty = $obj->smarty;
@@ -239,10 +239,10 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$debugging = $smarty->debugging;
$_template = new Smarty_Internal_Template($debObj->debug_tpl, $debObj);
if ($obj instanceof Smarty_Internal_Template) {
if ($obj->_objType == 2) {
$_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
}
if ($obj instanceof Smarty || $full) {
if ($obj->_objType == 1 || $full) {
$_template->assign('template_data', $this->template_data[$this->index]);
} else {
$_template->assign('template_data', null);
@@ -273,9 +273,9 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$config_vars = array();
foreach ($obj->config_vars as $key => $var) {
$config_vars[$key]['value'] = $var;
if ($obj instanceof Smarty_Internal_Template) {
if ($obj->_objType == 2) {
$config_vars[$key]['scope'] = $obj->source->type . ':' . $obj->source->name;
} elseif ($obj instanceof Smarty_Data) {
} elseif ($obj->_objType == 4) {
$tpl_vars[$key]['scope'] = $obj->dataObjectName;
} else {
$config_vars[$key]['scope'] = 'Smarty object';
@@ -298,9 +298,9 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
}
}
}
if ($obj instanceof Smarty_Internal_Template) {
if ($obj->_objType == 2) {
$tpl_vars[$key]['scope'] = $obj->source->type . ':' . $obj->source->name;
} elseif ($obj instanceof Smarty_Data) {
} elseif ($obj->_objType == 4) {
$tpl_vars[$key]['scope'] = $obj->dataObjectName;
} else {
$tpl_vars[$key]['scope'] = 'Smarty object';

View File

@@ -34,9 +34,9 @@ class Smarty_Internal_Method_GetTags
{
/* @var Smarty $smarty */
$smarty = isset($this->smarty) ? $this->smarty : $obj;
if ($obj instanceof Smarty_Internal_Template && !isset($template)) {
if ($obj->_objType == 2 && !isset($template)) {
$tpl = clone $obj;
} elseif (isset($template) && $template instanceof Smarty_Internal_Template) {
} elseif (isset($template) && $template->_objType == 2) {
$tpl = clone $template;
} elseif (isset($template) && is_string($template)) {
/* @var Smarty_Internal_Template $tpl */

View File

@@ -42,7 +42,7 @@ class Smarty_Internal_Nocache_Insert
$_output .= "echo {$_function}(" . var_export($_attr, true) . ",\$_smarty_tpl);?>";
}
$_tpl = $_template;
while ($_tpl->parent instanceof Smarty_Internal_Template) {
while ($_tpl->parent->_objType == 2) {
$_tpl = $_tpl->parent;
}

View File

@@ -35,7 +35,7 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
return is_file($file) ? $file : false;
}
// go relative to a given template?
if ($file[0] == '.' && $_template && $_template->parent instanceof Smarty_Internal_Template &&
if ($file[0] == '.' && $_template && $_template->parent->_objType == 2 &&
preg_match('#^[.]{1,2}[\\\/]#', $file)
) {
if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' &&
@@ -104,7 +104,7 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
return false;
}
/**
/**
* populate Source Object with meta data from Resource
*
* @param Smarty_Template_Source $source source object