Why does the PSR2 standard require us to use 4 (four) spaces instead of tab?

5

According to one of the items specified by the standard PSR2 (to which most of the PHP libraries), we have:

  • Codes MUST use 4 indentation spaces, not tabs.

I know the pattern exists, but I wonder if there is any special reason.

What is the problem of using tabs in a PHP code?

Overall (even if it's not PHP), using tabs instead of spaces can be a problem?

    
asked by anonymous 01.02.2016 / 18:41

1 answer

3

There was a vote and they decided that it would be spaces. Quoting specification:

  

Using only spaces, and not mixing spaces with tabs, helps to avoid problems with diffs, patches, history, and annotations. The use of spaces also makes it easy to insert fine-grained sub-indentation for inter-line alignment. '

Translation / summary: the default is spaces and following the standard makes life easier, the use of spaces also allows slightly greater control over levels of under-indentation.

More than just flame war.

    
01.02.2016 / 18:51