Bug #73844 [NEW]: Cannot use lexical variable $variable as a parameter name inside array_walk()

From: Date: Fri, 30 Dec 2016 17:12:16 +0000
Subject: Bug #73844 [NEW]: Cannot use lexical variable $variable as a parameter name inside array_walk()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-206246@lists.php.net to get a copy of this message
From: pagescene at gmail dot com Operating system: Linux PHP version: 7.1.0 Package: Arrays related Bug Type: Bug Bug description:Cannot use lexical variable $variable as a parameter name inside array_walk() Description: ------------ The following code works fine under earlier PHP versions including PHP 7.0.x, however it results in fatal error "Cannot use lexical variable $variable as a parameter name inside array_walk()" under PHP 7.1 Test script: --------------- $value = 'b'; $checkbox_values = ['a' => 'Aaa', 'b' => 'Bbb', 'c' => 'Ccc']; array_walk($checkbox_values, function(&$value, $key) use($value) { $value = (int)(strval($key) === $value); }); print_r($checkbox_values); Expected result: ---------------- Array ( [a] => 0 [b] => 1 [c] => 0 ) Actual result: -------------- Fatal error: Cannot use lexical variable $value as a parameter name in / on line 4 -- Edit bug report at https://bugs.php.net/bug.php?id=73844&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73844&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73844&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73844&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73844&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73844&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73844&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73844&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73844&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73844&r=support Expected behavior: https://bugs.php.net/fix.php?id=73844&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73844&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73844&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73844&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73844&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73844&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73844&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73844&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73844&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73844&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73844&r=mysqlcfg

« previous php.bugs (#206246) next »