Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
if($error === null){}
preferred (sometimes mandatory by standards), because the option if(!$error){}
is auto-cast to bool:
!$any
can be used comfortably when you (and the program) are sure that you are working with either an object or a bool
If possible, change the type of the return value, i.e. Call the special class Error and check the type of the result after the call.
There is also the practice of removing the error status from the returned value, since errors are different and require different responses, using exceptions - descendant classes of Exception
In this case, each error variant must be caught in its catch section and the call in try (initialize the error itself with using throw).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question