Doc #67822 [NEW]: Precedence of used variable names vs closure arguments should be defined
| From: | fredemmott@php.net | Date: | Mon, 11 Aug 2014 18:34:55 +0000 |
| Subject: | Doc #67822 [NEW]: Precedence of used variable names vs closure arguments should be defined | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-11425@lists.php.net to get a copy of this message | ||
From: fredemmott
Operating system: n/a
PHP version: Irrelevant
Package: PHP Language Specification
Bug Type: Documentation Problem
Bug description:Precedence of used variable names vs closure arguments should be defined
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 bug report at https://bugs.php.net/bug.php?id=67822&edit=1
--