Re: Extension class inherit from PHP class

[email protected] (Johannes Schlüter)
Newsgroups php.pecl.dev
Organization php.net
Message-ID <1270827375.6262.41.camel@guybrush>
On Thu, 2010-04-08 at 16:33 -0700, Trevan Richins wrote:
> I'm wondering if it is possible to have a class defined in a C extension 
> inherit from a class defined in PHP.  
[...]
> Is there something that I'm missing or is this even possible?  

It's nothing that's supposed tobe possible. The engine is designed in a
way that internal classes are registered on module startup and survive
multiple requests and are destroyed on PHP module shutdown.

The only hack to do what you want I can image is to manually unregister
it on request shutdown. While I have no idea what the consequences for
opcode caches and similar thing might be.

> If you are wondering why I'm doing this, it is an attempt to speed up legacy
>  code.  I plan to move slow methods from Grandchild to Child while leaving
>  the normal hierarchy intact.

Well, I'd rather rethink the approach. Either make your internal class
the base class or make the existing functions proxies calling global
function/methods from some specific class.

johannes
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.