ID:               47235
 User updated by:  dmsuperman at gmail dot com
 Reported By:      dmsuperman at gmail dot com
-Status:           Open
+Status:           Closed
 Bug Type:         *Regular Expressions
 Operating System: Linux Ubuntu
 PHP Version:      5.2.8
 New Comment:

I'm an idiot, I forgot __call recieved an _array_ of arguments. Ignore
this, sorry guys


Previous Comments:
------------------------------------------------------------------------

[2009-01-29 02:26:33] dmsuperman at gmail dot com

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"
  }
}


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


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

Reply via email to