However, I keep wrestling with what is the 'best' approach for handling DB queries that should return, say, an array but may return 'false' if the entry is not found.
It would be nice if declaring the return type as nullable (e.g. fcn(): ?array) would work, but it doesn't -- false is not null.
One approach is to use a ternary operation on the query result; e.g.
Code: Select all
return $result ?: null;
Of course, there may be better methods, and I would appreciate any suggestions.