1

Is it allowed to assign multiple variables on the same line in PSR-12?

For example:

$count = $score = 0;
Ernesto Allely
  • 851
  • 10
  • 16
  • As a personal opinion, it can actually make it easy to miss that the subsequent variables are declared. There is no reason you can't use it and it comes down to style. – Nigel Ren Sep 11 '20 at 10:20

1 Answers1

2

Yes. If it's not explicitly stated, then there is no standard. Either works.

Also, chain assignment like that just makes the code cleaner so I personally would not see a reason to why it should not be allowed.

https://www.php-fig.org/psr/psr-12/

PatricNox
  • 3,306
  • 1
  • 17
  • 25