diff options
Diffstat (limited to 'lib/smarty3/sysplugins/smarty_internal_compile_for.php')
-rw-r--r-- | lib/smarty3/sysplugins/smarty_internal_compile_for.php | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/lib/smarty3/sysplugins/smarty_internal_compile_for.php b/lib/smarty3/sysplugins/smarty_internal_compile_for.php index e5e7c61..3f113e5 100644 --- a/lib/smarty3/sysplugins/smarty_internal_compile_for.php +++ b/lib/smarty3/sysplugins/smarty_internal_compile_for.php @@ -26,16 +26,16 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase * The parser is generating different sets of attribute by which this compiler can * determine which syntax is used. * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @param array $parameter array with compilation parameter + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @param array $parameter array with compilation parameter * * @return string compiled code */ public function compile($args, $compiler, $parameter) { - $compiler->loopNesting ++; - if ($parameter == 0) { + $compiler->loopNesting++; + if ($parameter === 0) { $this->required_attributes = array('start', 'to'); $this->optional_attributes = array('max', 'step'); } else { @@ -45,9 +45,8 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase $this->mapCache = array(); // check and get attributes $_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,11 +88,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 $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; @@ -113,9 +111,9 @@ class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase /** * Compiles code for the {forelse} tag * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @param array $parameter array with compilation parameter + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @param array $parameter array with compilation parameter * * @return string compiled code */ @@ -123,10 +121,8 @@ class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase { // check and get attributes $_attr = $this->getAttributes($compiler, $args); - list($openTag, $nocache) = $this->closeTag($compiler, array('for')); $this->openTag($compiler, 'forelse', array('forelse', $nocache)); - return "<?php }} else { ?>"; } } @@ -142,29 +138,27 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase /** * Compiles code for the {/for} tag * - * @param array $args array with attributes from parser - * @param object $compiler compiler object - * @param array $parameter array with compilation parameter + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @param array $parameter array with compilation parameter * * @return string compiled code */ public function compile($args, $compiler, $parameter) { - $compiler->loopNesting --; + $compiler->loopNesting--; // check and get attributes $_attr = $this->getAttributes($compiler, $args); // must endblock be nocache? if ($compiler->nocache) { $compiler->tag_nocache = true; } - list($openTag, $compiler->nocache) = $this->closeTag($compiler, array('for', 'forelse')); - $output = "<?php }\n"; - if ($openTag != 'forelse') { + if ($openTag !== 'forelse') { $output .= "}\n"; } - $output .= "?>\n"; + $output .= "?>"; return $output; } } |