ID:               43543
 Updated by:       [EMAIL PROTECTED]
 Reported By:      dharma dot yp at in dot ibm dot com
-Status:           Open
+Status:           Wont fix
 Bug Type:         Arrays related
 Operating System: Windows, Linux
 PHP Version:      5.2CVS-2007-12-09 (snap)
 New Comment:

It's fine as it is for 5.2. If it's not ok for 5.3, reopen.


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

[2007-12-09 14:26:19] dharma dot yp at in dot ibm dot com

Description:
------------
In array_walk() and array_walk_recursive() functions, 
1) In PHP 5.2 , if we pass non-existent function( not defined), it is
expected to output the warning message with return value "false".It is
able output the warning message but not the correct return value. The
warning message and return value is as follows. 

"Warning: array_walk(): Unable to call wrong_function() - function does
not exist in %s on line %d
bool(true)".
   Where as in PHP6, it works correct and warning message is as
follows.

"Warning: array_walk_recursive() : Expects parameter 2 to be valid
callback, string given in %s on line %d
NULL".


2) In PHP5.2, if we pass less number of parameters for "callback"
function through the array_walk() call, it is expected to ouput the
warning message with return value of "false". It is able to output the
warning message but not the correct return value.The warning message and
return value is as follows.

"Warning: Missing argument 3 for actual_function() in %s on line %d
bool(true)".

This also fails with php 5.3 and php 6.


The return value of " bool(true)" in (1) and (2) will misguide/confuse
the developers as the documentation says array_walk()and
array_walk_recursive()function calls return TRUE on Success and FALSE on
Failure.





Reproduce code:
---------------
/****  for array_walk() ****/
<?php

function actual_function($value, $key, $user_data)
{
  echo $value + $key;
}

$input = array( 0 => 1, 1 => 2, 2 => 3);

var_dump( array_walk($input, "wrong_function"));
var_dump( array_walk($input, "actual_function"));

?>

/**** for array_walk_recursive() ****/
function actual_function($value, $key, $user_data)
{
  echo $value + $key;
}

$input = array( 0 => 1, 1 => 2, 2 => 3);

var_dump( array_walk_recursive($input, "wrong_function"));
var_dump( array_walk_recursive($input, "actual_function"));

?>

Expected result:
----------------
/**** for array_walk() ****/
Warning: array_walk(): Unable to call wrong_function() - function does
not exist in %s on line %d
bool(false)

Warning: Missing argument 3 for actual_function() in %s on line %d
bool(false)


/**** for array_walk_recursive() ****/
Warning: array_walk_recursive() : Expects parameter 2 to be valid
callback, string given in %s on line %d
NULL


Warning: Missing argument 3 for actual_function() in %s on line %d
bool(false)


Actual result:
--------------
/**** for array_walk() ****/
Warning: array_walk(): Unable to call wrong_function() - function does
not exist in %s on line %d
bool(true)

Warning: Missing argument 3 for actual_function() in %s on line %d
bool(true)


/**** for array_walk_recursive() ****/
Warning: array_walk_recursive() : Expects parameter 2 to be valid
callback, string given in %s on line %d
NULL


Warning: Missing argument 3 for actual_function() in %s on line %d
bool(true)


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


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

Reply via email to