Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP PSR-2 new lines before/ after statments

Example no 1:

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

I can't find clear answer about new live before and after foreach, what PSR-2 say about that ?

like image 901
Wizard Avatar asked Oct 01 '15 07:10

Wizard


People also ask

Is PSR 2 deprecated?

Deprecated - As of 2019-08-10 PSR-2 has been marked as deprecated.

What is psr12?

PSR-12 seeks to provide a set way that both coding style tools can implement, projects can declare adherence to and developers can easily relate on between different projects for these coding style reducing cognitive friction.

What are PSRS in PHP?

The PHP Standard Recommendation (PSR) is a PHP specification published by the PHP Framework Interoperability Group (PHP-FIG). It serves the standardization of programming concepts in PHP. The aim is to enable interoperability of components.

What is PSR return?

Also known as “Critical Point” and “Point of No Return”, these two formulas should be considered when planning a flight and can help making decisions in an emergency. PSR is the point furthest from the airfield of departure that an aircraft can fly and still return to base within its safe endurance. (


1 Answers

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 logic comprehension and readability.

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

like image 134
JF Dion Avatar answered Oct 23 '22 10:10

JF Dion