Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does PSR-2 require vertical alignment?

Tags:

php

psr-2

What is allowed between these two:

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

or

$value     = 'value';
$user      = 'John';
$timestamp = 1480927909;
$day       = date('Y-m-d', $timestamp);
like image 684
Marko Milivojevic Avatar asked Dec 05 '16 08:12

Marko Milivojevic


1 Answers

PSR-2 does not have specific rules for this kind of inter-line alignment:

From the PSR-2 Conclusion:

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

  • Declaration of global variables and global constants
  • Declaration of functions
  • Operators and assignment
  • Inter-line alignment
  • Comments and documentation blocks
  • Class name prefixes and suffixes
  • Best practices

Future recommendations MAY revise and extend this guide to address those or other elements of style and practice.

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

The way-back original long-form PSR-1 covered inter-line alignment, globals, ternaries, assignment, and lots of other things. Those ended up getting removed for various reasons; their epitaph is at the conclusion of PSR-2.

like image 69
Kirk Beard Avatar answered Sep 22 '22 22:09

Kirk Beard