Ver Mensaje Individual
  #6 (permalink)  
Antiguo 20/03/2013, 10:52
Avatar de masterpuppet
masterpuppet
Software Craftsman
 
Fecha de Ingreso: enero-2008
Ubicación: Montevideo, Uruguay
Mensajes: 3.550
Antigüedad: 16 años, 4 meses
Puntos: 845
Respuesta: llamar metodo de objeto desde otro

Que quieres hacer exactamente ? fluent interface ?, method chaining ?, no necesitas PHP 6 para algo asi, PHP actualmente lo soporta, algo asi:

Código PHP:
Ver original
  1. class Foo
  2. {
  3.     private $baz = 'baz';
  4.  
  5.     /**
  6.      * @return string
  7.      */
  8.     public function getBaz()
  9.     {
  10.         return $this->baz;
  11.     }
  12. }
  13.  
  14. class Bar
  15. {
  16.     /**
  17.      * @var Foo
  18.      */
  19.     private $foo;
  20.    
  21.     /**
  22.      * @param Foo $foo
  23.      */
  24.     public function __construct(Foo $foo)
  25.     {  
  26.         $this->foo = $foo;     
  27.     }
  28.    
  29.     /**
  30.      * @return Foo
  31.      */
  32.     public function getFoo()
  33.     {
  34.         return $this->foo;
  35.     }
  36. }

Código PHP:
Ver original
  1. $bar = new Bar(new Foo);
  2. echo $bar->getFoo()->getBaz(); //echo baz

Saludos.
__________________
http://es.phptherightway.com/
thats us riders :)