|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-01-29 02:34 UTC] dmsuperman at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 19:00:01 2025 UTC |
Description: ------------ When combining the use of preg_replace_callback with the __call automagic function, the value returned to the automagic __call function differs from the expected value. It's always wrapped in a single-element single-dimensional array (from what I can tell). The example code with varied results can describe what I mean perfectly. This happens in 5.2.6 and 5.2.8 (I just downloaded the latest version before testing this bug to be sure). Reproduce code: --------------- <?php class my { function doit(){ preg_replace_callback("/(.+)/", "var_dump", "aa"); preg_replace_callback("/(.+)/", array($this, "output"), "aa"); preg_replace_callback("/(.+)/", array($this, "somefunc"), "aa"); } function output($arg){ var_dump($arg); } function __call($func, $arg){ var_dump($arg); } } $obj = new my(); $obj->doit(); ?> Expected result: ---------------- array(2) { [0]=> string(2) "aa" [1]=> string(2) "aa" } array(2) { [0]=> string(2) "aa" [1]=> string(2) "aa" } array(2) { [0]=> string(2) "aa" [1]=> string(2) "aa" } Actual result: -------------- array(2) { [0]=> string(2) "aa" [1]=> string(2) "aa" } array(2) { [0]=> string(2) "aa" [1]=> string(2) "aa" } array(1) { [0]=> array(2) { [0]=> string(2) "aa" [1]=> string(2) "aa" } }