1

I have a class that returns stdClass.

Every time I extend it, I supply the constructor with some kind of type (as a string), and all of the methods returns stdClass of that type.

I would like to do - just like in C++/Java/Typescript:

new B<User> so the code knows to expect a user being returned.

Over more, I would like to do:

class A extends B<User> {

I can't find any trace of mentioning it in the php.net website, or anywhere else. So is there support for it or not? (I realise probably not, but wanna be sure)

Amit
  • 5,924
  • 7
  • 46
  • 94
  • Possible duplicate of [Class template in PHP like in C++](http://stackoverflow.com/questions/21605535/class-template-in-php-like-in-c) – Ruslan Osmanov Dec 08 '16 at 12:16

1 Answers1

0

No, php doesn't not support template classes.

But HACK does.

Faouzi Oudouh
  • 800
  • 3
  • 15