Thursday, 2 January 2014

Where true or false is not enough!

At some point we've found the following code candy in our source code:

function str2bool($str) {
    if ($str === false or $str === "0" or $str === 0 or $str === "" or $str === "false" or $str === "FALSE" or $str === "falsch" or $str === "FALSCH") {
        return false;
    return true;

This piece of code is unused and someone forgot about to delete it. But it looks like it was used in one of our externally connected subsystems to translate values like FALSCH, falsch, FALSE to a boolean false. ("falsch" is german for "false")

We're not sure if there were ever values like "FALSCH" in our code - but it's a little bit scary for us ;)

No comments:

Post a Comment