Is there some equivalent of "friend" or "internal" in php? If not, is there any pattern to follow to achieve this behavior?
Edit: Sorry, but standard Php isn't what I'm looking for. I'm looking for something along the lines of what ringmaster did.
I have classes which are doing C-style system calls on the back end and the juggling has started to become cumbersome. I have functions in object A which take in object B as a parameter and have to call a method in object B passing in itself as an argument. The end user could call the method in B and the system would fall apart.
PHP doesn't support any friend-like declarations. It's possible to simulate this using the PHP5 __get and __set methods and inspecting a backtrace for only the allowed friend classes, although the code to do it is kind of clumsy.
There's some sample code and discussion on the topic on PHP's site:
(Code proved by tsteiner at nerdclub dot net on bugs.php.net)