Even though you could build workarounds (e.g. use PHP’s magic methods) PHP clearly was not designed for this. Not sure, what you try to achieve, but if it’s crucial for your project maybe try another language? In Smalltalk for example you can do this kind of thing, as everything there is an object, even classes themself.
I see. But why on earth did you pick PHP then? Have a look at Lisp (e.g. Clojure). It’s much better suited to build something like self-modifying code.
I’m using reflection to find out where the function begins and ends. The problem is that I don’t know if it’s safe to use.
new ReflectionClass(str_replace('.php', '', $this->_filename));
str_replace('.php', '', $this->_filename) // this here get's converted to a string something like 'User'
And now the question is - Is this thing safe to use ? Lets say that I have a model ‘User.php’ in my protecte.models and a User.php in protected.modules.modulename.models how will this work out ?
And if I can’t use reflection here maybe you could point me out to something else.