Fix ArrayAccess priority:
* Methods brump properties and ArrayAccess * Properties beat ArrayAccess * ArrayAccess beats nothing at all * ArrayAccess also beats private properties Add a test case to verify. See #178
This commit is contained in:
@@ -133,17 +133,13 @@ class Mustache_Context
|
||||
private function findVariableInStack($id, array $stack)
|
||||
{
|
||||
for ($i = count($stack) - 1; $i >= 0; $i--) {
|
||||
if (is_object($stack[$i])) {
|
||||
if ($stack[$i] instanceof ArrayAccess) {
|
||||
if (isset($stack[$i][$id])) {
|
||||
return $stack[$i][$id];
|
||||
}
|
||||
} elseif (!($stack[$i] instanceof Closure)) {
|
||||
if (method_exists($stack[$i], $id)) {
|
||||
return $stack[$i]->$id();
|
||||
} elseif (isset($stack[$i]->$id)) {
|
||||
return $stack[$i]->$id;
|
||||
}
|
||||
if (is_object($stack[$i]) && !($stack[$i] instanceof Closure)) {
|
||||
if (method_exists($stack[$i], $id)) {
|
||||
return $stack[$i]->$id();
|
||||
} elseif (isset($stack[$i]->$id)) {
|
||||
return $stack[$i]->$id;
|
||||
} elseif ($stack[$i] instanceof ArrayAccess && isset($stack[$i][$id])) {
|
||||
return $stack[$i][$id];
|
||||
}
|
||||
} elseif (is_array($stack[$i]) && array_key_exists($id, $stack[$i])) {
|
||||
return $stack[$i][$id];
|
||||
|
||||
Reference in New Issue
Block a user