# Calling original function from an overloaded function

- Thread: https://externals.io/message/38124
- Original archive: https://news-web.php.net/php.internals/38124
- Started by Christoph Dorn on 2008-06-10T04:29:12+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #38124 — Christoph Dorn — 2008-06-10T04:29:12+00:00

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

I have been looking at xdebug and have figured out how to overload a
function. As a test I have overloaded the var_dump function.

Now how do I call the original var_dump function from my implementation?
Borrowing from OO terminology I have subclassed the var_dump method, now
I want to call parent::var_dump() from my subclass.

Also how does overloading work when two extensions overload the same
function? Can this be done? Is there some sort of order? Can I let the
other extension overload the function and then overload the function
from the other extension?

Any pointers would be greatly appreciated.

Thanks

Christoph

---

## #38125 — Alexey Zakhlestin — 2008-06-10T04:56:25+00:00

URL: https://externals.io/message/38124#38125 · In reply to: #38124

Well, speaking in broad terms, I would suggest to store the pointer to
original function before overloading it, and calling that, when you
need it


> I have been looking at xdebug and have figured out how to overload a
>  function. As a test I have overloaded the var_dump function.
>
>  Now how do I call the original var_dump function from my implementation?
>  Borrowing from OO terminology I have subclassed the var_dump method, now
>  I want to call parent::var_dump() from my subclass.
>
>  Also how does overloading work when two extensions overload the same
>  function? Can this be done? Is there some sort of order? Can I let the
>  other extension overload the function and then overload the function
>  from the other extension?
>
>  Any pointers would be greatly appreciated.
>
>  Thanks
>
>  Christoph
>
>
>
>
>  --
>  
>  
>
>


-- 
Alexey Zakhlestin
http://blog.milkfarmsoft.com/

---

## #38126 — Gregory Beaver — 2008-06-10T05:46:21+00:00

URL: https://externals.io/message/38124#38126 · In reply to: #38124

Christoph Dorn wrote:
> I have been looking at xdebug and have figured out how to overload a
> function. As a test I have overloaded the var_dump function.
> 
> Now how do I call the original var_dump function from my implementation?
> Borrowing from OO terminology I have subclassed the var_dump method, now
> I want to call parent::var_dump() from my subclass.
> 
> Also how does overloading work when two extensions overload the same
> function? Can this be done? Is there some sort of order? Can I let the
> other extension overload the function and then overload the function
> from the other extension?
> 
> Any pointers would be greatly appreciated.

Hi,

phar does exactly what you're describing, this is all encapsulated in
func_interceptors.c:

http://cvs.php.net/viewvc.cgi/php-src/ext/phar/func_interceptors.c?revision=1.20.2.1&content-type=text%2Fplain&pathrev=1.20.2.1

Greg
