Bug #52713 [Com]: Can't call undefined methods (using __call) on parent

From: Date: Tue, 31 Aug 2010 04:06:45 +0000
Subject: Bug #52713 [Com]: Can't call undefined methods (using __call) on parent
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-153962@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52713&edit=1

 ID:                 52713
 Comment by:         michael at wakeless dot net
 Reported by:        michael at wakeless dot net
 Summary:            Can't call undefined methods (using __call) on
                     parent
 Status:             Open
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   All
 PHP Version:        5.3.3
 Block user comment: N

 New Comment:

I'm pretty sure everyone should be aware of this but I'll say it
nonetheless.

parent:: isn't necessarily a static call. When it's used within an
object context it should remain within an object context, but the
subsequent call to __callStatic seems to lose it.

I tried a workaround of testing for $this in __callStatic but it seems
to have gone missing.

Is there anything I can do to help this out? Write a more comprehensive
test case that can be checked into the suite?


Previous Comments:
------------------------------------------------------------------------
[2010-08-31 01:06:05] felipe@php.net

The change was introduced as a fix for the bug #51176.

------------------------------------------------------------------------
[2010-08-31 01:05:07] felipe@php.net

The difference introduced was that the __call() just will be called when
__callStatic() is not implemented, on such static method calls.

------------------------------------------------------------------------
[2010-08-28 22:38:40] giovanni at giacobbi dot net

I ran into the same problem.

It's a serious breakage! I just tested on php 5.3.2 and it works as
expected!

------------------------------------------------------------------------
[2010-08-27 06:06:16] michael at wakeless dot net

Description:
------------
When using the __call and __callStatic functionality on a parent class
calls to parent::method() will always use __callStatic rather than the
__call. 

This breaks backwards compatibility in a number of cases.

Test script:
---------------
class A {
  function __call($method, $args) {
    if($method == "Test") {
      echo "Success.";
    }
  }
  
  function __callStatic($method, $args) {
    echo "Failure.";
  }
}

class B extends A {
  function Test() {
    echo "Test called.";
    parent::Test();
  }
}

$test = new B;
$test->Test();


Expected result:
----------------
//Expected output: Test called.Success.

Actual result:
--------------
//Actual output: Test called.Failure


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52713&edit=1


Thread (8 messages)

« previous php.bugs (#153962) next »