I recommend to familiarize with
php internals: endnamespacediscussionAfter another discussion in IRC, it was decided to use the \ character as a separator in namespaces in PHP. The patch is being prepared, and it is not known whether it will enter PHP 5.3 or not.
The argument can be found
here or
here.')
The main problem when using :: as a separator in the opinion of the developers is to understand what is happening in the line of code
Foo::bar();
it becomes difficult (this is a call to the static method bar () from the class Foo or a call to the function bar () from the namespace Foo?). An additional limitation is the PHP interpreter itself, which cannot distinguish name resolution from calling a static method. It is supposed to get rid of such ambiguity using the \ character.
However, many developers believe that this is the wrong choice. The \ character is used in escape sequences. There will be a problem with editing the code in existing editors and IDE, even just at the level of highlighting the code, not to mention its analysis.
The advantage of this approach, according to patch developers, is that \ is used \ for \ separation \ elements \ paths in Windows and therefore will be intuitive for programmers from the Windows world (According to the survey results, most php | architect readers work on Windows, and on Unix only deployed work :-)).
Other pros are:
- \ visually different from ::, and therefore skimming the code will make it easier to distinguish the namespace from the static method
- \ is inserted into the code with just one key (no need to hold down shift) in the English layout