I'm trying to use Repositories which implement my RepositoryInterface.
As a C# .NET developer I would create a Generic interface like this:
public interface IRepository<TModelType>
{
IEnumerable<TModelType> FindAll();
void Save(TModelType model);
}
I would implement it like this:
public class UserRepository : IRepository<User>
{
public IEnumerable<User> FindAll()
{
// Method body
}
public void Save(User model)
{
// Method body
}
}
Now my question: Is there something like this in PHP?
EDIT:
The reason I want to do this is type safety and code completion assistance and I don't want to cast the model parameter all the time. ;-)
Generics equivalent in PHP
Hello guys,
I'm trying to use Repositories which implement my RepositoryInterface. As a C# .NET developer I would create a Generic interface like this:
I would implement it like this:
Now my question: Is there something like this in PHP?
EDIT:
The reason I want to do this is type safety and code completion assistance and I don't want to cast the model parameter all the time. ;-)
Regards, Stefan