From:             dmsuperman at gmail dot com
Operating system: Linux Ubuntu
PHP version:      5.2.8
PHP Bug Type:     *Regular Expressions
Bug description:  preg_replace_callback calling a __call returns incorrect 
values

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 bug report at http://bugs.php.net/?id=47235&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47235&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47235&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47235&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47235&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47235&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47235&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47235&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47235&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47235&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47235&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47235&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47235&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47235&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47235&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47235&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47235&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47235&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47235&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47235&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47235&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47235&r=mysqlcfg

Reply via email to