fetchQueryCallback() gives an error in my IDE because the if($callback === null) part isn't seen. It doesn't make sense to allow the callback to be null. I think the best way to do it would be to change it to
public function fetchQueryCallback($db_string, Callable $callback, array $db_values = array(), array $seeds = array())
Before I go committing that change, I wanted to know what you guys think.
I guess the null would indeed be meaningless.
Does your IDE point to any specific place where the function is called with a null argument? (Just to be sure there isn't any edge-case I forgot about).
You have the same one lazy O:-)
Yeah, but I have it on the other computer that I do not switch on very often... O:-)
I'm a bit dumb at times, I didn't get the message right, now I do.
Yep, I added the null default more or less to mimic the jQuery behaviour: if there is a callback call it, otherwise just do what you are supposed to do with it. The cheap polimorphism you can achieve with PHP.
ETA: a potential case (as of now, not existing):
if (condition) {
$query = 'SELECT * FROM something LEFT JOIN somethingelse';
$callback = function ($vals) {...};
}
else {
$query = 'SELECT * FROM something';
$callback = null;
}
$results = $db->fetchQueryCallback($query, $values, $callback);
Is the explanation acceptable, or it is better not to have such cases?
Why use a method that does a callback if there is no callback? Just call fetchQuery() and if you want to use a callback, call fetchQueryCallback(), or just have fetchQuery($query, array $values, $callback = null). I don't have Elkarte open and I don't have much time (working on learning how to add modules for PuPHPet) and then a wedding later.