Bug #67924 [Opn->Fbk]: Closure and lambda problem

From: Date: Thu, 28 Aug 2014 18:51:06 +0000
Subject: Bug #67924 [Opn->Fbk]: Closure and lambda problem
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187321@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 Updated by: requinix@php.net Reported by: tin dot legall at wishgroupe dot com Summary: Closure and lambda problem -Status: Open +Status: Feedback Type: Bug Package: Scripting Engine problem Operating System: Debian PHP Version: 5.4.4 Block user comment: N Private report: N New Comment: Works for me. http://3v4l.org/pOTkX You've tried that exact code? No modifications whatsoever? Do you have any Zend extensions installed? If so you need to try without them as they can modify PHP's behavior. Previous Comments: ------------------------------------------------------------------------ [2014-08-28 17:43:42] tin dot legall at wishgroupe dot com 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 ------------------------------------------------------------------------ [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

« previous php.bugs (#187321) next »