I don’t understand this part of php’s PSR-2 convention:
The soft limit on line length MUST be 120 characters; automated style checkers MUST warn but MUST NOT error at the soft limit.
Lines SHOULD NOT be longer than 80 characters; lines longer than that SHOULD be split into multiple subsequent lines of no more than 80 characters each.
I thought “soft limit” meant “try to stick to this limit, but a few characters extra are not a problem”. But then I read the second line and now I don’t get it.
It’s pretty easy:
- 0-80: Always ok
- 80-120: Acceptable (if there’s a good reason for it, e.g. a string where wrapping it would be ugly)
- 120+: Lint tools, IDEs, etc. MUST show a warning (but never an error!) since the line might be ugly/unreadable/…
There is no hard limit in PSR-2.
The MUST (NOT) refers to automated style checkers, not to you as a programmer.
Also note the section that says that
no error should be issued when exceeding the soft limit.