I have a function that accepts a checkGlossary bool param as well as an optional glossary array.
Their states are directly tied together.
The glossary is never required if the bool is FALSE, and inversely, it is always required if the bool is TRUE.
To me, it seems like this could easily be simplified from:
// Current
function doSomething($param1, $param2, $checkGlossary=FALSE, $glossary=NULL){
// blah blah blah
if($checkGlossary)
array_search($glossary[$param2]);
// etc etc etc
}
... to:
// Proposed
function doSomething($param1, $param2, $glossary=FALSE){
// blah blah blah
if($glossary)
array_search($glossary[$param2]);
// etc etc etc
}
My only hesitation is over the fact that the type for $glossary (bool or array) would be unpredictable.
It doesn't bother me as long as I'm not going against some Best-Practices guidelines.
Thoughts?
checkGlossaryflag and use only theglossaryvariable. Setarray()as default value and ommit the check if the array is empty.array()as the default value). If you put that in an answer, I'll select it.