When concreate classes implement interface, do they return object of type interface that they are implementing? In typical factory pattern scenario the concrete classes return object of type interface they are implementing (for java and C# this is true). Does this happen in case of PHP also?
Consider the following situation..
interface IUser
{
function getName();
}
class User implements IUser
{
public function __construct( $id ) { }
public function getName()
{
return "Jack";
}
}
class UserFactory
{
public static function Create( $id )
{
return new User( $id );
}
}
$uo = UserFactory::Create( 1 );
echo( $uo->getName()."
" );
Is object $uo an instance of type IUser or User, and why?