Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Volker Dusch:
Errors will be fixed. Warnings will be 'looked at'
Oct 04, 2012 @ 13:25:43

In a new post to his site Volker Dusch shares his thoughts about warnings in coding style checks (and how they differ from real errors).

When it comes to coding standards there is one rule that always makes me cringe when I stumble upon it: "Lines SHOULD be less than 120 chars long. If not a warning will be issued." Let me try to make a point why I consider WARNINGS in coding guideline checks hurtful.

He defines a warning first, so there's no confusion (something that should be done, but doesn't have to) and why he thinks there's not much of a place for them in the code guidelines. He suggests that, by having them, they take away time from the real issues, the errors. He notes that "should" rules on formatting shouldn't be added to your QA tools right away. Adding too many of these that spit out too many warnings (not errors) could just muddy the waters and make the developers more confused.

tagged: errors warnings qa code style guidelines opinion

Link:

Alexander Netkachev's Blog:
PHP coding tip: Convert notices and warnings into Exceptions
Oct 18, 2006 @ 12:19:54

Exceptions and warnings can be tossed out from your code at some odd locations sometimes. There's a few options that you have when they jump out, including pushing them out to an error log or just ignoring them completely. Alexander Netkachev has a different solutions, though - handling them with something already built into PHP, using exception reporting.

This coding tip demonstrates how to deal with PHP core notices and warning (aka recoverable errors) in the exception way, using try/catch statement.

IT's a simple idea, but it can definitely help you keep all of you errors in one place. The sample code he gives shows both a basic idea of the solution and a bit more complex example, providing more detailed messages for different exception types.

tagged: warnings notices exceptions convert handling try catch warnings notices exceptions convert handling try catch

Link:

Alexander Netkachev's Blog:
PHP coding tip: Convert notices and warnings into Exceptions
Oct 18, 2006 @ 12:19:54

Exceptions and warnings can be tossed out from your code at some odd locations sometimes. There's a few options that you have when they jump out, including pushing them out to an error log or just ignoring them completely. Alexander Netkachev has a different solutions, though - handling them with something already built into PHP, using exception reporting.

This coding tip demonstrates how to deal with PHP core notices and warning (aka recoverable errors) in the exception way, using try/catch statement.

IT's a simple idea, but it can definitely help you keep all of you errors in one place. The sample code he gives shows both a basic idea of the solution and a bit more complex example, providing more detailed messages for different exception types.

tagged: warnings notices exceptions convert handling try catch warnings notices exceptions convert handling try catch

Link:


Trending Topics: