From:             olympic at dino-online dot de
Operating system: all
PHP version:      5.0.5
PHP Bug Type:     Feature/Change Request
Bug description:  static calls and $this

Description:
------------
In static calls $this is set. 

While in theory it might make sense to allow objects 
of the same class (or derived class) to "use" this 
feature, it's a potential pitfall and from my point 
of view it's bug.

I think if a non static method is called statically
then $this can't be any object that hasn't been
created by this or a derive class.

No other language has such a "feature" :)

If it's not a bug, then read my bugreport as 
"remove this feature". 
If it's a bug, add a runtime checking for $this is object
created by same or derived class.


Reproduce code:
---------------
Example:
Noone can really say that this is "transparen" ok:

class Foo {
        private    $hallo="I am from Foo";
        function dontCallMe() {

                return $this->hallo;
        }
}
class Bar {
        public $hallo="I am from Bar";
        function testMe() {
                return Foo::dontCallMe();
        }
}
$x=new Bar();
echo ($x->testMe()); // expected runtime error...









Expected result:
----------------
Runtime error.

Actual result:
--------------
output is: "I am from Bar"


This return the member var of Bar, what you would NEVER expect.

-- 
Edit bug report at http://bugs.php.net/?id=34990&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=34990&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=34990&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=34990&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=34990&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=34990&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=34990&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=34990&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=34990&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=34990&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=34990&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=34990&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=34990&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=34990&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=34990&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=34990&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=34990&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=34990&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=34990&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=34990&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=34990&r=mysqlcfg

Reply via email to