1. 12
  1.  

  2. 6

    (Spoilers for the puzzle.)

    Like the presenter, I also got my professional start in PHP, so I was curious to see if I recognized the bug. I didn’t, but as I watched his explanation I realized this video is all about type errors (even his false start with != vs. !== is looking for one). The solution ends up being a chain of three type errors in one function: hash_hmac accepting an array in place of a string, plus returning null instead of a string, plus accepting a null instead of a string. Then he mentions a potential bug with swapping two string arguments that could be caught cheaply with newtypes. I guess that’s why so many dynamic languages have been sprouting type systems in the last decade (Hack, Flow, Typescript, Sorbet, etc.)

    1. 2

      I also got my professional start in PHP, so I was curious to see if I recognized the bug. I didn’t

      Same here. My first intuition was along the lines of his. The type juggling.

      Good video.

      1. 2

        I was a bit disappointed that the solution depended on knowing how PHP works. I was hoping for a more abstract puzzle where the programming language was incidental, but that’s just how it is, can’t ignore the language.

      2. 3