#26802 [Ver->Csd]: Can't call function through static property
| From: | zeev@php.net | Date: | Wed, 11 Feb 2004 10:43:10 +0000 |
| Subject: | #26802 [Ver->Csd]: Can't call function through static property | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-54744@lists.php.net to get a copy of this message | ||
ID: 26802
Updated by: zeev@php.net
Reported By: adam at trachtenberg dot com
-Status: Verified
+Status: Closed
Bug Type: Zend Engine 2 problem
Operating System: *
PHP Version: 5CVS
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.
$static_method = "foo::bar";
$static_method();
is not supposed to work. The incompatibility with PHP 4 has been
fixed.
Previous Comments:
------------------------------------------------------------------------
[2004-01-05 19:49:38] helly@php.net
Updated test to all different versions showed that indeed one way of
calling a class is wrong.
class::$prop() should evaluate class::$prop and call that function. But
instead it calls the method specified by the result in the class given.
In other words the class name is used twice.
------------------------------------------------------------------------
[2004-01-05 17:03:57] adam at trachtenberg dot com
Description:
------------
You cannot dynamically call a static methods using a
variable. This works for regular functions, for example:
function foo() {}
$f = 'foo';
$f();
Reproduce code:
---------------
class foo {
static public function bar() {
print "baz\n";
}
}
foo::bar();
$static_method = "foo::bar";
$static_method();
Expected result:
----------------
baz
baz
Actual result:
--------------
PHP Fatal error: Call to undefined function foo::bar()
in /php/test.php on line 10
baz
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26802&edit=1