Hi. I'd like to propose the following ammendments to PSR-2. See here for the first part:
The changes here are:
1. A soft length limit, or a hard limit, or both MAY be required.
There is absolutely no reason why a code owner should not be able to enforce soft or hard limits.
2. A soft limit SHOULD be between 80 and 120 characters.
This fixes the completely illogical wording of the current text that implies the hard limit is 80 chars and the soft limit is 120 (that's backwards).
3. Simplify note about spaces vs tabs.
I've removed the note about spaces being better because it helps with diffs and patches. It's simply not true because if you are consistent it works fine, but the note adds no value to the specification. The micro-alignment is actually the important bit for those that want to bother.
Ok, that's that.
I also want to propose we add some very generic requirements Docblocks. I've been looking around at many code projects that are claiming to be PSR-2 compliant (and they are), but frankly there in-code documentation, in some cases, sucks! It's really not good enough.
Therefore, would it be out of order to add some minimum standards about Docblocks if there is to be an ammendment. The reason I ask is I assume that any ammendment will retire PSR-2 and change it to PSR-# (where # is the next available number)? So if there are changes, it's worth while doing something meaningful.
To that end I'd propose something like the following (in shorthand):
* Docblocks MUST be provided in the file header, for classes and their methods and their properites/constants, and for functions.
* File Docblocks MUST include @license and @copyright.
* Class Docblocks MUST include a short description/title and SHOULD include @since
* Class property/constant Docblocks MUST include @var with variable type and description
and SHOULD include @since
* Class methods and functions MUST include a short description/title,
MUST include @param where function arguments are provided,
MUST include @return
MUST include @throws if an exception is thrown in the method or function
SHOULD include @since
Might be a few things I've missed but that's the minimum we should require (I'm not pariticularly worried about formatting and alignment at this time - present is better than pretty). And that would go for any scope - public, protected or private. Anything less is just being sloppy in my opinion (and I'd add it applies to all PHP code files, including tests). I'm not sure the @package and @subpackge is absolutely necessary anymore given we are in a post-namespacing world - I'll defer to the advice of the documentation tool writers there.
If there's any interest in moving forward on this, I'll forge ahead with some actual text. If not, then let's bury this quickly.
Thanks in advance.
Regards,
Andrew Eddie