I think that there is an error in this line. What do you mean by the $treatEmptyAsFalse parameter? The function empty will not pass any empty value. Not 0, not empty string, not false, not null etc... If it comes to that, I would rewrite this line like this: if (!is_null($value)) {. But now it definitely works wrong!