|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51554 Identifies if a call is static ou 'objective'
Submitted: 2010-04-14 03:07 UTC Modified: 2010-04-14 09:39 UTC
From: david71rj at gmail dot com Assigned:
Status: Wont fix Package: Class/Object related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-04-14 03:07 UTC] david71rj at gmail dot com
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(){
      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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-14 09:39 UTC]
-Status: Open +Status: Wont fix
 [2010-04-14 09:39 UTC]
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.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jul 31 18:01:24 2021 UTC