|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #68510 Support aliasing with the use operator
Submitted: 2014-11-26 22:16 UTC Modified: 2017-08-04 23:21 UTC
From: eric dot lewis at nytimes dot com Assigned:
Status: Suspended Package: *General Issues
PHP Version: 5.6.3 OS: CentOS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: eric dot lewis at nytimes dot com
New email:
PHP Version: OS:


 [2014-11-26 22:16 UTC] eric dot lewis at nytimes dot com
I'd like the ability to alias any variable when applied with the use operator. 

Currently, you must alias objects or array elements before the use operator, and pass the aliased value to the use operator. This could be simplified.

Test script:

// Currently in PHP, you must alias before invoking the use operator.
$sword = new stdClass();
$sword->length = 3;
$length = $sword_length;
function() use ($length) {
 // .. do something productive with $length.

// Using the as operator here seems more intuitive to the language's existing syntax.
$sword = new stdClass();
$sword->length = 3;
function() use ($sword->length as $length) {
 // .. do something productive with $length.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-26 22:26 UTC]
See also: and

This would need to go through the RFC process as well (nowadays, also with an appropriate spec PR).
 [2017-08-04 23:21 UTC]
-Status: Open +Status: Suspended
 [2017-08-04 23:21 UTC]
Thank you for your interest in PHP and for submitting a feature request. Please be aware that due to the magnitude of change this request requires, it would be necessary to discuss it on PHP Internals list ( as an RFC. Please read the guide about creating RFCs here:
If you haven't had experience with writing RFCs before, it is advised to seek guidance on the Internals list ( and/or solicit help from one of the experienced developers. 

Please to not consider this comment as a negative view on the merits of your proposal - every proposal which requires changes of certain magnitude, even the very successful and widely supported ones, must be done through the RFC process. This helps make the process predictable, transparent and accessible to all developers.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Nov 24 14:01:23 2020 UTC