Answer the question
In order to leave comments, you need to log in
How to format this code according to PSR standards?
I try to write code following the PSR standards. I'm using PHPstorm, and it has such a great feature as code auto-formatting using standards.
Actually there are two questions:
1. Alignment of assignment expressions in code blocks.
As I write (one space before the assignment sign, and one after):
$variable = ['var1', 'var2', 'var3', 'var4'];
$variableWithALongName = array();
$variableWithAVeryLongName = array();
$variable = ['var1', 'var2', 'var3', 'var4'];
$variableWithALongName = array();
$variableWithAVeryLongName = array();
НЕДОПУСТИМО жёстко ограничивать длину строки;
мягкое ограничение ДОЛЖНО составлять 120 символов;
СЛЕДУЕТ стараться, чтобы длина строки составляла 80 символов или менее.
$array['variable'] = 'В этой строке кода меньше 120 символов, но скорее всего больше чем 80';
$array['variable']
= 'В этой строке кода меньше 120 символов, но скорее всего больше чем 80';
$array['variable']
= 'В этой строке кода меньше 120 символов, то скорее всего больше чем 80';
$variable = ['var1', 'var2', 'var3', 'var4'];
$variableWithALongName = array();
$variableWithAVeryLongName = array();
Answer the question
In order to leave comments, you need to log in
Question: how is it correct and where is it written?Both options do not violate.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question