Bug #67924 [Fbk->Opn]: Closure and lambda problem
| From: | tin dot legall at wishgroupe dot com | Date: | Thu, 28 Aug 2014 17:43:43 +0000 |
| Subject: | Bug #67924 [Fbk->Opn]: Closure and lambda problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187320@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67924&edit=1
ID: 67924
User updated by: tin dot legall at wishgroupe dot com
Reported by: tin dot legall at wishgroupe dot com
Summary: Closure and lambda problem
-Status: Feedback
+Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: Debian
-PHP Version: 5.4.32
+PHP Version: 5.4.4
Block user comment: N
Private report: N
New Comment:
Here is the code example that illustrates the problem:
<?php
// This is our range of numbers
$numbers = range(1, 5);
// Our closure
$double = function($a) {
return $a * 2;
};
// Use the closure as a callback here to
// double the size of each element in our
// range
$new_numbers = array_map($double, $numbers);
print implode(' ', $new_numbers);
?>
Expected result:
----------------
2 4 6 8 10
Actual result:
--------------
1 2 3 4 5
Previous Comments:
------------------------------------------------------------------------
[2014-08-28 16:11:23] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
Not a description of what you did but the actual code. Because what it sounds like you're
describing creates something totally incorrect and will spew warnings.
------------------------------------------------------------------------
[2014-08-28 13:05:18] tin dot legall at wishgroupe dot com
Description:
------------
Take example #2 at the following address and switch $double and $number declarations
http://php.net/manual/en/language.types.callable.php
Expected result:
----------------
2 4 6 8 10
Actual result:
--------------
1 2 3 4 5
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67924&edit=1