Hi Stas,

Am 12.02.2015 um 22:31 schrieb Stanislav Malyshev:
Hi!

class A {
     // This is an *instance* method, but it doesn't actually use $this.
     // This kind of usage is very common in PHP 4 era code, where
     // "static" annotations weren't used
     function test() {
         echo "foo";
     }
}

class B {
     function test2() {
         // This call would be forbidden because it assumes $this of class
B, when
         // calling an instance method of class A. However A::test() does
not actually
         // use $this!
         A::test();
     }
}
IMHO, this should work. Maybe issue E_STRICT, but even then I'd think
it's not really necessary, I can't see any purpose E_STRICT serves in
this case - since $this is not used, no potential bug is averted, as the
code works exactly as it was supposed to be working.

Such code will break, not in the first place but later on!
You propose that every instance method not using the variable $this internally will be magically a static method and can never ever be changed to use $this without an bc break.

<snip>


Marc


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to