For PHP the way isn't (wasn't) very type strict, and you could implement your own handle logic, based on method return value:
$result=$myClass->save();if(is_array($result)){// Validation errors!// Warnings are returned in structured array, where indexes are class attributes// Example:// $result['firstname'] = 'First name is required'// $result['email'] = 'Email address must be valid' }elseif(is_numeric($result)){// New record created!// Method returns newly created database row ID}else{// Record updated!// Method returns TRUE}
I have to admit I've kind of converted to returning TRUE or FALSE, and implementing another method to get errors, if save failed using $errors = $myClass->getErrors(), but it was still nice shortcut, purely because PHP didn't enforce explicit return types.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For PHP the way isn't (wasn't) very type strict, and you could implement your own handle logic, based on method return value:
I have to admit I've kind of converted to returning TRUE or FALSE, and implementing another method to get errors, if save failed using
$errors = $myClass->getErrors()
, but it was still nice shortcut, purely because PHP didn't enforce explicit return types.