#25220 [Csd->Opn]: Statically called members can access $this
| From: | php at koert dot bitfactory dot nl | Date: | Sat, 29 Nov 2003 12:11:24 +0000 |
| Subject: | #25220 [Csd->Opn]: Statically called members can access $this | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-51326@lists.php.net to get a copy of this message | ||
ID: 25220
User updated by: php at koert dot bitfactory dot nl
Reported By: php at koert dot bitfactory dot nl
-Status: Closed
+Status: Open
Bug Type: Zend Engine 2 problem
Operating System: Cygwin/win2k
PHP Version: 5CVS-2003-08-23 (dev)
New Comment:
Still not fixed, it produces the wrong error. It should warn about
$this, not about $variable.
I am cvsupping as we speak, but i assume thie following testcase still
doesn't produce an error:
class static_class {
var $variable="Variable in static_class.";
function static_func() { echo $this->variable; }
}
class testclass {
var $variable="Variable in testclass.";
function func() { static_class::static_func(); }
}
$x = new testclass();
$x->func();
Previous Comments:
------------------------------------------------------------------------
[2003-11-28 20:46:25] sniper@php.net
Output with latest CVS:
PHP Notice: Undefined property: testclass::$variable in
/home/jani/t.php on line 4
------------------------------------------------------------------------
[2003-08-23 11:19:11] php at koert dot bitfactory dot nl
Description:
------------
If a static method is called from an objectcontext, $this is accessible
from that objectcontext.
$this should be out of scop in the static method...
Reproduce code:
---------------
class static_class {
function static_func() { echo $this->variable; }
}
class testclass {
function func() { static_class::static_func(); }
}
$x = new testclass();
$x->func();
Expected result:
----------------
<br />
<b>Fatal error</b>: Using $this when not in object context in
<b>[filename]</b> on line <b>2</b><br />
Actual result:
--------------
No output (thus no error)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25220&edit=1