Re: [PHP] Function __call



Diogo Neves schreef:
Hi,

On Sat, Aug 30, 2008 at 6:20 PM, Jochem Maas <jochem@xxxxxxxxxxxxx> wrote:
please keep replies on list unless your intending to pay me
an hourly fee ...

Yeap, i'm new in the list and i missed te cc of list... i'll try to
remember, sorry

okay.

Diogo Neves schreef:

Now in understand "schreef" is from da system...

no my email client in in dutch ... it means 'wrote' ... actually that's
in the list archives already :-)

On Sat, Aug 30, 2008 at 4:40 PM, Jochem Maas <jochem@xxxxxxxxxxxxx> wrote:
Diogo Neves schreef:
...

nop... I wanna manipulate the $this and the $arguments, and possible
don't even execute the private method...

I'm tring to develop a "hook system" for my classes... and i simple
don't wanna to do all the hook verification every method of the class

I'll send my files for you to see what I'm doing in "do something" on
my __call() funtion
the code looks messy what with the global $hooks, functions required for
hooking

Yeap, but i'm only making tests... i'm not too horried about mess yet...

(the function name class_hooker() is very funny btw)

ok... i missed that in my english... added :)

and you seem to
be mixing static/non-static class calls willy-nilly.


I'm never calling something static, i'm?

er, no ... but I had to re-read the code a few times.


I'd rethink this if I we're you. if every can be hooked, then make the
hooking should be part of a base class, possibly a factory method for object
creation will help to keep things clean and in one place. a generic
'hooking'
decorator object might also be an idea. or maybe just using subclasses to
change/augment behaviour is a much simpler and cleaner approach.

yep... i'm thinking of a base class, but that has nothing to do with
the __call, if u see, i'm already passing the "get_class( $this )" and
not __CLASS__ on call_user_func of the user, but again only testing

your code makes me think of the hooking mechanism in WordPress ... works
okay,
but it's a nightmare to code to (imho).

right again, i'm trying to do a wapper for phpbb class's that have a
similar hook system, but needs to be defined method by method,
function by function... like a big mess... and even like that i don't
get yet the criteria to have a hook or not :)

as you are finding out, creating an elegant solution to this problem
is not as easy as it may seem ... especially if you stuck with
integrating to a 3rd party application.


BTW. function and method names beginning with '__' are considered reserved
by the engine, it's not best practice to name userland functions/methods
things like '__magic'


Yeap, in this case is my naming that is really pretty bad, but i
needed something diferent from the normal hookable methods, then I
simple added a '_'... but again tests, naming and code organization
was not a horry, only logic...

the single prefixed underscore to private method names will probably
be the easiest implementation ... note that passing every method call
via __call() is a rather large performance hit.


But again, i don't see why your php should see your class's private
methods outside of itself, it should simple look for a public one, if
it exists then call it, otherwise call the _call and let it handle it
:S


Anyway, thanks for answer me and give me that points, and if u know a
really good hoking system, please give me reference ;)


I guess AdultFriendFinder is not the right answer :-P


And please anyone else has an opinion of it should work or not?

again, NO it should NOT. it was not designed that way.

search the archives of internals@xxxxxxxxxxxxx for a possible answer as
to why, and you might considering asking that list why it doesn't work
the way you think it should ... note that I doubt very much it will change
because such a change would incur major BC breakage.

Thanks


.



Relevant Pages

  • Re: SysHook and STATUS_ACCESS_VIOLATION
    ... > Excuse me you claim Microsoft has a hooking library, ... Once you hook you can never unhook! ... > Don Burn (MVP, Windows DDK) ... >> So, before write so much STUPID, probably you have to listen my answer, ...
    (microsoft.public.development.device.drivers)
  • Re: How to avoid that a key can be hold down
    ... CallNextHookEx Hook, ncode, wParam, ByVal lParam ... But you must realise that any hooking of this kind is ... when running hooking code in the IDE any error ...
    (comp.lang.basic.visual.misc)
  • Re: Hooking to stop file move(ment)
    ... I do believe that my hooking function is actually being invoked; ... MoveFileW function prototype receives two long pointers to unicode strings. ... In theory, couldn't I use any type of long pointer to pass the data along, ... That about does it for how I hook the function...my Hooking function ...
    (microsoft.public.win32.programmer.kernel)
  • Re: stop sounds of a different process
    ... using detour library i managed to cause the application i'm hooking not to ... which supports both (waveOut and direct sound) so it works fine (this is just ... my hook) i do not perform the actual write and just return MMSYSERR_NOERROR, ...
    (microsoft.public.win32.programmer.directx.audio)
  • Re: SysHook and STATUS_ACCESS_VIOLATION
    ... The kernel function is ... > NTSTATUS MyZwOpenKey(IN OUT PHANDLE pHandle, IN ACCESS_MASK ReqAccess, ... >> Excuse me you claim Microsoft has a hooking library, ... Once you hook you can never unhook! ...
    (microsoft.public.development.device.drivers)