On Sat, Aug 4, 2012 at 12:40 AM, Andrew Faulds <a...@ajf.me> wrote: > While we're at it, > > $a = 'this'; > $$a = new StdClass(); > > should be an error. > Also $GLOBALS['this'] = new StdClass(); > > https://bugs.php.net/bug.php?id=52428
Hehe, I already caught all those executor tricks, like : <?php ${'th'.'is'} = 'what I want'; In fact, "$this" is checked at compile time. The compiler checks for the letters t+h+i+s to be found in the code, (usually throught strcmp()) and acts as we know. $this is never checked at execution, that's why we can use such tricks to do illegal things. I discussed that with [I cant remember who] (Felipe wasn't it?) few times ago, and he told me that checking for $this to be used at execution time would be too time consuming (I assume it would need a lookup at every variable read operation, so that's why). Plus, if someone wants to shoot himself in the foot, then let him do it. Coming back to the RFC subject : - Excuse me to perhaps ask for too much but: why don't we simply forbid any static method call to non static method ? I mean, that's something I've never understood why PHP allows an instance method to be called statically ? That's a non sense to my eyes, I've never used such a thing in my PHP life. That's ugly, illogic and simply wrong. If you want to call a method statically, then make it static and then prevent it from carrying any $this information. But I see that most of you would prefer keeping this behavior and somehow fix it by just turning $this to NULL in incompatible context. I would have thrown an E_FATAL-what're-u-doing error :-p Julien -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php