How to mimic C++ template classes in PHP?
EDITED1
For example how would this be in PHP?
template <typename T>
class MyQueue
{
std::vector<T> data;
public:
void Add(T const &d);
void Remove();
void Print();
};
Converting your C++ code to PHP:
As Thirler explained, PHP is dynamic, so you can pass anything you want to the Add function, and hold whatever values you want in $data. If you really wanted to add some type safety, you would have to pass the type you want to allow to the constructor.
Then you can add some checks in other functions using the instanceof operator.
However, it will not come close to the functionality of a statically typed languge that is designed to catch the type errors at compile time.