From 519d37839c2957fc9f7d087c5baa4b9105537305 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Wed, 15 Jan 2014 15:51:41 +0000
Subject: [PATCH] Make variable replacer aware of castable objects

Long term 'asVar' will be replaced with __toString function
---
 include/class.variable.php | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/class.variable.php b/include/class.variable.php
index 32704a909..233c9fc18 100644
--- a/include/class.variable.php
+++ b/include/class.variable.php
@@ -63,8 +63,12 @@ class VariableReplacer {
 
         if(!$obj) return "";
 
-        if (!$var && method_exists($obj, 'asVar')) //XXX: to_string?
-            return call_user_func(array($obj, 'asVar'));
+        if (!$var) {
+            if (method_exists($obj, 'asVar'))
+                return call_user_func(array($obj, 'asVar'));
+            elseif (method_exists($obj, '__toString'))
+                return (string) $obj;
+        }
 
         list($v, $part) = explode('.', $var, 2);
         if ($v && is_callable(array($obj, 'get'.ucfirst($v)))) {
-- 
GitLab