Order of parent and child classes in EG(class_table)

php.internals

Sebastian Bergmann

19 years ago
Hi, I am wondering whether a child class is always stored after its parent class in EG(class_table) because I would like to rely on this behaviour for the result of get_declared_classes(). Thanks, Sebastian
-- Sebastian Bergmann http://sebastian-bergmann.de/ GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69

Stanislav Malyshev

19 years ago
> I am wondering whether a child class is always stored after its parent > class in EG(class_table) because I would like to rely on this behaviour > for the result of get_declared_classes().
I think it's not written anywhere it should be so, but in fact it always would be so since when you are defining child class you have to have parent already in the class table. So unless some very nasty extension would define classes in different order, it is always so.
-- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/

Tijnema !

19 years ago
On 3/26/07, Stanislav Malyshev <stas@zend.com> wrote:
> > I am wondering whether a child class is always stored after its parent > > class in EG(class_table) because I would like to rely on this behaviour > > for the result of get_declared_classes(). > > I think it's not written anywhere it should be so, but in fact it always > would be so since when you are defining child class you have to have > parent already in the class table. So unless some very nasty extension > would define classes in different order, it is always so.
Logically it should be, but you cannot be sure it will be ALWAYS like that. 99% of the time it probably is, but sometimes things aren't going the way you expected :P Tijnema

Andrei Zmievski

19 years ago
What about the case where dl() is used? AFAIK the classes defined in dl()'ed files always go at the end of the class table. -Andrei On Mar 26, 2007, at 10:29 AM, Stanislav Malyshev wrote:

Stanislav Malyshev

19 years ago
> What about the case where dl() is used? AFAIK the classes defined in > dl()'ed files always go at the end of the class table.
Any class that is defined goes at the end of the class table existing at the time, no matter if it's dl() or not. If loaded extension defines classes derived from existing ones, they would be after existing classes. If it defines both parent and child class, then in theory it could do it so that child class would enter the class table before the parent class, but it'd be quite broken extension.
-- Stanislav Malyshev, Zend Products Engineer stas@zend.com http://www.zend.com/