in reply to A caller() by any other name
If I understand your question correctly, you have a situation in which you call $foo->a(), which calls $bar->b(), and in the second call, you want to get $foo. Is that right?
You could, of course, pass $foo as an argument. As you correctly note, doing that "violates one, or more, OO rules & best practice(s)." I think that's also true if you could get this info from caller or some analog. That is, your desire to know this info may reveal a design problem.
You go on to say that maybe this could be a class behavior that you can add to any classes that need it. I agree this is probably a better solution, if this kind of interface is really needed at all. Something as simple as Re: Proper way to create 'globals' might do the trick too.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A caller() by any other name
by Bloodnok (Vicar) on Dec 02, 2008 at 12:18 UTC | |
by JadeNB (Chaplain) on Dec 04, 2008 at 22:22 UTC |