I don't think you understand how type hinting works.



  • From our library code:

    public static function getPermissions(Company_User $user)
        {
            if (!($user instanceof Company_User)) {
    

    Note: I wrote the original implementation of getPermissions, and the redundant check was not in place. It was added later by another one of our developers, who clearly doesn't understand how type hinting works. The code afterward attempts to go out and get the currently logged in user if a valid user isn't passed to the function. I tried to explain that would never happen, but I don't think he really got the gist of what I was trying to explain.



  • You have to protect yourself from lying compilers. Defensive programming ftw.



  • @erikal said:

    You have to protect yourself from lying compilers. Defensive programming ftw.

    If I'm right and this is PHP, there is no compiler per se, because if there was and it was any good, it would have told SituationSoap's colleague that what he's doing is retarded.

    Although, given said colleague's competence, I doubt he would've even understood the compiler warning.



  • @The_Assimilator said:

    I doubt he would've even understood the compiler warning.

    "I know what this message means!  It's trying to tell me I forgot to turn warnings off."

     



  •  And this, folks, is what happens when people learn to "program" by bashing away in a language with a poor implementation of dynamic typing. They end up literally incapable of comprehending types and type-checking.

    What Dijkstra said about BASIC was slightly unfair.  BASIC at least had some concept of types.  It does, however, apply perfectly to PHP, and for that reason I will never employ a programmer whose only experience is with PHP, even if the job only involves writing PHP.



  • @DCRoss said:

    @The_Assimilator said:
    I doubt he would've even understood the compiler warning.
    "I know what this message means!  It's trying to tell me I forgot to turn warnings off."
    I wanted to get something done today.  Now I'm gonna spend all day cleaning tea off my monitor.

     



  • I would ask him to show you how he tested that code path.

     


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.