HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
GetValue or val?
Bleistivt
Moderator
Which function should I use to get a value from a collection or array?
I see both val and GetValue (and their recursive counterparts) being used.
https://github.com/vanilla/vanilla/blob/master/library/core/functions.compatibility.php
^ This tells me GetValue will be deprecated at some point, or is it the other way around?
Also, kind of unrelated, since Vanilla 2.3 will require php5.4, are there plans switch to the nicer array() syntax []?
There are tools to perform this conversion automatically.
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
0
Comments
This is really down to the new naming convention. Functionally they are same.
Personally I don't endorse Depreciating it for a long time.
Over use of either can be a problem, becuase of the efficiency of array_key_exists/property_exists may pose scalability issues.
I have thought of testing alternative algorithms to make it more inefficient at scale, testing all hypothetical.
grep is your friend.
There is nothing stopping you from using it. I really don't see the point in trawling through code changing it for no reason. Also it is subjective whether it is nicer.
grep is your friend.
http://vanillaforums.org/discussion/comment/205106/#Comment_205106
Having a default fallback if the value is not set is very convenient, though.
Maybe a simpler function that just tests for isset() could be introduced, that can be used when you know you're only dealing with arrays.
My themes: pure | minusbaseline - My plugins: CSSedit | HTMLedit | InfiniteScroll | BirthdayModule | [all] - PM me about customizations
VanillaSkins.com - Plugins, Themes and Graphics for Vanillaforums OS
We have moved to
val()
. We're no longer accepting new code usingGetValue()
. They are functionally equivalent, butval()
is better optimized in addition to matching the new naming standard.@Linc It looks through testing that the unnecessary
&$Collection
in GetValue almost doubles execution time. This was purely for the$Remove
param.Definitely depreciating
$Remove
is a good idea. It is poor fit for this function anyway. I have not seen anyone use it.grep is your friend.