Req #51554 [Opn->Wfx]: Identifies if a call is static ou 'objective'
| From: | degeberg@php.net | Date: | Wed, 14 Apr 2010 07:39:19 +0000 |
| Subject: | Req #51554 [Opn->Wfx]: Identifies if a call is static ou 'objective' | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-149556@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=51554&edit=1
ID: 51554
Updated by: degeberg@php.net
Reported by: david71rj at gmail dot com
Summary: Identifies if a call is static ou 'objective'
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: Class/Object related
PHP Version: Irrelevant
New Comment:
You shouldn't interchange static and non-static methods. If you need to
call a method statically, mark it as static. Your code below will give
an E_STRICT error.
Previous Comments:
------------------------------------------------------------------------
[2010-04-14 03:07:55] david71rj at gmail dot com
Description:
------------
If a call a method as static, how I can test if is a static call or
objective?
Well, I think about "is_static_call()", example:
class A {
public function test(){
if(is_static_call()){
echo 'Static method';
}
else {
echo 'Objective method';
}
}
}
A::test(); // Static method
$a = new A;
$a->test(); // Objective method
Currently I use a 'workarround' for this problem:
if($this && get_class($this) === get_class()){
// Objective method
}
This is my sugestion.
Bye.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51554&edit=1