I've tried searching for this but frankly I don't know what to search for and unfortunately I imagine this question has been asked before.
In PHP, and possibly other languages, why can't I use an object immediately after I create it?
// This causes an error
$obj = new Object()->myFunction();
Note: I return $this
in most of my setter functions so I can chain them together
function myFunction() {
// ... some more code here ...
return $this;
}