class A
{
public function print()
{
return 'Some text...';
}
}
Class B
{
protected $a;
public function __construct(A $a)
{
$this->a = $a;
}
public function print(){
return $this->a->print();
}
}
$a = new A();
$b = new B($a);
echo $b->print(); // Some text...