php.net |  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.
Password:
Status:
Package:
Bug Type:
Summary:
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
Description:
------------
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:
---------------
<?php

// 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.
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-26 22:26 UTC] aharvey@php.net
See also: https://wiki.php.net/rfc/useas and http://marc.info/?l=php-internals&m=134262361326161&w=4

This would need to go through the RFC process as well (nowadays, also with an appropriate spec PR).
 [2017-08-04 23:21 UTC] stas@php.net
-Status: Open +Status: Suspended
 [2017-08-04 23:21 UTC] stas@php.net
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 (internals@lists.php.net) as an RFC. Please read the guide about creating RFCs here:
https://wiki.php.net/rfc/howto
If you haven't had experience with writing RFCs before, it is advised to seek guidance on the Internals list (http://php.net/mailing-lists.php) 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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 14:01:30 2024 UTC