Is there any way to check from where a property is being called?
Like from outside an object, from inside its children or inside himself?
I am doing some tests with the possibility of type hinting and strong typing classes like the structure proposed by jan.kneschke here, and doing so with the use of __get and __set.
But I need to know where the property is being called from, since it seems that I can't simply access that information from inside the magic methods (since I am calling an unspecified property).
Hi! Thanks for the reply, I have read that article and saw the concepts it exposes. I've read it while developping this application, and unfortunatelly couldn't find how it can help me.
What I am trying to do is setting a way to declare strong typed fields within a class, and setting it as private, protected or public and as readonly, writeonly or both.
For this to work, I am using the __get and __set magic methods to receive the call for an unset property (with the same "main" name as the ones declared inside the class, and check if it should be pointing to a "strong typed" declared property. So far so good and everything is working perfectly.
The problem is that the __get and __set methods (expectedly) does not inform me if the call is being done from within the class, its children or from outside it, so I can't check for visibility.
That is why I am looking for a possible way to make sure from where that property was called, so I can trigger the visibility check methods.
Bookmarks