PHP : $this->methodcall() gives error and CalledClass:methodcall() works fine
<p>I am trying to call method <code>getDetails()</code> from another class which in turns calls to methods from its own class(i.e, called class) and it does so by </p>

<p><code>$this-&gt;getAccount()</code> and <code>$this-&gt;getAddress()</code> and in called class we have methods like <code>$this-&gt;getAccount()</code> and <code>$this-&gt;getAddress()</code> function but when I call </p>

<p>them I get fatal error message as call to undefined method, but when I try calling that method using <code>CalledClassName::getAddress()</code> and </p>

<p><code>CalledClassName::getAddress()</code> than it works fine.</p>

<p>My question is that class which am calling(i.e, calledClass ) will always have use <code>$this-&gt;getAddress()</code> and <code>$this-&gt;getAccount()</code> as am getting this class </p>

<p>information from other team and there are 3 teams that would be calling functions <code>getDetails()</code> which would internally call <code>getAccount()</code> and <code>getAddress()</code> </p>

<p>functions and so how should I deal with the issue of $this on myside when am calling <code>getDetails()</code> function. </p>

<p>Code Example</p>

<pre><code>Calling Class:


CalledClass::getDetails() // Call to getDetails function in CalledClass


CalledClass::


public function postalAddress()
{
 return array(
   'addressId' =&gt; $address-&gt;addressId,
   'city' =&gt; $address-&gt;city,
   'country' =&gt; $address-&gt;country,
   'postcode' =&gt; $address-&gt;postcode,
   'stateOrProvince' =&gt; $address-&gt;stateOrProvince,
   'street' =&gt; $address-&gt;streetName,
   'streetNumber' =&gt; $address-&gt;streetNrFirst,
   'streetSuffix' =&gt; $address-&gt;streetNrFirstSuffix
  );
};

public function getAddress()
{
 return $this-&gt;postalAddress();
}

public function setAccount($account)
{
 $this-&gt;account = $account;
}

public function getAccount()
{
 return $this-&gt;find('account = 1311143','');
}



 public function getDetails()
    {

     $data = array();
     $data[$address] = $this-&gt;getAddress();
     $data[$account] = $this-&gt;getAccount();
     return $data;
    }
</code></pre>

<p>So now using the above method it gives me error and so if am using <code>CalledClass::getAddress()</code> and <code>CalledClass::getAccount()</code> and it works fine but I cant chang e the code in the calledclass as am calling this function from another team. </p>

<p>Any guidance or suggestions ?</p>
