PHP PSR-2 new lines before / after entries

Example No. 1:

$something = [1,2,3,4]
foreach ($something as $key => $value) {
    //code code code
}
$something2 = [];

I can’t find a clear answer about the new living before and after foreach, what does PSR-2 say about this?

+4
source share
1 answer

Point 2.3 "Lines" Make it optional to add blank lines before and after statements. It is still useful to separate code blocks in “paragraphs” to improve logical understanding and readability.

Blank lines MAY be added to improve readability and indicate appropriate blocks of code.

+3
source

Source: https://habr.com/ru/post/1609756/


All Articles