<?php
class foo{
public $a; //bar
function __construct(bar $a)
{
$this->a = $a;
}
public function scream(){
echo "scream";
}
}
class bar {
public function tryToScream()
{
///?????? Is it a way to call foo->scream() from here ?????
}
}
$f = new foo(new bar());
$f->a->tryToScream();
PD9waHAKCmNsYXNzIGZvb3sKICAgIHB1YmxpYyAkYTsgLy9iYXIKCiAgICBmdW5jdGlvbiBfX2NvbnN0cnVjdChiYXIgJGEpCiAgICB7CiAgICAgICAgJHRoaXMtPmEgPSAkYTsKICAgIH0KCgogICAgcHVibGljIGZ1bmN0aW9uIHNjcmVhbSgpewogICAgICAgIGVjaG8gInNjcmVhbSI7CiAgICB9Cn0KCmNsYXNzIGJhciB7CiAgICBwdWJsaWMgZnVuY3Rpb24gdHJ5VG9TY3JlYW0oKQogICAgewogICAgICAgIC8vLz8/Pz8/PyBJcyBpdCBhIHdheSB0byBjYWxsIGZvby0+c2NyZWFtKCkgZnJvbSBoZXJlID8/Pz8/CiAgICB9Cn0KCiRmID0gbmV3IGZvbyhuZXcgYmFyKCkpOwokZi0+YS0+dHJ5VG9TY3JlYW0oKTsK