See code:
class Foo {
public static function dumpObj($obj) {
var_dump($obj);
}
}
class Bar {
public $someData = 'bla';
public function __construct() {
Foo::dumpObj($this);
}
}
new Bar;
I'm guessing this outputs 'null' because $this is special and we just can't do this sort of thing with it. As you can see, I want to call Bar's method from within the Foo class during Bar's inception, and need Bar's object to do so. I can of course modify Bar's object in __construct, so assumed the object has been created and something outside the Bar class could modify it too.
Is there another way to do this? Foo unfortunately has to remain static and separate of Bar.
Much thanks for any responses.