Inline constructing/cloning and inline foreach listing
| From: | Hannes Landeholm | Date: | Tue, 07 Jun 2011 13:28:49 +0000 |
| Subject: | Inline constructing/cloning and inline foreach listing | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-53137@lists.php.net to get a copy of this message | ||
Hi,
I like to do stuff "inline" instead of cluttering my code with variables.
There are currently three syntaxes/expressions which are currently not
supported but I hope could be implemented until 5.4.
First inline constructing (which I think has already previously been
discussed), but also cloning, e.g:
// Inline constructing:
$car = (new CarFactory())->makeCar();
// Inline cloning:
$tomorrow = (clone $today)->add($one_day);
I'd also like to iterate sets of arrays more "inline": (I'm not sure if this
has been discussed before)
foreach ($arrays as list($e1, $e2, $e3)) { ...
// Instead of:
foreach ($arrays as $array) {
list($e1, $e2, $e3) = $array;
Regards,
Hannes