From: [EMAIL PROTECTED] Operating system: Solaris PHP version: 4.2.3 PHP Bug Type: Scripting Engine problem Bug description: Calling static method from instance method results in invalid $this
Here is an example ... <?php class Foo { function Foo() { $this->class = 'foo'; } function doCall() { return Bar::staticFunction(); } }; class Bar { function staticFunction() { if ( isset( $this ) ) { print 'This isset <br />'; print_r( $this ); } else { print 'Call as a static <br />'; } } }; $foo =& new Foo(); $foo->doCall(); ?> Note an instance of Foo is calling a static method of Bar. Bar does a test to see if $this is set. $this should not be set, since the method was statically invoked. Unfortunately, $this is set and its the instance of Foo that made the call to the static method of Bar. This bug makes writing methods that work both as static methods and instance methods virtually impossible. It is also extremely unsafe to allow Bar to access the member variables of Foo. -- Edit bug report at http://bugs.php.net/?id=20089&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20089&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20089&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20089&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20089&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20089&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=20089&r=support Expected behavior: http://bugs.php.net/fix.php?id=20089&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=20089&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=20089&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20089&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20089&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20089&r=dst IIS Stability: http://bugs.php.net/fix.php?id=20089&r=isapi