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

前端 未结 5 564
死守一世寂寞
死守一世寂寞 2021-02-03 18:29

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

5条回答
  •  忘了有多久
    2021-02-03 18:57

    The key to understand all FIG standards is to properly interprate key words used in RFCs.

    There MUST NOT be a hard limit on line length.

    Although no one will put a gun to your head…

    The soft limit on line length MUST be 120 characters.

    … it would be better not exceed the length of 120 characters…

    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.

    … but, as a recommendation, try to split lines longer than 80 characters.


    It all comes down to readability. Legibility research specific to digital text has shown that, like with printed text, line length can affect reading speed (saccade). Also, it turns out that the subconscious mind is energized when jumping to the next line (as long as it doesn't happen too frequently). At the beginning of every new line the reader is focused, but this focus gradually wears off over the duration of the line ("Typographie", E. Ruder).

提交回复
热议问题