Does the PSR-2 require vertical alignment?

What is allowed between the two:

$value = 'value'; $user = 'John'; $timestamp = 1480927909; $day = date('Ym-d', $timestamp); 

or

 $value = 'value'; $user = 'John'; $timestamp = 1480927909; $day = date('Ym-d', $timestamp); 
+6
source share
1 answer

PSR-2 does not have specific rules for such line-to-line alignment:

From the Conclusion of PSR-2 :

There are many elements of style and practice deliberately omitted by this guide . These include, but are not limited to:

  • Declaring global variables and global constants
  • Function Declaration
  • Operators and Purpose
  • Line spacing
  • Comments and documentation blocks
  • Class Name Prefixes and Suffixes
  • Best practics

Future recommendations MAY revise and disseminate this manual to address certain elements of style and practice.

For what it's worth, line-to-line alignment was discussed for PSR-1 by the PHP-FIG group, but was removed from the final version:

The long, reverse form PSR-1 covers line spacing , globals, tees, assignments, and more. As a result, they were deleted for various reasons; their epitaph is at the end of PSR-2.

+7
source

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


All Articles