Lester Caine wrote on 18/01/2016 12:35:
As someone still using 'extract' in legacy code, I can sort of see the
logistics of this, but why not just extend 'extract' to use the current
object rather than the symbol table. It already has handling for
duplicate keys and to prefix the 'array' name to the resulting variables.

The main advantage I can see is that this is a whitelist-based approach - you state explicitly in your code what you expect the array to look like, and what variables you are assigning based on it. This is very different from "whatever's in this array, turn it into a variable".

The "current object" was just one possible use case, have a look at some of the other examples in the RFC, such as:

list(
    CURLOPT_GET => $isGet,
    CURLOPT_POST => $isPost,
    CURLOPT_URL => $url
) = $curlOptions;

Note that $curlOptions probably had other things in it, $url may be an existing variable getting a new value. The best extract would give you is $curloption_10002, which isn't all that useful.

Regards,
--
Rowan Collins
[IMSoP]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to