php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55311 Static methods invoke __call when called from within class
Submitted: 2011-07-28 21:04 UTC Modified: 2011-07-30 19:10 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: steve at twitpic dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.3.6 OS: Ubuntu 11.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: steve at twitpic dot com
New email:
PHP Version: OS:

 

 [2011-07-28 21:04 UTC] steve at twitpic dot com
Description:
------------
When calling a non-existant static method within an objects method, php invokes 
_call instead of 
__callStatic. When calling the same non-existant static method outside of the 
object, php correctly 
invokes __callStatic.

It appears that this broke in php5.3.5 and is still broken in 5.3.6. It works as 
expected in 5.3.3, 
however.

Test script:
---------------
class Test {

  public function __call($method, $args) {
   echo "call\n";
  }

  public static function __callStatic($method, $args) {
   echo "callStatic\n";
  }

  public function testing() {

    Test::fakeFunction();

  }

}

$t = new Test;
$t->testing();
Test::fakeFunction();

Expected result:
----------------
// expected output
callStatic
callStatic

Actual result:
--------------
// output
call
callStatic

Patches

bug55311.phpt (last revision 2011-07-29 03:31 UTC by laruence@php.net)
bug55311.patch (last revision 2011-07-29 03:29 UTC by laruence@php.net)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-29 03:28 UTC] laruence@php.net
-Status: Open +Status: Verified
 [2011-07-29 03:28 UTC] laruence@php.net
looks like for some reason someone change the if/else sequence make this bug, but I am not sure why he do this.
 [2011-07-29 03:29 UTC] laruence@php.net
The following patch has been added/updated:

Patch Name: bug55311.patch
Revision:   1311910177
URL:        https://bugs.php.net/patch-display.php?bug=55311&patch=bug55311.patch&revision=1311910177
 [2011-07-29 03:31 UTC] laruence@php.net
The following patch has been added/updated:

Patch Name: bug55311.phpt
Revision:   1311910279
URL:        https://bugs.php.net/patch-display.php?bug=55311&patch=bug55311.phpt&revision=1311910279
 [2011-07-29 08:33 UTC] cataphract@php.net
-Status: Verified +Status: Bogus
 [2011-07-29 15:56 UTC] steve at twitpic dot com
This is ridiculous- this bug is not bogus, it's completely legitimate, unexpected 
behavior, and totally non documented. As a reasonable programmer, one expects a 
static call to behave the same inside of a class as well as outside of a class.

How can we bring the "desired" behavior up for vote? I think that it's insane to 
not fix it.
 [2011-07-30 19:10 UTC] cataphract@php.net
> one expects a static call to behave the same 
> inside of a class as qell as outside of a class

The thing is it's not a static call. :: only defines the scope (hence its name, "Scope Resolution Operator"), it doesn't determine whether the call is static or it isn't.
 [2012-06-24 19:20 UTC] info at dillenm dot nl
This IS a bug!
Because according to PHP.net: 
[...]is a token that allows access to static, constant, and overridden properties 
or methods of a class.[...]

This means that the "::" character should access the method or property staticly.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Apr 04 22:01:29 2025 UTC