# Order of parent and child classes in EG(class_table)

- Thread: https://externals.io/message/28601
- Original archive: https://news-web.php.net/php.internals/28601
- Started by Sebastian Bergmann on 2007-03-26T17:17:43+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #28601 — Sebastian Bergmann — 2007-03-26T17:17:43+00:00

URL: https://externals.io/message/28601#28601

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

---

## #28602 — Stanislav Malyshev — 2007-03-26T17:29:47+00:00

URL: https://externals.io/message/28601#28602 · In reply to: #28601

>  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/

---

## #28603 — Tijnema ! — 2007-03-26T17:35:53+00:00

URL: https://externals.io/message/28601#28603 · In reply to: #28602

> > […]
>
> 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
> --
> Stanislav Malyshev, Zend Products Engineer
> stas@zend.com  http://www.zend.com/

---

## #28607 — Andrei Zmievski — 2007-03-26T22:05:06+00:00

URL: https://externals.io/message/28601#28607 · In reply to: #28602

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



> > […]
>
> 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/

---

## #28608 — Stanislav Malyshev — 2007-03-26T22:16:55+00:00

URL: https://externals.io/message/28601#28608 · In reply to: #28607

> 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/
