#42302 [Opn->Bgs]: Class magic methods

From: Date: Wed, 15 Aug 2007 13:01:10 +0000
Subject: #42302 [Opn->Bgs]: Class magic methods
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969377357@lists.php.net to get a copy of this message
ID: 42302 Updated by: colder@php.net Reported By: brent dot hansen at gmail dot com -Status: Open +Status: Bogus Bug Type: Documentation problem Operating System: XP PHP Version: 5.2.4RC1 New Comment: "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); } } Previous Comments: ------------------------------------------------------------------------ [2007-08-15 08:08:13] jani@php.net Reclassified. ------------------------------------------------------------------------ [2007-08-14 21:27:23] brent dot hansen at gmail dot com Description: ------------ This could also be a poor documentation issue. http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php (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; $mytest->dont_die(); // Test #2 sometest::dont_die(); Expected result: ---------------- // Test #1 dont_die // Test #2 dont_die Actual result: -------------- // Test #1 dont_die // Test #2 Fatal error: Call to undefined method testclass::dont_die() ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42302&edit=1

« previous php.doc (#969377357) next »