Bug #51406 [NEW]: Exception constructor calling method statically populates $this

From: Date: Fri, 26 Mar 2010 20:16:16 +0000
Subject: Bug #51406 [NEW]: Exception constructor calling method statically populates $this
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-149081@lists.php.net to get a copy of this message
From: Operating system: Windows Server 2008 PHP version: 5.3.2 Package: *General Issues Bug Type: Bug Bug description:Exception constructor calling method statically populates $this Description: ------------ You are able to call a class method statically even if it is not defined as static. If you do this from the constructor of an Exception, $this references the Exception object. This is tested on my dev machine running Windows 7, IIS7.5 and PHP 5.3.2 as well as our test server running Windows Server 2008, IIS7 and PHP 5.3.2 Test script: --------------- <?php class ExtendedException extends Exception { public function __construct($message, $code) { parent::__construct($message, $code); Log::Write("Hello!"); } } class Log { // Note this method is not marked static public function Write($string) { print_r($this); } } try { throw new ExtendedException(); } catch (Exception $e) { } ?> Expected result: ---------------- Actual result: -------------- ExtendedException Object ( [message:protected] => [string:Exception:private] => [code:protected] => 0 [file:protected] => D:\Public\Innovirt\bugtest.php [line:protected] => 18 [trace:Exception:private] => Array ( ) [previous:Exception:private] => ) -- Edit bug report at http://bugs.php.net/bug.php?id=51406&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51406&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51406&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51406&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=51406&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51406&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=51406&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=51406&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=51406&r=needscript Try newer version: http://bugs.php.net/fix.php?id=51406&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=51406&r=support Expected behavior: http://bugs.php.net/fix.php?id=51406&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=51406&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=51406&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=51406&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51406&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=51406&r=dst IIS Stability: http://bugs.php.net/fix.php?id=51406&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=51406&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=51406&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=51406&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=51406&r=mysqlcfg

« previous php.bugs (#149081) next »