|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #42302 Class magic methods
Submitted: 2007-08-14 21:27 UTC Modified: 2007-08-15 13:01 UTC
From: brent dot hansen at gmail dot com Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: 5.2.4RC1 OS: XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: brent dot hansen at gmail dot com
New email:
PHP Version: OS:


 [2007-08-14 21:27 UTC] brent dot hansen at gmail dot com
This could also be a poor documentation issue. (aka Scope Resolution Operator ::) states that "When an extending class overrides the parents definition of a method, PHP will not call the parent's method. It's up to the extended class on whether or not the parent's method is called. This also applies to Constructors and Destructors, Overloading, and Magic method definitions."

leading to the conclusion that magic methods (e.g., __call) are available as class::_somefunction()

if this is just a documentation error please correct all instances of "class" with "object".

Reproduce code:
class sometest {
  function __call($method, $arguments) {
    echo $method;

// Test #1
$mytest = new sometest;
// Test #2

Expected result:
// Test #1

// Test #2

Actual result:
// Test #1

// Test #2
Fatal error: Call to undefined method testclass::dont_die()


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-15 08:08 UTC]
 [2007-08-15 13:01 UTC]
"When an extending class overrides the parents definition of a method..."

So no, nothing leads to the conclusion that the magic method __call is used on static calls.

What it means is that:

class A {
  function __call($method, $arguments) {
    echo $method;

class B extends A  {
  function __call($method, $arguments) {
    // here, A::__call won't be automatically called
    // as B overrides the definition of A::__call

    // you've to use for example:
    parent::__call($method, $arguments);

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Jun 24 10:01:23 2021 UTC