-
Notifications
You must be signed in to change notification settings - Fork 2.5k
replacing array_key_exists with faster isset calls #6562
Conversation
should we also change has checkers with isset() || array_key_exists() ?
@pine3ree yes, it should be using |
Actually, never mind: if |
When using getter it's always preferable using isset alone, since it covers all the cases. |
Yeah, the patch is good as-is. The trailing spaces are still caught by the CS checks in the test suite though... |
oh, yeah...sorry. it always happend to me when editing directly on github (due to my obsession of having a blank line b4 return). There's still a couple of assert equal errors in tests/ZendTest/Feed/Reader/Entry/AtomTest.php:148 |
mmm shouldn't be related to form elements at all. |
@pine3ree yeah, build is ok for what is related to this PR now. No further action needed |
Actually... empty strings are valid labels in this case, and should not return null. Since |
?? empty strings array values returns TRUE
echoes bool(true) |
@weierophinney you probably misread this one :-) Re-opening |
Honestly, i still don't understand what you mean or where isset('') does apply. I just changed the getters for labelOptions and attributes arrays with a very common optimization and I am applying isset to arrays not to strings that can be empty. since i have only used isset like this: isset($arr[$key]); applying your use case that would mean $arr[$key] could be '', which returns TRUE if checked with isset. Can you give me any example of the case you had in mind? What am I missing? kindly. |
@pine3ree it was just a PEBKAC, not intentional :-) |
don't we all suffer from it? :-) |
should we also change has checkers with isset() || array_key_exists() ?