6

Naaarf

Refactoring the whole day.

Someone who prefers while(list(...) = each(...)) or for($x=0; $x < count($array); $x++) wrote the following code, too.

if ($indexed == null || $indexed == "0" && $row[$x]["indexed"] == 0 || $indexed == "1" && $row[$x]["indexed"] == 1) ....

It's buggy. Why does this not surprise me?

This stuff. Whole day.

My brain feels foggy.

Comments
  • 1
    Almost looked like something I spotted today.. but there’s no ternary operations and assignments occurring in that if . Happy to swap 😂
  • 1
    @Frederick this is what happens when php devs don’t know how php handles types. 😢
  • 1
    Lengthy Boolean logic without parenthesis makes me very confused and often angry.

    Especially in php since its evaluation order is often backwards from what I expect.
  • 0
    after converting, using an object for the options:

    if (!$option->hasIndexFilter() || $options->getIndexFilter() === (bool) $row['indexed'])

    ....
  • 0
    Bin it & rewrite it. I’d have killed that programmer just for using a while loop on an array, and I’ve seen some pretty shitty code.

    I have 2 very simple questions
    1) what’s wrong with - if (empty()) { }
    2) if they are expecting an int, what wrong with saying, i don’t know, CASTING IT TO A FUCKING INT!!!

    It’s programmers like these that make me go why?
Add Comment