From:             
Operating system: Linux, Fedora 13 64 bits
PHP version:      5.3.3RC1
Package:          Arrays related
Bug Type:         Bug
Bug description:array_splice problem with Closures

Description:
------------
array_splice don't works with Closures.

Test script:
---------------
<?php

$items = array( 'to remove' , 'item' );



var_dump( phpversion() );



array_splice( $items , 0 , 1 , 'works with strings' );

var_dump( $items );



array_splice( $items , 0 , 1 , 10 ); //with numbers

var_dump( $items );



array_splice( $items , 0 , 1 , true ); //with booleans

var_dump( $items );



array_splice( $items , 0 , 1 , array( 'it\'s' , 'ok' ) ); //with arrays

var_dump( $items );



$items = array( 'to remove' , 'item' );

$func = function(){ return 'just a test'; };



array_splice( $items , 0 , 1 , $func ); //but not with Closures

var_dump( $items );

Expected result:
----------------
string(5) "5.3.0"

array(2) {

  [0]=>

  string(18) "works with strings"

  [1]=>

  string(4) "item"

}

array(2) {

  [0]=>

  int(10)

  [1]=>

  string(4) "item"

}

array(2) {

  [0]=>

  bool(true)

  [1]=>

  string(4) "item"

}

array(3) {

  [0]=>

  string(4) "it's"

  [1]=>

  string(2) "ok"

  [2]=>

  string(4) "item"

}

array(2) {

  [0]=>

  object(Closure)#2 (0) {

  }

  [1]=>

  string(4) "item"

}

Actual result:
--------------
PHP 5.3.0:



string(5) "5.3.0"

array(2) {

  [0]=>

  string(18) "works with strings"

  [1]=>

  string(4) "item"

}

array(2) {

  [0]=>

  int(10)

  [1]=>

  string(4) "item"

}

array(2) {

  [0]=>

  bool(true)

  [1]=>

  string(4) "item"

}

array(3) {

  [0]=>

  string(4) "it's"

  [1]=>

  string(2) "ok"

  [2]=>

  string(4) "item"

}

array(1) {

  [0]=>

  string(4) "item"

}

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



PHP 5.3.2



string(5) "5.3.2"

array(2) {

  [0]=>

  string(18) "works with strings"

  [1]=>

  string(4) "item"

}

array(2) {

  [0]=>

  int(10)

  [1]=>

  string(4) "item"

}

array(2) {

  [0]=>

  bool(true)

  [1]=>

  string(4) "item"

}

array(3) {

  [0]=>

  string(4) "it's"

  [1]=>

  string(2) "ok"

  [2]=>

  string(4) "item"

}

array(1) {

  [0]=>

  string(4) "item"

}

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



PHP 5.3.3-dev



string(9) "5.3.3-dev"

array(2) {

  [0]=>

  string(18) "works with strings"

  [1]=>

  string(4) "item"

}

array(2) {

  [0]=>

  int(10)

  [1]=>

  string(4) "item"

}

array(2) {

  [0]=>

  bool(true)

  [1]=>

  string(4) "item"

}

array(3) {

  [0]=>

  string(4) "it's"

  [1]=>

  string(2) "ok"

  [2]=>

  string(4) "item"

}

array(1) {

  [0]=>

  string(4) "item"

}

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

Reply via email to