# catch of object operations __set and __invoke

- Thread: https://externals.io/message/11425
- Original archive: https://news-web.php.net/php.internals/11425
- Started by Leonardo Pedretti on 2004-07-21T14:03:09+00:00
- Messages: 2
- 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

---

## #11425 — Leonardo Pedretti — 2004-07-21T14:03:09+00:00

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

Hi all.
I have just messed around with the php 5 code so to find a way to implement 
some way to make objects call some magic method when there is an invocation 
of a non existent method, or a setting of a non existent data member (this 
last may not be neccesary by now for what i am implementint, but it would be 
correct to implement them both).
I have tracked in the zend_execute.c file, line 2507, the call to the error 
when the method is not found, inside the function 
zend_init_method_call_handler
My question is: the parameter lists in every call is a defined constant... it 
just becomes impossible to backtrack, can someone give me just a bit of 
information on this topic?
What i think would be correct is that the function that calls 
zend_init_method_call_handler receives an error in the case the method is not 
found, and in that case it calls the handler again calling __invoke() with an 
array of the original parameters and the name of the original function that 
was called. Another method would be to always call __invoke() passing it the 
original call information, and depending on the return code of __invoke() 
then execute the original call.
However, I can't find where this hook should be placed around the code. If 
someone can give me a bit of info on this topic, i would love to make the 
patch.

With regards
-- 

Leonardo Pedretti
Axon Sistemas
Líder de Equipo Proyecto Basalto

---

## #11441 — Marcus Boerger — 2004-07-21T19:40:03+00:00

URL: https://externals.io/message/11425#11441 · In reply to: #11425

Hello Leonardo,

Wednesday, July 21, 2004, 4:03:09 PM, you wrote:

> Hi all.
> I have just messed around with the php 5 code so to find a way to implement
> some way to make objects call some magic method when there is an invocation
> of a non existent method

Just use: __call()

regards
marcus
