While writing some PHP, I needed to iterate over a function call that could also return null
, so I used the following construct:
foreach (($object->method() ? : array()) as $thing)
{
// Insert code here
}
My project manager was not fond of this practice and insisted I write something more verbose. I understand his perspective, but if it were up to me, I would leave it as is. What do others think of this practice?