It depends on what code you produce. If this is really production code, you should make sure that your function works properly under any circumstances. This includes verifying that the parameters contain the data that you are expecting. Otherwise, throw an exception or perform another form of error handling (that your example is completely missing).
If this is not for use in production, and you do not need to protect the code, you can ignore everything and follow the principle of "garbage in garbage" (or the three principles of crap: bone crap, process crap, get crap).
In the end, it all depends on meeting expectations: if you do not need your function to work correctly, you do not need to code it correctly. If you really rely on the fact that your code works exactly, you even need to check the input data for each block (function, class).
hakre
source share