Background
In every other programming language I use on a regular basis, it is simple to operate on the return value of a function without declaring
Does this work?
return ($foo->getBarArray())[0];
Otherwise, can you post the getBarArray() function? I don't see why that wouldn't work from what you posted so far.