I have a Page class that creates out events. One of those is the UserAuth event, which gets a User entity object from the database and returns it to the page.
Now I want to protect the page's copy of the user object as much as possible, but writing has to be public to the UserAuth class or any class that extends it.
I know it's possible to see the calling function's class using debug_trace. My question is this - would using that to restrict access to the function be a good idea?
Hmm.. No - better idea.
public function setUserAuthModule ( UserAuthModule $userAuth) {
$this->userAuth = $userAuth;
}
And the userAuth module simple calls
$this->page->setUserAuthModule( $this );
I quite literally thought up that better approach while typing this up and it's sound. That said, would that prior idea ever be sane? I doubt it - it just feels like a clumsy means of trying to enforce "friend" status in PHP.








Bookmarks