cast to array instead of checking is_assoc
parent
5724ef5ba5
commit
b1843eba7d
|
@ -162,7 +162,7 @@ c_for = for varref/varref "=" exp/exp "-->" chunks/cs "<!--" "END" {
|
||||||
$$ = "\$stack[] = ".$varref[0].";
|
$$ = "\$stack[] = ".$varref[0].";
|
||||||
\$stack[] = ".$varref_index.";
|
\$stack[] = ".$varref_index.";
|
||||||
\$stack[] = 0;
|
\$stack[] = 0;
|
||||||
foreach (self::array1($exp[0]) as \$item) {
|
foreach ((array)($exp[0]) as \$item) {
|
||||||
".$varref[0]." = \$item;
|
".$varref[0]." = \$item;
|
||||||
".$varref_index." = \$stack[count(\$stack)-1]++;
|
".$varref_index." = \$stack[count(\$stack)-1]++;
|
||||||
".$cs."}
|
".$cs."}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* Homepage: http://yourcmc.ru/wiki/VMX::Template
|
* Homepage: http://yourcmc.ru/wiki/VMX::Template
|
||||||
* License: GNU GPLv3 or later
|
* License: GNU GPLv3 or later
|
||||||
* Author: Vitaliy Filippov, 2006-2015
|
* Author: Vitaliy Filippov, 2006-2015
|
||||||
* Version: V3 (LALR), 2015-03-09
|
* Version: V3 (LALR), 2015-04-08
|
||||||
*
|
*
|
||||||
* This file contains the implementation of VMX::Template compiler.
|
* This file contains the implementation of VMX::Template compiler.
|
||||||
* It is only used when a template is compiled in runtime.
|
* It is only used when a template is compiled in runtime.
|
||||||
|
@ -3761,7 +3761,7 @@ class VMXTemplateParser extends lime_parser {
|
||||||
$result = "\$stack[] = ".$varref[0].";
|
$result = "\$stack[] = ".$varref[0].";
|
||||||
\$stack[] = ".$varref_index.";
|
\$stack[] = ".$varref_index.";
|
||||||
\$stack[] = 0;
|
\$stack[] = 0;
|
||||||
foreach (self::array1($exp[0]) as \$item) {
|
foreach ((array)($exp[0]) as \$item) {
|
||||||
".$varref[0]." = \$item;
|
".$varref[0]." = \$item;
|
||||||
".$varref_index." = \$stack[count(\$stack)-1]++;
|
".$varref_index." = \$stack[count(\$stack)-1]++;
|
||||||
".$cs."}
|
".$cs."}
|
||||||
|
@ -4992,5 +4992,5 @@ class VMXTemplateParser extends lime_parser {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Time: 2,6265029907227 seconds
|
// Time: 3,1172089576721 seconds
|
||||||
// Memory: 11885624 bytes
|
// Memory: 11886108 bytes
|
||||||
|
|
11
template.php
11
template.php
|
@ -8,7 +8,7 @@
|
||||||
* Homepage: http://yourcmc.ru/wiki/VMX::Template
|
* Homepage: http://yourcmc.ru/wiki/VMX::Template
|
||||||
* License: GNU GPLv3 or later
|
* License: GNU GPLv3 or later
|
||||||
* Author: Vitaliy Filippov, 2006-2015
|
* Author: Vitaliy Filippov, 2006-2015
|
||||||
* Version: V3 (LALR), 2015-03-09
|
* Version: V3 (LALR), 2015-04-08
|
||||||
*
|
*
|
||||||
* The template engine is split into two parts:
|
* The template engine is split into two parts:
|
||||||
* (1) This file - always used when running templates
|
* (1) This file - always used when running templates
|
||||||
|
@ -476,15 +476,6 @@ class VMXTemplate
|
||||||
throw new VMXTemplateException("Unknown block or function '$block'$errorinfo");
|
throw new VMXTemplateException("Unknown block or function '$block'$errorinfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
static function array1($a)
|
|
||||||
{
|
|
||||||
if (is_null($a))
|
|
||||||
return array();
|
|
||||||
if (is_array($a) && !self::is_assoc($a))
|
|
||||||
return $a;
|
|
||||||
return array($a);
|
|
||||||
}
|
|
||||||
|
|
||||||
// No-op, just returns the single argument. Needed to workaround ($expression)['key'] and ($expression)->m() issues.
|
// No-op, just returns the single argument. Needed to workaround ($expression)['key'] and ($expression)->m() issues.
|
||||||
static function noop($a)
|
static function noop($a)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue