pear:rfc:pear2_class_naming
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
pear:rfc:pear2_class_naming [2009/01/07 03:57] – add IDE autocompletion reason for Abstract suffix rather than prefix ashnazg | pear:rfc:pear2_class_naming [2009/09/20 19:00] – highlight reference #3 ashnazg | ||
---|---|---|---|
Line 3: | Line 3: | ||
==== Document Information ==== | ==== Document Information ==== | ||
* Title: PEAR2 Class Naming Conventions | * Title: PEAR2 Class Naming Conventions | ||
- | * Version: 0.1.0 | + | * Version: 0.2.0 |
- | * Status: | + | * Status: |
* Type: Informative Document | * Type: Informative Document | ||
* Wiki link: http:// | * Wiki link: http:// | ||
+ | * Last Updated: | ||
+ | * Passed: | ||
==== Author(s) Information ==== | ==== Author(s) Information ==== | ||
* Name: Chuck Burgess | * Name: Chuck Burgess | ||
- | * Name: | + | * Name: |
* Email: [[pear-group@php.net]] | * Email: [[pear-group@php.net]] | ||
Line 17: | Line 19: | ||
==== Discussion List ==== | ==== Discussion List ==== | ||
- | * Currently | + | This RFC is currently being discussed |
+ | |||
+ | This RFC's content is also being influenced by the new PHP Standards group [[http:// | ||
===== Introduction ===== | ===== Introduction ===== | ||
Line 23: | Line 27: | ||
With the introduction of namespaces in PHP 5.3, the PEAR1 rule of Package_Subpackage_ClassName naming (for creating pseudo-namespacing) is no longer necessary. | With the introduction of namespaces in PHP 5.3, the PEAR1 rule of Package_Subpackage_ClassName naming (for creating pseudo-namespacing) is no longer necessary. | ||
- | The naming of individual classes retains these PEAR1 rules: | + | The naming of individual classes retains these PEAR1 rules [1]: |
* Start with capital letter, e.g. class Foo {} | * Start with capital letter, e.g. class Foo {} | ||
* CamelCase for multi-worded class names, e.g. class FooBarBaz {} | * CamelCase for multi-worded class names, e.g. class FooBarBaz {} | ||
Line 30: | Line 34: | ||
New guidelines for PEAR2: | New guidelines for PEAR2: | ||
- | * syntax/ | + | * syntax/ |
- | * such suffixing is not preferred, but neither is it outlawed | + | * such suffixing is required for abstract classes and interfaces, for additional clarity to non-native English readers [3] |
===== Issues ===== | ===== Issues ===== | ||
- | * there has been some discussion/ | + | A debate was originally spurred by the use of actual classes whose names, once namespaces removes their Several_Prefix_Layers_ from the name, will be just " |
===== Proposed Solution ===== | ===== Proposed Solution ===== | ||
+ | |||
Initial rules and guidelines: | Initial rules and guidelines: | ||
- | * no suffix for an Abstract or Interface class name is necessary, nor is it preferred | + | * a suffix for an Abstract or Interface class name is required |
- | * attempts to misuse abstract classes and interfaces in userspace code will be caught by PHP anyway | + | * the extra naming is more legible |
- | * any extra naming is effectively just for code readers | + | * the suffix |
- | * any extra naming | + | |
* this follows other well-known conventions (e.g. Java) | * this follows other well-known conventions (e.g. Java) | ||
- | * an " | ||
- | * having it suffixed makes it work better with IDE's autocompletion... otherwise, you'll always find yourself typing the full " | ||
- | * an " | ||
- | ===== References ===== | + | The only exception to the Interface suffix requirement is the base package exception, which must be named simply " |
- | * PEAR1 Coding Standards for Class Naming -- [[http:// | + | |
- | * [[Weierophinney]]' | + | |
+ | One benefit of the suffix rather than a prefix is in alphabetical-based visual listing of classes. | ||
+ | |||
+ | ===== Examples ===== | ||
+ | Here are some real-life examples gleaned from PEAR1 packages | ||
+ | |||
+ | * Demonstrating the inherited PEAR1 naming rules | ||
+ | * "class Text_Diff" | ||
+ | * "class DB_DataObject" | ||
+ | * "class Auth_PrefManager" | ||
+ | * "class Services_Amazon_SQS" | ||
+ | |||
+ | * Demonstrating the new rules proposed by this RFC | ||
+ | * " | ||
+ | * " | ||
+ | |||
+ | ===== References ===== | ||
+ | * [1] PEAR1 Coding Standards for Class Naming -- [[http:// | ||
+ | * [2] [[weierophinney]]' | ||
+ | * [3] PHP Standards Group' | ||
+ | * [4] [[weierophinney]]' |
pear/rfc/pear2_class_naming.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1