chore(php): convert class underscores to namespaces

TODO:
- [x] Revert changes to `lib/system_log.php`
- [x] `*_subtype` instances need fixing.
- [x] Fix `elgg_echo` changes

I believe the only public classes namespaced with underscores were:
 * Elgg_Notifications_Notification
 * Elgg_Notifications_Event

I added those as extensions of their namespaced counterparts for backwards compatibility.

I used these commands to do it:

##### Convert namespace underscores to backslashes

TODO: details

##### Pull namespaces out of class declaration
```
find engine -type f -print0 | xargs -0 sed -i 's/class \(Elgg\(\\[A-Z][A-Za-z0-9]*\)*\)\\\([A-Z][A-Za-z0-9]*\)/namespace \1;\n\nclass \3/g'
```

Pulled namespaces out of interface declarations manually because there were only 3. Used this to find them:
```
grep -r 'interface \\' engine
```
##### Add global namespace qualifiers `Elgg\Class` => `\Elgg\Class`
```
find engine -type f -print0 | xargs -0 sed -i 's/\([^\\]\)Elgg\\/\1\\Elgg\\/g'
```

##### Remove global qualifiers from namespaces
```
find engine -type f -print0 | xargs -0 sed -i 's/namespace \\Elgg/namespace Elgg/g'
find engine -type f -print0 | xargs -0 sed -i 's/abstract namespace \([A-Za-z0-9\\]*\);\n\nclass/namespace \1;\n\nabstract class/g'          
```

##### TODO: Move namespaces to top

```
.scripts/move_namespaces_to_top.php
```

##### Add global qualifiers to global classes

```
find engine -type f -print0 | xargs -0 sed -i 's/\([^\\]\)PHPUnit_Framework_TestCase/\1\\PHPUnit_Framework_TestCase/g'
find engine -type f -print0 | xargs -0 sed -i 's/new \([A-Za-z]*\)Exception/new \\\1Exception/g'
find engine -type f -print0 | xargs -0 sed -i 's/extends \([A-Za-z]*\)Exception/extends \\\1Exception/g'
find engine -type f -print0 | xargs -0 sed -i 's/implements Iterator\([A-Za-z]+\)/implements \\Iterator\1/g'
find engine -type f -print0 | xargs -0 sed -i 's/, Countable/, \\Countable/g'
find engine -type f -print0 | xargs -0 sed -i 's/\([^\\\-\_A-Za-z\/]\)Elgg\([A-Z][A-Za-z]*\)/\1\\Elgg\2/g'
find engine -type f -print0 | xargs -0 sed -i 's/\([^\\\-\_A-Za-z\/]\)stdClass/\1\\stdClass/g'
find engine -type f -print0 | xargs -0 sed -i 's/\([^\\\-\_A-Za-z\/]\)Array\([A-Z][A-Za-z]*\)/\1\\Array\2/g'
find engine -type f -print0 | xargs -0 sed -i 's/\([^\\\-\_A-Za-z\/]\)\([A-Z][A-Za-z]*\)Iterator/\1\\\2Iterator/g'
find engine -type f -print0 | xargs -0 sed -i 's/class \\/class \1/g'
find engine -type f -print0 | xargs -0 sed -i 's/elgg_echo\(..\)\\/elgg_echo\1/g'
```


##### Fixed lint problems
Did this manually. Most common issue was having a space between the class docblock and the class, which made it look like we didn't write any docblocks for those classes.

The other issue was alightment of properties. The leading namespace character throws things off.
I'm in favor of deprecation msg, but would rather https://github.com/Elgg/Elgg/issues/7125


On 7/30/14 7:08 AM, Juho Jaakkola wrote:
> Couldn't we add a constructor that would trigger a deprecation warning and then call parent?