Run Rector on your code to see what it can do for you:

         $output = "<?php \$_smarty_tpl->createLocalArrayVariable($_attr[var], {$_nocache}, {$_scope});\n\$_smarty_tpl->tpl_vars[$_attr[var]]->value$parameter[smarty_internal_index] = $_attr[value];";
     } elseif ($compiler->template->smarty instanceof SmartyBC) {
         // implement Smarty2's behaviour of variables assigned by reference
-        $output = "<?php if (isset(\$_smarty_tpl->tpl_vars[$_attr[var]])) {\$_smarty_tpl->tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]];";
-        $output .= "\n\$_smarty_tpl->tpl_vars[$_attr[var]]->value = $_attr[value]; \$_smarty_tpl->tpl_vars[$_attr[var]]->nocache = $_nocache; \$_smarty_tpl->tpl_vars[$_attr[var]]->scope = $_scope;";
-        $output .= "\n} else \$_smarty_tpl->tpl_vars[$_attr[var]] = new SmartyVariable($_attr[value], $_nocache, $_scope);";
+        $output = sprintf('<?php if (isset($_smarty_tpl->tpl_vars[%s])) {$_smarty_tpl->tpl_vars[%s] = clone $_smarty_tpl->tpl_vars[%s];', $_attr[var], $_attr[var], $_attr[var]);
+        $output .= "\n\$_smarty_tpl->tpl_vars[$_attr[var]]->value = $_attr[value]; \$_smarty_tpl->tpl_vars[$_attr[var]]->nocache = {$_nocache}; \$_smarty_tpl->tpl_vars[$_attr[var]]->scope = {$_scope};";
+        $output .= "\n} else \$_smarty_tpl->tpl_vars[$_attr[var]] = new SmartyVariable($_attr[value], {$_nocache}, {$_scope});";
     } else {
-        $output = "<?php \$_smarty_tpl->tpl_vars[$_attr[var]] = new SmartyVariable($_attr[value], $_nocache, $_scope);";
+        $output = sprintf('<?php $_smarty_tpl->tpl_vars[%s] = new SmartyVariable(%s, %s, %s);', $_attr[var], $_attr[value], $_nocache, $_scope);
     }
PHP snippet to change
Config  rector.php
Rector version: c8d728 - released at 2025-06-22 21:36