class_implements()/class_parents() accepting string parameter

php.internals

Lukas Smith

21 years ago
Hi, it would be very useful if class_implements()/class_parents() would also handle a string containing a class name instead of requiring an object instance. regards, Lukas

Marcus Boerger

21 years ago
Hello Lukas, Wednesday, April 6, 2005, 3:46:08 PM, you wrote:
> Hi,
> it would be very useful if class_implements()/class_parents() would also > handle a string containing a class name instead of requiring an object > instance.
Class as it says does not need an instance. Can you send a patch?
-- Best regards, Marcus mailto:mail@marcus-boerger.de

Andrey Hristov

21 years ago
Marcus Boerger wrote:
> Hello Lukas, > > Wednesday, April 6, 2005, 3:46:08 PM, you wrote: > > >>Hi, > > >>it would be very useful if class_implements()/class_parents() would also >>handle a string containing a class name instead of requiring an object >>instance. > > > Class as it says does not need an instance. Can you send a patch? > >
Hello Marcus, Lucas, I have made a patch for class_implements() : http://andrey.hristov.com/projects/php_stuff/patches/class_implements.patch.txt The function is here : http://andrey.hristov.com/projects/php_stuff/patches/class_implements.c Andrey

Andrey Hristov

21 years ago
Andrey Hristov wrote:
> Marcus Boerger wrote: > >> Hello Lukas, >> >> Wednesday, April 6, 2005, 3:46:08 PM, you wrote: >> >> >>> Hi, >> >> >> >>> it would be very useful if class_implements()/class_parents() would >>> also handle a string containing a class name instead of requiring an >>> object instance. >> >> >> >> Class as it says does not need an instance. Can you send a patch? >> >> > Hello Marcus, Lucas, > I have made a patch for class_implements() : > > http://andrey.hristov.com/projects/php_stuff/patches/class_implements.patch.txt > > The function is here : > http://andrey.hristov.com/projects/php_stuff/patches/class_implements.c > > Andrey >
and this is the test script : ./php -r 'interface iface1{}interface iface2{} class a implements iface1, iface2{} var_dump(class_implements(new a), class_implements("a"), class_implements("aaa"), class_implements("bbb", 0)); function __autoload($cname){ var_dump($cname);}' or <?php interface iface1{} interface iface2{} class a implements iface1, iface2{} var_dump(class_implements(new a), class_implements("a"), class_implements("aaa"), class_implements("bbb", 0) ); function __autoload($cname){ var_dump($cname); } ?>