Permalink
Browse files

More prep work

  • Loading branch information...
1 parent bd9f8a6 commit ea817bcb79c85e74cab35cc16e4a87a78b316249 @dongilbert committed Nov 28, 2012
View
8 docs/manual/en-US/coding-standards/chapters/namespacing.md
@@ -7,7 +7,7 @@ This chapter outlines things to remember when dealing with namespacing. Full nat
When writing code to contribute back to the platform, there are some things to keep in mind.
-* Preface internal PHP or SPL classes with a forward slash. This tells PHP to saearch the global namespace. More information here: [Using Global Classes in Namespaces on php.net](http://www.php.net/manual/en/language.namespaces.faq.php#language.namespaces.faq.globalclass)
+* Preface internal PHP or SPL classes with a backslash. This tells PHP to search the global namespace. More information here: [Using Global Classes in Namespaces on php.net](http://www.php.net/manual/en/language.namespaces.faq.php#language.namespaces.faq.globalclass)
```php
/**
@@ -37,13 +37,13 @@ $obj->property = 'bar';
throw new \RuntimeException('Yay namespaces!')
```
-* Calls to included libraries must also follow proper namespacing rules. If you wanted to use the `PDO` classes, you'll need to preface that with a forward slash as well.
+* Calls to included libraries must also follow proper namespacing rules. If you wanted to use the `PDO` classes, you'll need to preface that with a backslash as well.
```php
\PDO::query();
```
-* When using callables, use the magic `__CLASS__` constant whenever possible. For example, in `JLoader` we call `spl_autoload_register()` several times. This function takes a callable as it's argument, which is passed as an array of class name and method name. (See example below.) The reason this is important is that the `__CLASS__` constant returns the calling class name. If that class is in a namespace, it returns the fully qualified class name. This means the code you write in this fashion will not need to be re-written when full namespacing is achieved. It will just work. More information here: [__CLASS__ on php.net](http://php.net/manual/en/language.constants.predefined.php)
+* When using callables, use the magic `__CLASS__` constant whenever possible. For example, in `JLoader` we call `spl_autoload_register()` several times. This function takes a callable as it's argument, which is passed as an array of class name and method name. (See example below.) The reason this is important is that the `__CLASS__` constant returns the calling class name. If that class is in a namespace, it returns the fully qualified class name. This means the code you write in this fashion will not need to be re-written when full namespacing is achieved. It will just work. More information here: [`__CLASS__` on php.net](http://php.net/manual/en/language.constants.predefined.php)
```php
// This is the old way
@@ -55,7 +55,7 @@ spl_autoload_register(array(__CLASS__, 'load'));
### Namespace Compatibility Layer
-When full namespacing is achieved, there will be a compatibility layer that you can enable. This will allow you to use the latest platform code base with your existing app, without requiring a full re-write. By allowing users to make the transition as time allows, we reduce headaches without reducing our user base. All type hinting, `is_subclass_of()`, `instanceof`, etc works with this approach as well. It's much more seamless than importing all the classes at the top of each file where they are used.
+When full namespacing is achieved, there will be a compatibility layer that you can enable. This will allow you to use the latest platform code base with your existing app, without requiring a full re-write. By allowing users to make the transition as time allows, we reduce headaches without reducing our user base. All type hinting, `is_subclass_of()`, `instanceof`, etc continues to work with this approach as well. It's much more seamless than importing all the classes at the top of each file where they are used.
This compatibility layer will consist of basically a class map that will use the `class_alias` function to create aliases to all the class names as they exist now. One of the bigger benefits of this approach is that it requires little interaction from the end-user/developer. Simply enable the compatibility later, and your app will continue to function as it always has (in theory).
View
2 libraries/joomla/uri/uri.php
@@ -197,7 +197,7 @@ public static function getInstance($uri = 'SERVER')
$theURI = $uri;
}
- self::$instances[$uri] = new JURI($theURI);
+ self::$instances[$uri] = new static($theURI);
}
return self::$instances[$uri];
}
View
4 libraries/joomla/user/authentication.php
@@ -120,7 +120,7 @@ public static function getInstance()
{
if (empty(self::$instance))
{
- self::$instance = new JAuthentication;
+ self::$instance = new static;
}
return self::$instance;
@@ -171,7 +171,7 @@ public function attach($observer)
}
else
{
- if (!($observer instanceof JAuthentication))
+ if (!($observer instanceof self))
{
return;
}
View
4 libraries/joomla/user/user.php
@@ -257,13 +257,13 @@ public static function getInstance($identifier = 0)
// Note: don't cache this user because it'll have a new ID on save!
if ($id === 0)
{
- return new JUser;
+ return new static;
}
// Check if the user ID is already cached.
if (empty(self::$instances[$id]))
{
- $user = new JUser($id);
+ $user = new static($id);
self::$instances[$id] = $user;
}

0 comments on commit ea817bc

Please sign in to comment.