Details
-
Type:
Coding Standards Violation
-
Status:
Resolved
-
Priority:
Trivial
-
Resolution: Not an Issue
-
Affects Version/s: 0.2.0
-
Fix Version/s: Next Minor Release
-
Component/s: None
-
Labels:None
-
Fix Version Priority:Nice to Have
Description
Ralph Schindler proposed a series of class member organizational conventions that we can adopt for improving the readability and consistency of the framework code base. I've modified them slightly for clarity and to include others' responses to the mailing list thread:
http://www.nabble.com/Class-member-orgainizational-conventions-tf2508874s16154.html#a6996153
- Properties should appear at the top of the class definition followed by methods.
- Class members (both properties and methods) should be organized by visibility: public first, protected second, and private last.
- Special methods such as __construct(), __destruct(), __clone(), __sleep(), __wakeup(), __get(), __set(), __isset(), __isset(), __unset(), __call(), __toString(), and __set_state() should appear first in the list of methods, in the order presented here, as needed by the class.
- Static methods should be listed before instance methods.
- Static methods should have the visibility written first, as illustrated in the php manual at http://php.net/manual/en/language.oop5.static.php:
public static $myStatic = 'foo'; public static function aStaticMethod() {}
- Finally, methods should be grouped logically by execution order, developer need, etc., where appropriate. For example: setOptions() appears before start(), which appears before stop(), since this is the most logical order of usage.
Issue Links
| This issue depends on: | ||||
| ZF-691 | Coding Standards Version 1.0 |
|
|
|
We currently have a rift on this issues as wether visibility comes before static or not. We should all voice our opinion on the matter, as i see this is more a matter of taste than objective fact, and based off what has been brought up, come to a decision on this.. perhaps have a hammer come down from the powers that be.. Bill? Hehe.
But seriously, lets get this decided and put into the coding standards doc.
We all want fresh and clean code