Is it possible to return an interface from a function? Example:
interface DBInterface {
public function getDB();
[...]
}
class Bar {
public function defineDBObject($name){
return DBInterface;
}
}
I doubt it, but I have a client who likes to write involved spec docs that are calling for it. I want to make sure that it is, in fact, impossible.
You can’t. You can only return objects or primitives. Classes and interfaces are not objects in PHP.