phppsr-2

How many spaces should I use for intendation according to the PSR-2 coding standard?


I was unable to find out how many spaces we have to use for intendation according to the PSR-2 standard. Can I use as many as I like?

I always use 4 spaces

public function test()
{
    //4 spaces

But I also saw code which uses more than 24 spaces. Which is the coding standard? I changed code with 24 spaces intendation to 4 spaces and then my coworker asked me why I changed it.


Solution

  • PSR-4 is an autoloading standard. It has NOTHING to do with indentation or spaces.

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

    You are thinking of PSR-2, the coding style guide.

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

    Code MUST use 4 spaces for indenting, not tabs.