|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-08-16 13:15 UTC] vrana@php.net
[2007-08-16 23:51 UTC] ozone at cname dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 20 08:00:01 2025 UTC |
Description: ------------ Documentation states that the __call() method will be passed two arguments, the first being the name of the called method, the second being *an array* of the arguments. Thus, when daisy-chaining the __call() method via parent::__call() or equivalent, the second __call() should have an array with a single element which is an array of the arguments passed to the first __call(). The actual behavior is more desirable than the documented behavior, and this is probably "not a bug". That said, I don't want to rewrite my code if a future version of PHP changes the behavior without warning. Reproduce code: --------------- class a { function __call($m, $a) { echo "--- a::$m\n"; echo "call($m) "; var_dump($a); } } class b extends a { function __call($m, $a) { echo "--- b::$m\n"; if($m == "special") { echo "special override "; var_dump($a); } else parent::__call($m, $a); } } $ca = new a(); $cb = new b(); $ca->test(); $ca->test("one", "two"); $cb->special(); $cb->test(); $cb->test("one", "two"); Expected result: ---------------- A literal interpretation of the documentation says the var_dump ultimately executed by the last call to $cb->test() "should" display something like: array(1) { [0]=> array(2) { [0]=> string(3) "one" [1]=> string(3) "two" } } Actual result: -------------- array(2) { [0]=> string(3) "one" [1]=> string(3) "two" }