Get a caller class instance from another object
<p>Please take a look at this code:</p>

<pre><code>class Foo {

   public $barInstance;

   public function test() {
      $this-&gt;barInstance = new Bar();
      $this-&gt;barInstance-&gt;fooInstance = $this;
      $this-&gt;barInstance-&gt;doSomethingWithFoo();
   }

}

class Bar {
   public $fooInstance;

   public function doSomethingWithFoo() {
       $this-&gt;fooInstance-&gt;something();
   }
}

$foo = new Foo();
$foo-&gt;test();
</code></pre>

<p>Question: is it possible to let the "<code>$barInstance"</code> know from which class it was created (or called) without having the following string: <code>"$this-&gt;barInstance-&gt;fooInstance = $this;"</code></p>
