Re:Every C99.php shell is backdoored
by thefreeman on Tuesday June 24, 2014 @10:28AM
(#7937917)
I think it is a useful construct for specifically the scenario it is mis-used in here. Overriding default values, or a kwargs polyfill
this is unwieldy and difficult to reason about when you see it used, especially if you are trying to use some of the initial default values. ie.
vs.
With this, you can just do
obviously its a preference thing, but I think it is a somewhat harmless use case. If there are any params which you do not want to be overriden you move them beneath the call to extract.
[ Parent
| on HN ]
We typically handle that by having a $defaults array, then array_merge($defaults, $options) in the function.
Re:Every C99.php shell is backdoored
by thefreeman on Tuesday June 24, 2014 @11:50AM
(#7938405)
Yep, totally valid, and like I said basically a preference thing.
I personally like to work with explicit variables within the function rather then array indices. With your system I could easily call extract on your resulting array, but I also like defining the variables I want overridden explicitly in code so I my IDE doesn't think they are undefined (though JetBrains does a pretty good job of determining which variables are being created by extract in most scenarios anyway).