Doc #67822 [Opn->Fbk]: Precedence of used variable names vs closure arguments should be defined

From: Date: Sun, 28 Jun 2015 22:36:03 +0000
Subject: Doc #67822 [Opn->Fbk]: Precedence of used variable names vs closure arguments should be defined
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-12486@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67822&edit=1 ID: 67822 Updated by: stas@php.net Reported by: fredemmott@php.net Summary: Precedence of used variable names vs closure arguments should be defined -Status: Open +Status: Feedback Type: Documentation Problem Package: PHP Language Specification Operating System: n/a -PHP Version: Irrelevant +PHP Version: PHP-5.6 Block user comment: N Private report: N New Comment: Not sure it is really necessary to specify, this doesn't seem to be an important use case. Is there any reason why it should be one way or another? Previous Comments: ------------------------------------------------------------------------ [2014-08-11 18:34:55] fredemmott@php.net Description: ------------ If a closure has an argument and a used variable with the same name, PHP5 uses the variable; HHVM uses the argument. The PHP5 behavior should be documented in the specification. There's also an issue filed against HHVM to match PHP5's behavior (https://github.com/facebook/hhvm/issues/3406) Test script: --------------- <?php $foo = 'used variable'; $closure = function ($foo) use ($foo) { return $foo; }; var_dump($closure('argument')); Expected result: ---------------- 'used variable' Actual result: -------------- PHP5: 'used variable' HHVM: 'argument' ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=67822&edit=1

« previous php.doc.bugs (#12486) next »