Req #54888 [Opn->Csd]: The use of "as" in closure "use"

From: Date: Sat, 05 May 2018 21:03:33 +0000
Subject: Req #54888 [Opn->Csd]: The use of "as" in closure "use"
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215099@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54888&edit=1 ID: 54888 Updated by: requinix@php.net Reported by: alex at arcomit dot co dot uk Summary: The use of "as" in closure "use" -Status: Open +Status: Closed Type: Feature/Change Request Package: *General Issues PHP Version: 5.3.6 -Assigned To: +Assigned To: requinix Block user comment: N Private report: N New Comment: As of PHP 5.4 closures inherit $this scope from where they were defined, meaning you can use $this directly without use-ing anything. https://3v4l.org/oM0Pc I anyone has other use cases, beyond just "I want a different variable name", then we can reopen. Previous Comments: ------------------------------------------------------------------------ [2011-05-20 13:47:13] alex at arcomit dot co dot uk Description: ------------ Would be handy if "as" or something similar could be used in closures to allow for easy passing of class properties. e.g. $callback = function() use ($this as $_this) { }; $callback = function() use ($this->prop1 as $prop) { }; ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=54888&edit=1

« previous php.bugs (#215099) next »