Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
287 views
in Technique[技术] by (71.8m points)

php - What is a line length "soft limit" and how do I interpret this in the PSR-2 convention?

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.

question from:https://stackoverflow.com/questions/14962667/what-is-a-line-length-soft-limit-and-how-do-i-interpret-this-in-the-psr-2-conv

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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/...

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...