'lo there,
how can one manage to get object methods to return the object and make
consequent/subsequent calls in ONE statement possible?
So instead of
---
$a = new FirstClass();
$b = new SecondClass();
$b->set( "attrib", "value" );
$a->add( "test" );
$a->add( $b );
---
it'd be so sweet to be able to write something like
---
$a = new FirstClass()->add( "test" )->add( new secondClass()->set(
"attrib", "value" ) );
---
I know this is fiction and can not be implemented like this ( though I
made every method returning '$this' ) - but is there any alternative?
Thanx & bye,
Carsten
how can one manage to get object methods to return the object and make
consequent/subsequent calls in ONE statement possible?
So instead of
---
$a = new FirstClass();
$b = new SecondClass();
$b->set( "attrib", "value" );
$a->add( "test" );
$a->add( $b );
---
it'd be so sweet to be able to write something like
---
$a = new FirstClass()->add( "test" )->add( new secondClass()->set(
"attrib", "value" ) );
---
I know this is fiction and can not be implemented like this ( though I
made every method returning '$this' ) - but is there any alternative?
Thanx & bye,
Carsten