#27304 [Opn->Csd]: ZE2 Static functions don't function properly
| From: | helly@php.net | Date: | Thu, 26 May 2005 12:26:02 +0000 |
| Subject: | #27304 [Opn->Csd]: ZE2 Static functions don't function properly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-79547@lists.php.net to get a copy of this message | ||
ID: 27304
Updated by: helly@php.net
Reported By: john@php.net
-Status: Open
+Status: Closed
Bug Type: Feature/Change Request
-Operating System: RH8
+Operating System: *
-PHP Version: 5CVS-2004-02-18 (dev)
+PHP Version: < 5.0.3
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2004-02-18 02:44:44] john@php.net
Description:
------------
Static functions don't behave properly at all. They can be called from
an object-context and provide no means to even confirm from within the
function if it has been called from a static context or not.
I understand that static methods should never have access to $this
regardless of context, but unless the engine enforces a restriction on
calling static functions from an object context this behavior is
completely counter-intuitive and inconsistent. Not only does the engine
not catch this, but the developer cannot either.
Reproduce code:
---------------
<?php
error_reporting(E_ALL);
class Staticexample {
const a = 10;
static function test() {
var_dump(isset($this));
}
}
$b = new Staticexample();
Staticexample::test();
$b->test();
?>
Expected result:
----------------
bool(false)
bool(true)
Actual result:
--------------
bool(false)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27304&edit=1