Given the following structure:
class B
{
private $_b;
private __constructor() { }
public function setValue( $value )
{
$this->_b->setValue( $value );
}
public static function load( &$__b )
{
$B = new B();
$B->_b = $__b;
return $B;
}
}
class A
{
private $_b;
public function getB()
{
return B::load( $this->_b );
}
public function save()
{
$this->_b->save();
}
}
$_SESSION['a'] = new A();
The following does not work:
$b = $_SESSION['a']->getB();
$b->setValue( 'value' );
$_SESSION['a']->save();
However, the following does work:
$_SESSION['a']->getB()->setValue( 'value' );
$_SESSION['a']->save();
I know someone here will see what's wrong, or if it's not even possible.