On 11/08/16 13:50, Niklas Keller wrote: >> Now this is where the fundamental difference in styles comes in. >> > PERSONALLY I would not be looking to throw exceptions at all. The whole >> > point of validation is to handle any validation error ... and it is an >> > error not an exception. >> > > If not by using exceptions, how would you handle them if you assign such > checks to variables and assign a wrong value?
This is where this 'strict' over 'weak' discussion starts. I have no doubt that for some people a 'strict' switch would enable throwing exceptions every time something that failed was actioned. While I'm still in the camp where if ( !$age->set( $result_set['age'] ) ) { // handle error } else { // next step } is a lot more readable than chaining everything together and building some complex exception handler to process something which is much tidier to handle in line ... Much of the proposed style sugar only works for a completely different style of working. I have yet to be convinced that re-factoring years of code which naturally follows an in-line coding style would gain anything from being reworked to the 'exception' style, but exceptions are being added to the engine which may well be trigger by legacy styles and which therefore have to be handled to keep code moving forward. Even something as simple as reading each line of a CSV file and processing it until an error is detected - such as end-of-file - requires a different mindset if the errors throw you out of the data handling loop because of a validation error. Claiming that "You do not have to use the new style" misses the point that often one has no control on where that new style impinges on legacy code. Not least where third party code is an integral part of the infrastructure. Even where PDO chaining has been used in third party libraries, one invariably ends up pulling that apart to allow in-line responses rather than remote exception handling. PDO is an area where the correct handling of data validation would benefit from a clean built in validation process. Rather than throwing some array handling validator with an isolated set of rules at the problem post reading the data. -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php