What does this function test?

A function wrote by a co-worker:

1
2
3
4
5
6
7
8
9
10
11
function test($what, $where) {
    if (!empty($where)) {
        if (!empty($where[$what])) {
            return $where[$what];
        } else {
            return '';
        }
    } else {
        return '';
    }
}

When I had a look at this function I immediatlly tought: Test? What does it test? Thankfully there’s the $what argument! And look! A $where argument too!

WTF? Folks, name your functions and variables properly.

Post a Comment

Your email is never shared.