Zizaco / confide

Confide is a authentication solution for Laravel 4
1.19k stars 258 forks source link

Error coding #485

Closed khooz closed 9 years ago

khooz commented 9 years ago

Hi! Sorry to bother you again.

This, too, is not an actual bug, but rather a suggestion: This may be because of me migrated from C/C++ to PHP but, it is good practice that instead of returning false or true, returning an integer (mostly defined as a constant) as the result of a function, mostly 0 for success and not zero as the error code. Then, checking the function is simply

if ($err = myfunc())
{
   switch($err)
   {
      case ERR_CASE_ONE:
      {
         // approperiate action for case one
         break;
      }
      ...
      default:
      {
         // approperiate action for unknown error
         break;
      }
   }
}

And mostly these errors can be masked. For instance you can mask them with PHP's default error level masks like E_ALL and E_WARNING etc. to form a robust error reporting.

Zizaco commented 9 years ago

Nice. I would accept a pull request regarding this subject.