mirror of
https://github.com/smarty-php/smarty.git
synced 2025-07-31 08:27:14 +02:00
Merge pull request #544 from carpii/Smarty2
allow StdClass to be cast to array when compiling foreach, to prevent invalid count warning in PHP 7.2+
This commit is contained in:
@ -1192,7 +1192,7 @@ class Smarty_Compiler extends Smarty {
|
||||
}
|
||||
|
||||
$output = '<?php ';
|
||||
$output .= "\$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array'); }";
|
||||
$output .= "\$_from = $from; if ((\$_from instanceof StdClass) || (!is_array(\$_from) && !is_object(\$_from))) { settype(\$_from, 'array'); }";
|
||||
if (isset($name)) {
|
||||
$foreach_props = "\$this->_foreach[$name]";
|
||||
$output .= "{$foreach_props} = array('total' => count(\$_from), 'iteration' => 0);\n";
|
||||
|
Reference in New Issue
Block a user