php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #67822 Precedence of used variable names vs closure arguments should be defined
Submitted: 2014-08-11 18:34 UTC Modified: 2015-07-12 04:22 UTC
From: fredemmott@php.net Assigned:
Status: No Feedback Package: PHP Language Specification
PHP Version: PHP-5.6 OS: n/a
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-08-11 18:34 UTC] 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'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-28 22:36 UTC] stas@php.net
-Status: Open +Status: Feedback -PHP Version: Irrelevant +PHP Version: PHP-5.6
 [2015-06-28 22:36 UTC] stas@php.net
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?
 [2015-07-12 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC