Req #51554 [Opn->Wfx]: Identifies if a call is static ou 'objective'

[email protected] Wed, 14 Apr 2010 09:39:19 +0200 (CEST)
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at http://bugs.php.net/bug.php?id=51554&edit=1

 ID:          51554
 Updated by:  [email protected]
 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