I decided here to completely switch to the code design style according to the PSR-2 standard. But being an adversary of indents with spaces (I believe that
SmartTabs is the most correct option), I decided to study the question: what is written in the standard and why it is so. They drove.
What does the standard say
Let's look at the standard text and see what is written there:
1. Overview
Code MUST use 4 spaces for indenting, not tabs.
In the short help they write that the code MUST use 4 spaces, but not tabs. Okay, let's say, read on about this item in more detail.
2.4. Indenting
MUST NOT use tabs for indenting.
Again repeat the brief help, that you can not use tabs, but you must use 4 spaces. And then the most interesting read a footnote to this item.
Nb: Using tabs, it helps to avoid problems with patterns, history, and annotations. It makes it easy to insert a sub-indentation for inter-line alignment.
We use Google translator:
“Nb: Using only spaces, rather than mixing spaces with tabs, helps to avoid problems with change files, fixes, history and annotations. The use of spaces also makes it easy to insert a fine-grained sub-indent to align between the lines. ”The sub-indent is clear, quite an interesting feature, but I have never used it, I use it like this:
')

But this is exactly what SmartTabs theory implies when tabs are used to indent from the beginning of a line, and spaces are just for such clever maneuvers (and when changing the size of a tab, the main code will change and the code with spaces will always be readable regardless of the size of the tab) .
But the spaces, as written in the standard, are used so that there are no problems when working with version control systems. That's what I want to figure out and check whether this is so.
We put experiment number 1
1. Create two files, in one there will be a code with spaces in the other, exactly the same code, but already with tabs.
2. Make copies of these files and make changes to them.
3. Now let's look with the help of the program WinMerge
Tabs
Spaces
4. Send these files to GIT
5. We'll see with the help of the program SourceTree
Tabs
Spaces
6. Let's look at the Bitbucket site

7. As we can see with the usual, non-repeating code, there are no problems, it doesn’t matter that spaces or tabs are used.
We set up experiment number 2
1. And now we set up an experiment, the bugs of which I myself have repeatedly noticed using tabs. It is very interesting to see, suddenly and really spaces solve this problem.
2. Create two files that will have repeated pieces of code after the changes. And also make copies of these files and make changes to them.
3. Now let's look with the help of the program WinMerge
Tabs
Spaces
4. Send these files to GIT
5. We'll see with the help of SourceTree
Tabs
Spaces
6. Let's look at the Bitbucket site

7. Suddenly, with tabs that with spaces, the problem is visible to the naked eye and none of the programs could correctly understand where the changes occurred. Then what is the standard for saying that spaces make it possible to solve a problem: it helps to avoid problems with diffs, patches, history, and annotations.
As a conclusion
So it may be worth spitting on this item of the standard and using SmartTabs, because the advantages of using tabs at the beginning of a line are indisputable. You can set up tabs as you like, if you want as two spaces, you want as 4, and you want as 8 or even 3. At the same time, if everything is used correctly, the code will never go anywhere.
UPDATE1After reading the comments, I completely changed my opinion about the spaces, after conducting this study I wanted to understand the advantages of 4 spaces before the tabs, especially then it seemed to me that there are much more advantages to the tabs. But now tabs no longer seem as good as they used to be. Yes, it is necessary to do as in the standard, especially since the majority does so, why swim against the current. But spaces also have their drawbacks. In general, when the standard was made, the smallest evil out of two possible was chosen (IMHO).
But these holivars seem to last for quite some time.
UPDATE2 10/14/2015At the request of the comments, I will collect in one place the main points why spaces are better than tabs:
- SmartTabs is great, but tzlom wrote in his comments , in which case even smart tabs are worse than spaces.
- Trite, most people write with spaces, there has already been historically moved ( comment ) from the user symbix , also here is proof
The pluses are of course strained, but until the end the whole truth about the reasons for the gaps against the tabs is known only to those who participated in the development of the standard.