Task #2536
Additions to coding guidelines
Status: | Resolved | Start date: | 2009-01-30 | |
---|---|---|---|---|
Priority: | Must have | Due date: | ||
Assigned To: | - | % Done: | 100% |
|
Category: | - Documentation - | |||
Target version: | TYPO3 Flow Base Distribution - 1.0 alpha 1 | |||
Sprint: | Has patch: | |||
PHP Version: | Complexity: |
Description
Add (and explain) the following rules to the CGLs:
1. Prefer strict comparisons whenever possible. Examples:
if ($template) // BAD if (isset($template)) // GOOD if ($template !== NULL)) // GOOD if ($template !== '')) // GOOD if (strlen($template) > 0) // BAD! strlen("-1") is greater than 0 if (is_string($template) && strlen($template) >0) // BETTER if ($foo == $bar) // BAD, avoid truthy comparisons if ($foo != $bar) // BAD, avoid falsy comparisons if ($foo === $bar)) // GOOD if ($foo !== $bar)) // GOOD
2. Order of methods:
1. constructor
2. injection methods
3. initialization methods (including initializeObject())
4. public methods
5. protected methods
6. private methods
7. shutdown method(s)
8. destructor
3. Avoid double-negation:
Instead of exportSystemView(..., $noRecurse)
use exportSystemView(..., $recurse)
. It is more logical to pass TRUE if you want recursion instead of having to pass FALSE. In general, parameters negating things are a bad idea.
Associated revisions
FLOW3:
- some updates to the coding guidelines, fixes #2536
History
#1 Updated by Karsten Dambekalns over 6 years ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
Applied in changeset r2030.