Size bu şeylerin hiçbirini yapamazsınız gerçekten can sıkıcı (ve değil herhangi bir mantıklı değil):
new A('foo')->bar();
(new A('foo'))->bar();
Düşünebildiğim tek şey, yeni bir nesneyi döndürmek için statik bir işlevi var olmaktır
public static function get($a) {
return new self($a);
}
// ...
A::get('foo')->bar();
But that's just ugly. The reason why I need this is because in the context of the object definition I mostly pass the new object as parameter or as part of an array:
new B(array(
new A('foo')->bar()
new A('smt')->bar()->more()
));
bar()
ve more()
tabii nesnesine bir başvuru döndürmek.