Skip to content
Snippets Groups Projects
Commit ebb380d4 authored by Peter Rotich's avatar Peter Rotich Committed by Peter Rotich
Browse files

Make variable replacer __call aware

is_callable will report ANY function as available
parent 0298b949
No related branches found
No related tags found
No related merge requests found
......@@ -63,11 +63,12 @@ class VariableReplacer {
if(!$obj) return "";
if(!$var && is_callable(array($obj, 'asVar')))
if (!$var && method_exists($obj, 'asVar')) //XXX: to_string?
return call_user_func(array($obj, 'asVar'));
list($v, $part) = explode('.', $var, 2);
if($v && is_callable(array($obj, 'get'.ucfirst($v)))) {
if ($v && method_exists($obj, 'get'.ucfirst($v))
&& is_callable(array($obj, 'get'.ucfirst($v)))) {
$rv = call_user_func(array($obj, 'get'.ucfirst($v)));
if(!$rv || !is_object($rv))
return $rv;
......@@ -75,7 +76,7 @@ class VariableReplacer {
return $this->getVar($rv, $part);
}
if(!$var || !is_callable(array($obj, 'getVar')))
if (!$var || !method_exists($obj, 'getVar'))
return "";
$parts = explode('.', $var);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment