#45159 [Opn->Ver]: __callStatic() called only in static methods
| From: | colder@php.net | Date: | Tue, 03 Jun 2008 13:10:09 +0000 |
| Subject: | #45159 [Opn->Ver]: __callStatic() called only in static methods | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-125452@lists.php.net to get a copy of this message | ||
ID: 45159
Updated by: colder@php.net
Reported By: reto at buxaprojects dot com
-Status: Open
+Status: Verified
Bug Type: Class/Object related
Operating System: Fedora
PHP Version: 6CVS-2008-06-03 (snap)
New Comment:
This is somewhat expected, a call to foo::bar() from a non-static
context will be a non-static call, unless the function is explicitly
defined as static.
However, some of this(especially the part about calling a "static
method" from/to an invalid context) is scheduled for cleanup.
Previous Comments:
------------------------------------------------------------------------
[2008-06-03 11:59:19] reto at buxaprojects dot com
Description:
------------
__call() instead of __callStatic() is called, when we call a static
method from a non-static method.
Reproduce code:
---------------
abstract class One
{
public function __call($m, $p)
{
echo '__call(' . $m . ') called' . "\n";
}
public static function __callStatic($m, $p)
{
echo '__callStatic(' . $m . ') called' . "\n";
}
}
class Two extends One
{
public function __construct()
{
$this->normalMethod();
self::staticMethod();
}
private function normalMethod()
{
echo 'normalMethod() called' . "\n";
parent::a();
self::b();
static::c();
One::d();
Two::e();
}
private static function staticMethod()
{
echo 'staticMethod() called' . "\n";
parent::a();
self::b();
static::c();
One::d();
Two::e();
}
}
$two = new Two();
Expected result:
----------------
normalMethod() called
__call(a) called
__callStatic(b) called
__callStatic(c) called
__callStatic(d) called
__callStatic(e) called
staticMethod() called
__callStatic(a) called
__callStatic(b) called
__callStatic(c) called
__callStatic(d) called
__callStatic(e) called
Actual result:
--------------
normalMethod() called
__call(a) called
__call(b) called
__call(c) called
__call(d) called
__call(e) called
staticMethod() called
__callStatic(a) called
__callStatic(b) called
__callStatic(c) called
__callStatic(d) called
__callStatic(e) called
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=45159&edit=1