Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Native Namespace Code Prep #1721

Closed
wants to merge 6 commits into from

5 participants

@dongilbert
Collaborator

This PR adds in the root namespace backslash on calls to internal PHP and SPL classes. This will facilitate the platform moving to native PHP namespaces, whenever that may be.

More info can be found here: http://www.php.net/manual/en/language.namespaces.faq.php#language.namespaces.faq.globalclass

Also, I've replaced some explicit calls to class names with __CLASS__ in callables. For example, in JLoader when calling spl_autoload_register(). Also, where creating a new instance of the containing class, I've changed new JClassName to new static. I've not completed all instances of these yet.

This PR does not break B/C at all, as the whole codebase is already operating in the root/global namespace. But this will need to be done when we do move to namespaces, so I thought I could help that along.

No unit tests were harmed in the making of this pull request.

@eddieajau

Thanks Don. Would you mind adding a page to the docs, probably namspacing.md under the Code Standards heading, which outlines what we need to be aware of when writing, and obviously reviewing, code?

It makes sense for the platform, but I think this could potentially give the CMS some grief with extension developers that want to retain support for PHP 5.2 on CMS 2.5 yet maintain a dual 2.5+3 version package. I don't have a problem with the change but it's probably worth giving the CMS dev list a heads up that we are talking about this.

@dongilbert
Collaborator

I was looking at adding to the documentation here - https://github.com/joomla/joomla-platform/blob/staging/docs/manual/en-US/coding-standards/chapters/php.md#class-definitions - but it's probably best to make it it's own page, since I'm sure the section will continue to grow. I'll get that added as well as inform the CMS dev list.

@eddieajau

Thanks. I think it's better for it to be highly visible and I think it's easier to point to a single page on the topic when fielding questions (or criticism {cough}) about it.

@dongilbert
Collaborator

See documentation here - https://github.com/dongilbert/joomla-platform/blob/namespace_prep/docs/manual/en-US/coding-standards/chapters/namespacing.md

It's not completed yet, but it's what I could think of for now.

As for that compatibility layer section. We can take it or leave it, it's just my thoughts of what I would like to see happen, even if I maintain that layer myself for the 2 revisions after going fully namespaced.

@eddieajau

Compat. layer sounds good. I can get behind that if that's something we need (we should do some more clean up and shunting to the /legacy tree before we finalise it).

@dongilbert
Collaborator

I agree - a lot of the compatibility needs could be buffered in the legacy tree, and then the remainder picked up by the proposed compatibility layer.

As you suggested in the mailing list, I think it's a great idea to hold off until 13.1 to merge this. Want to change the milestone?

@eddieajau

Bumped to 13.1.

@nicksavov

Nice job, Don!

@dongilbert
Collaborator

Thanks - we pretty much put all our eggs in the J! basket at work - so if I want to use namespaces and all that has to offer, I need to make it happen.

@dongilbert
Collaborator

Suggested way to handle the compatibility layer.

https://gist.github.com/4162595

@dongilbert
Collaborator

Instead of __CLASS__, should we use $this when passing to a callable?

libraries/joomla/data/data.php
@@ -17,7 +17,7 @@
* @subpackage Data
* @since 12.3
*/
-class JData implements JDataDumpable, IteratorAggregate, JsonSerializable, Countable
+class JData implements \JDataDumpable, \IteratorAggregate, \JsonSerializable, \Countable
@mbabker Owner
mbabker added a note

JDataDumpable shouldn't have the slash here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@realityking realityking commented on the diff
libraries/joomla/database/driver/oracle.php
@@ -519,7 +519,7 @@ public function unlockTables()
*/
public static function isSupported()
{
- return class_exists('PDO') && in_array('oci', PDO::getAvailableDrivers());
+ return class_exists('PDO') && in_array('oci', \PDO::getAvailableDrivers());
@realityking Collaborator

Shouldn't this be class_exists('\PDO')?

@dongilbert Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@dongilbert dongilbert closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 30, 2012
  1. @dongilbert
  2. @dongilbert

    Replacing explicit class calls with __CLASS__ in callables

    dongilbert authored
    Create new instance with new static instead of new 'name of class'
  3. @dongilbert
  4. @dongilbert
  5. @dongilbert

    More prep work

    dongilbert authored
Commits on Dec 28, 2012
  1. @dongilbert
This page is out of date. Refresh to see the latest.
Showing with 657 additions and 591 deletions.
  1. +62 −0 docs/manual/en-US/coding-standards/chapters/namespacing.md
  2. +1 −0  docs/manual/en-US/menu.md
  3. +2 −2 libraries/joomla/access/access.php
  4. +3 −3 libraries/joomla/application/cli.php
  5. +7 −7 libraries/joomla/application/daemon.php
  6. +1 −1  libraries/joomla/application/router.php
  7. +4 −4 libraries/joomla/application/web.php
  8. +1 −1  libraries/joomla/application/web/router.php
  9. +1 −1  libraries/joomla/application/web/router/base.php
  10. +1 −1  libraries/joomla/application/web/router/rest.php
  11. +4 −4 libraries/joomla/archive/archive.php
  12. +7 −7 libraries/joomla/archive/bzip2.php
  13. +8 −8 libraries/joomla/archive/gzip.php
  14. +4 −4 libraries/joomla/archive/tar.php
  15. +13 −13 libraries/joomla/archive/zip.php
  16. +8 −8 libraries/joomla/cache/cache.php
  17. +3 −3 libraries/joomla/cache/controller.php
  18. +2 −2 libraries/joomla/cache/storage.php
  19. +2 −2 libraries/joomla/cache/storage/cachelite.php
  20. +2 −2 libraries/joomla/cache/storage/memcache.php
  21. +5 −5 libraries/joomla/cache/storage/memcached.php
  22. +1 −1  libraries/joomla/client/helper.php
  23. +1 −1  libraries/joomla/controller/base.php
  24. +1 −1  libraries/joomla/controller/controller.php
  25. +3 −3 libraries/joomla/crypt/cipher/mcrypt.php
  26. +2 −2 libraries/joomla/crypt/cipher/simple.php
  27. +1 −1  libraries/joomla/crypt/password/simple.php
  28. +8 −8 libraries/joomla/data/data.php
  29. +1 −1  libraries/joomla/data/dumpable.php
  30. +4 −4 libraries/joomla/data/set.php
  31. +8 −8 libraries/joomla/database/driver.php
  32. +7 −7 libraries/joomla/database/driver/mysql.php
  33. +7 −7 libraries/joomla/database/driver/mysqli.php
  34. +1 −1  libraries/joomla/database/driver/oracle.php
  35. +25 −25 libraries/joomla/database/driver/pdo.php
  36. +8 −8 libraries/joomla/database/driver/postgresql.php
  37. +8 −8 libraries/joomla/database/driver/sqlite.php
  38. +7 −7 libraries/joomla/database/driver/sqlsrv.php
  39. +2 −2 libraries/joomla/database/exporter/mysql.php
  40. +4 −4 libraries/joomla/database/exporter/mysqli.php
  41. +4 −4 libraries/joomla/database/exporter/postgresql.php
  42. +6 −6 libraries/joomla/database/factory.php
  43. +2 −2 libraries/joomla/database/importer/mysql.php
  44. +12 −12 libraries/joomla/database/importer/mysqli.php
  45. +12 −12 libraries/joomla/database/importer/postgresql.php
  46. +2 −2 libraries/joomla/database/iterator.php
  47. +3 −3 libraries/joomla/database/iterator/pdo.php
  48. +6 −6 libraries/joomla/database/query.php
  49. +1 −1  libraries/joomla/database/query/oracle.php
  50. +1 −1  libraries/joomla/database/query/preparable.php
  51. +1 −1  libraries/joomla/database/query/sqlite.php
  52. +8 −8 libraries/joomla/date/date.php
  53. +2 −2 libraries/joomla/document/document.php
  54. +1 −1  libraries/joomla/document/error/error.php
  55. +1 −1  libraries/joomla/document/feed/feed.php
  56. +1 −1  libraries/joomla/document/feed/renderer/atom.php
  57. +1 −1  libraries/joomla/document/feed/renderer/rss.php
  58. +1 −1  libraries/joomla/document/html/renderer/module.php
  59. +2 −2 libraries/joomla/environment/browser.php
  60. +1 −1  libraries/joomla/event/dispatcher.php
  61. +5 −5 libraries/joomla/factory.php
  62. +7 −7 libraries/joomla/filesystem/folder.php
  63. +1 −1  libraries/joomla/filesystem/helper.php
  64. +10 −10 libraries/joomla/filesystem/patcher.php
  65. +3 −3 libraries/joomla/filesystem/path.php
  66. +7 −7 libraries/joomla/github/account.php
  67. +10 −10 libraries/joomla/github/commits.php
  68. +2 −2 libraries/joomla/github/forks.php
  69. +18 −18 libraries/joomla/github/gists.php
  70. +10 −10 libraries/joomla/github/hooks.php
  71. +15 −15 libraries/joomla/github/issues.php
  72. +5 −5 libraries/joomla/github/milestones.php
  73. +16 −16 libraries/joomla/github/pulls.php
  74. +5 −5 libraries/joomla/github/refs.php
  75. +3 −3 libraries/joomla/github/statuses.php
  76. +4 −4 libraries/joomla/google/data.php
  77. +11 −11 libraries/joomla/google/data/adsense.php
  78. +22 −22 libraries/joomla/google/data/calendar.php
  79. +2 −2 libraries/joomla/google/data/picasa.php
  80. +9 −9 libraries/joomla/google/data/picasa/album.php
  81. +6 −6 libraries/joomla/google/data/picasa/photo.php
  82. +2 −2 libraries/joomla/google/embed/analytics.php
  83. +4 −4 libraries/joomla/google/embed/maps.php
  84. +1 −1  libraries/joomla/grid/grid.php
  85. +1 −1  libraries/joomla/html/content.php
  86. +6 −6 libraries/joomla/html/html.php
  87. +1 −1  libraries/joomla/html/jgrid.php
  88. +1 −1  libraries/joomla/html/list.php
  89. +2 −2 libraries/joomla/html/select.php
  90. +1 −1  libraries/joomla/http/factory.php
  91. +2 −2 libraries/joomla/http/transport/curl.php
  92. +7 −7 libraries/joomla/http/transport/socket.php
  93. +4 −4 libraries/joomla/http/transport/stream.php
  94. +1 −1  libraries/joomla/image/filter.php
  95. +1 −1  libraries/joomla/image/filter/brightness.php
  96. +1 −1  libraries/joomla/image/filter/contrast.php
  97. +1 −1  libraries/joomla/image/filter/smooth.php
  98. +28 −28 libraries/joomla/image/image.php
  99. +1 −1  libraries/joomla/input/input.php
  100. +10 −9 libraries/joomla/keychain/keychain.php
  101. +2 −2 libraries/joomla/language/language.php
  102. +1 −1  libraries/joomla/language/stemmer.php
  103. +1 −1  libraries/joomla/log/log.php
  104. +2 −2 libraries/joomla/log/logger/formattedtext.php
  105. +6 −6 libraries/joomla/mail/mail.php
  106. +7 −7 libraries/joomla/oauth2/client.php
  107. +1 −1  libraries/joomla/object/object.php
  108. +3 −1 libraries/joomla/pagination/pagination.php
  109. +1 −1  libraries/joomla/registry/format.php
  110. +3 −3 libraries/joomla/registry/format/ini.php
  111. +3 −3 libraries/joomla/registry/format/xml.php
  112. +2 −2 libraries/joomla/registry/registry.php
  113. +3 −3 libraries/joomla/session/session.php
  114. +1 −1  libraries/joomla/session/storage/apc.php
  115. +4 −4 libraries/joomla/session/storage/database.php
  116. +1 −1  libraries/joomla/session/storage/memcache.php
  117. +1 −1  libraries/joomla/session/storage/memcached.php
  118. +1 −1  libraries/joomla/session/storage/wincache.php
  119. +1 −1  libraries/joomla/session/storage/xcache.php
  120. +1 −1  libraries/joomla/string/inflector.php
  121. +15 −15 libraries/joomla/table/nested.php
  122. +12 −12 libraries/joomla/table/table.php
  123. +4 −4 libraries/joomla/table/usergroup.php
  124. +1 −1  libraries/joomla/uri/uri.php
  125. +2 −2 libraries/joomla/user/authentication.php
  126. +1 −1  libraries/joomla/user/helper.php
  127. +6 −6 libraries/joomla/user/user.php
  128. +4 −4 libraries/joomla/view/html.php
  129. +13 −13 libraries/loader.php
View
62 docs/manual/en-US/coding-standards/chapters/namespacing.md
@@ -0,0 +1,62 @@
+## Namespacing
+
+This chapter outlines things to remember when dealing with namespacing. Full native namespacing has not yet been implemented in the Joomla! Platform. So far, there are some preparations being made to make the transition, but we are a long way from making that large change.
+
+
+### Things to Remember When Contributing
+
+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 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
+/**
+ * This is the wrong way to call the class.
+ * When full namespacing is achieved, this
+ * will result in a class load error.
+ * Ex. "Class \Foo\Bar\stdClass not found"
+ */
+$obj = new stdClass;
+$obj->property = 'foo';
+
+/**
+ * Same when working with Exceptions. This
+ * will fail in a fully namespaced environment.
+ */
+throw new RuntimeException('Error Message Here.');
+
+/**
+ * This is the correct way to call it. The
+ * The forward slash tells it to search for
+ * the class in the global namespace
+ */
+$obj = new \stdClass;
+$obj->property = 'bar';
+
+// And Exceptions
+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 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)
+
+```php
+// This is the old way
+spl_autoload_register(array('JLoader', 'load'));
+
+// This is the namespaced way
+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 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).
+
+This layer will be available at least for 2 platform releases after achieving full namespace compatibility, after which it may be retained by any applications that are using it, such as the CMS if it chooses to implement these changes.
View
1  docs/manual/en-US/menu.md
@@ -20,6 +20,7 @@
- [Basic Guidelines](coding-standards/chapters/basic-guidelines.md)
- [Comments](coding-standards/chapters/comments.md)
- [PHP Code](coding-standards/chapters/php.md)
+- [Namespacing](coding-standards/chapters/namespacing.md)
- Appendices
- [Code Analysis](appendices/analysis.md)
View
4 libraries/joomla/access/access.php
@@ -488,7 +488,7 @@ public static function getActionsFromFile($file, $xpath = "/access/section[@name
public static function getActionsFromData($data, $xpath = "/access/section[@name='component']/")
{
// If the data to load isn't already an XML element or string return false.
- if ((!($data instanceof SimpleXMLElement)) && (!is_string($data)))
+ if ((!($data instanceof \SimpleXMLElement)) && (!is_string($data)))
{
return false;
}
@@ -498,7 +498,7 @@ public static function getActionsFromData($data, $xpath = "/access/section[@name
{
try
{
- $data = new SimpleXMLElement($data);
+ $data = new \SimpleXMLElement($data);
}
catch (Exception $e)
{
View
6 libraries/joomla/application/cli.php
@@ -126,13 +126,13 @@ public static function getInstance($name = null)
// Only create the object if it doesn't exist.
if (empty(self::$instance))
{
- if (class_exists($name) && (is_subclass_of($name, 'JApplicationCli')))
+ if (class_exists($name) && (is_subclass_of($name, __CLASS__)))
{
self::$instance = new $name;
}
else
{
- self::$instance = new JApplicationCli;
+ self::$instance = new static;
}
}
@@ -271,7 +271,7 @@ protected function fetchConfigurationData($file = '', $class = 'JConfig')
}
else
{
- throw new RuntimeException('Configuration class does not exist.');
+ throw new \RuntimeException('Configuration class does not exist.');
}
}
View
14 libraries/joomla/application/daemon.php
@@ -114,14 +114,14 @@ public function __construct(JInputCli $input = null, JRegistry $config = null, J
if (!defined('SIGHUP'))
{
JLog::add('The PCNTL extension for PHP is not available.', JLog::ERROR);
- throw new RuntimeException('The PCNTL extension for PHP is not available.');
+ throw new \RuntimeException('The PCNTL extension for PHP is not available.');
}
// Verify that POSIX support for PHP is available.
if (!function_exists('posix_getpid'))
{
JLog::add('The POSIX extension for PHP is not available.', JLog::ERROR);
- throw new RuntimeException('The POSIX extension for PHP is not available.');
+ throw new \RuntimeException('The POSIX extension for PHP is not available.');
}
// @codeCoverageIgnoreEnd
@@ -157,10 +157,10 @@ public static function signal($signal)
JLog::add('Received signal: ' . $signal, JLog::DEBUG);
// Let's make sure we have an application instance.
- if (!is_subclass_of(static::$instance, 'JApplicationDaemon'))
+ if (!is_subclass_of(static::$instance, __CLASS__))
{
JLog::add('Cannot find the application instance.', JLog::EMERGENCY);
- throw new RuntimeException('Cannot find the application instance.');
+ throw new \RuntimeException('Cannot find the application instance.');
}
// Fire the onReceiveSignal event.
@@ -535,7 +535,7 @@ protected function daemonize()
$this->parentId = $this->processId;
}
}
- catch (RuntimeException $e)
+ catch (\RuntimeException $e)
{
JLog::add('Unable to fork.', JLog::EMERGENCY);
@@ -641,7 +641,7 @@ protected function fork()
// If the fork failed, throw an exception.
if ($pid === -1)
{
- throw new RuntimeException('The process could not be forked.');
+ throw new \RuntimeException('The process could not be forked.');
}
// Update the process id for the child.
elseif ($pid === 0)
@@ -706,7 +706,7 @@ protected function setupSignalHandlers()
}
// Attach the signal handler for the signal.
- if (!$this->pcntlSignal(constant($signal), array('JApplicationDaemon', 'signal')))
+ if (!$this->pcntlSignal(constant($signal), array(__CLASS__, 'signal')))
{
JLog::add(sprintf('Unable to reroute signal handler: %s', $signal), JLog::EMERGENCY);
View
2  libraries/joomla/application/router.php
@@ -149,7 +149,7 @@ public static function getInstance($client, $options = array())
}
else
{
- throw new RuntimeException(JText::sprintf('JLIB_APPLICATION_ERROR_ROUTER_LOAD', $client), 500);
+ throw new \RuntimeException(JText::sprintf('JLIB_APPLICATION_ERROR_ROUTER_LOAD', $client), 500);
}
}
View
8 libraries/joomla/application/web.php
@@ -136,7 +136,7 @@ public function __construct(JInput $input = null, JRegistry $config = null, JApp
$this->set('execution.timestamp', time());
// Setup the response object.
- $this->response = new stdClass;
+ $this->response = new \stdClass;
$this->response->cachable = false;
$this->response->headers = array();
$this->response->body = array();
@@ -161,13 +161,13 @@ public static function getInstance($name = null)
// Only create the object if it doesn't exist.
if (empty(self::$instance))
{
- if (class_exists($name) && (is_subclass_of($name, 'JApplicationWeb')))
+ if (class_exists($name) && (is_subclass_of($name, __CLASS__)))
{
self::$instance = new $name;
}
else
{
- self::$instance = new JApplicationWeb;
+ self::$instance = new static;
}
}
@@ -920,7 +920,7 @@ protected function fetchConfigurationData($file = '', $class = 'JConfig')
}
else
{
- throw new RuntimeException('Configuration class does not exist.');
+ throw new \RuntimeException('Configuration class does not exist.');
}
}
View
2  libraries/joomla/application/web/router.php
@@ -142,7 +142,7 @@ protected function fetchController($name)
// If the controller class does not exist panic.
if (!class_exists($class) || !is_subclass_of($class, 'JController'))
{
- throw new RuntimeException(sprintf('Unable to locate controller `%s`.', $class), 404);
+ throw new \RuntimeException(sprintf('Unable to locate controller `%s`.', $class), 404);
}
// Instantiate the controller.
View
2  libraries/joomla/application/web/router/base.php
@@ -169,7 +169,7 @@ protected function parseRoute($route)
// We were unable to find a route match for the request. Panic.
if (!$controller)
{
- throw new InvalidArgumentException(sprintf('Unable to handle request for route `%s`.', $route), 404);
+ throw new \InvalidArgumentException(sprintf('Unable to handle request for route `%s`.', $route), 404);
}
return $controller;
View
2  libraries/joomla/application/web/router/rest.php
@@ -121,7 +121,7 @@ protected function fetchControllerSuffix()
// Validate that we have a map to handle the given HTTP method.
if (!isset($this->suffixMap[$this->input->getMethod()]))
{
- throw new RuntimeException(sprintf('Unable to support the HTTP method `%s`.', $this->input->getMethod()), 404);
+ throw new \RuntimeException(sprintf('Unable to support the HTTP method `%s`.', $this->input->getMethod()), 404);
}
// Check if request method is POST
View
8 libraries/joomla/archive/archive.php
@@ -128,7 +128,7 @@ public static function extract($archivename, $extractdir)
$tmpfname = $config->get('tmp_path') . '/' . uniqid('bzip2');
$bzresult = $adapter->extract($archivename, $tmpfname);
- if ($bzresult instanceof Exception)
+ if ($bzresult instanceof \Exception)
{
@unlink($tmpfname);
@@ -157,10 +157,10 @@ public static function extract($archivename, $extractdir)
break;
default:
- throw new InvalidArgumentException('Unknown Archive Type');
+ throw new \InvalidArgumentException('Unknown Archive Type');
}
- if (!$result || $result instanceof Exception)
+ if (!$result || $result instanceof \Exception)
{
return false;
}
@@ -187,7 +187,7 @@ public static function getAdapter($type)
if (!class_exists($class))
{
- throw new UnexpectedValueException('Unable to load archive', 500);
+ throw new \UnexpectedValueException('Unable to load archive', 500);
}
self::$adapters[$type] = new $class;
View
14 libraries/joomla/archive/bzip2.php
@@ -52,7 +52,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('The bz2 extension is not available.');
+ throw new \RuntimeException('The bz2 extension is not available.');
}
}
@@ -69,7 +69,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('Unable to read archive');
+ throw new \RuntimeException('Unable to read archive');
}
}
@@ -84,7 +84,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('Unable to decompress data');
+ throw new \RuntimeException('Unable to decompress data');
}
}
@@ -96,7 +96,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('Unable to write archive');
+ throw new \RuntimeException('Unable to write archive');
}
}
@@ -117,7 +117,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('Unable to read archive (bz2)');
+ throw new \RuntimeException('Unable to read archive (bz2)');
}
}
@@ -133,7 +133,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('Unable to write archive (bz2)');
+ throw new \RuntimeException('Unable to write archive (bz2)');
}
}
@@ -153,7 +153,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('Unable to write archive (bz2)');
+ throw new \RuntimeException('Unable to write archive (bz2)');
}
}
}
View
16 libraries/joomla/archive/gzip.php
@@ -64,7 +64,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('The zlib extension is not available.');
+ throw new \RuntimeException('The zlib extension is not available.');
}
}
@@ -80,7 +80,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('Unable to read archive');
+ throw new \RuntimeException('Unable to read archive');
}
}
@@ -95,7 +95,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('Unable to decompress data');
+ throw new \RuntimeException('Unable to decompress data');
}
}
@@ -107,7 +107,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('Unable to write archive');
+ throw new \RuntimeException('Unable to write archive');
}
}
}
@@ -127,7 +127,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('Unable to read archive (gz)');
+ throw new \RuntimeException('Unable to read archive (gz)');
}
}
@@ -143,7 +143,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('Unable to write archive (gz)');
+ throw new \RuntimeException('Unable to write archive (gz)');
}
}
@@ -163,7 +163,7 @@ public function extract($archive, $destination, array $options = array ())
}
else
{
- throw new RuntimeException('Unable to write file (gz)');
+ throw new \RuntimeException('Unable to write file (gz)');
}
}
}
@@ -210,7 +210,7 @@ public function _getFilePosition()
}
else
{
- throw new RuntimeException('Unable to decompress data.');
+ throw new \RuntimeException('Unable to decompress data.');
}
}
View
8 libraries/joomla/archive/tar.php
@@ -86,7 +86,7 @@ public function extract($archive, $destination, array $options = array())
}
else
{
- throw new RuntimeException('Unable to read archive');
+ throw new \RuntimeException('Unable to read archive');
}
}
@@ -110,7 +110,7 @@ public function extract($archive, $destination, array $options = array())
}
else
{
- throw new RuntimeException('Unable to create destination');
+ throw new \RuntimeException('Unable to create destination');
}
}
if (JFile::write($path, $buffer) === false)
@@ -121,7 +121,7 @@ public function extract($archive, $destination, array $options = array())
}
else
{
- throw new RuntimeException('Unable to write entry');
+ throw new \RuntimeException('Unable to write entry');
}
}
}
@@ -179,7 +179,7 @@ protected function _getTarInfo(& $data)
}
else
{
- throw new RuntimeException('Unable to decompress data');
+ throw new \RuntimeException('Unable to decompress data');
}
}
View
26 libraries/joomla/archive/zip.php
@@ -133,7 +133,7 @@ public function extract($archive, $destination, array $options = array())
}
else
{
- throw new RuntimeException('Archive does not exist');
+ throw new \RuntimeException('Archive does not exist');
}
}
@@ -216,7 +216,7 @@ protected function extractCustom($archive, $destination)
}
else
{
- throw new RuntimeException('Zlib not supported');
+ throw new \RuntimeException('Zlib not supported');
}
}
@@ -230,7 +230,7 @@ protected function extractCustom($archive, $destination)
}
else
{
- throw new RuntimeException('Unable to read archive (zip)');
+ throw new \RuntimeException('Unable to read archive (zip)');
}
}
@@ -242,7 +242,7 @@ protected function extractCustom($archive, $destination)
}
else
{
- throw new RuntimeException('Get ZIP Information failed');
+ throw new \RuntimeException('Get ZIP Information failed');
}
}
@@ -264,7 +264,7 @@ protected function extractCustom($archive, $destination)
}
else
{
- throw new RuntimeException('Unable to create destination');
+ throw new \RuntimeException('Unable to create destination');
}
}
@@ -276,7 +276,7 @@ protected function extractCustom($archive, $destination)
}
else
{
- throw new RuntimeException('Unable to write entry');
+ throw new \RuntimeException('Unable to write entry');
}
}
}
@@ -311,7 +311,7 @@ protected function extractNative($archive, $destination)
}
else
{
- throw new RuntimeException('Unable to create destination');
+ throw new \RuntimeException('Unable to create destination');
}
}
@@ -332,7 +332,7 @@ protected function extractNative($archive, $destination)
}
else
{
- throw new RuntimeException('Unable to write entry');
+ throw new \RuntimeException('Unable to write entry');
}
}
@@ -347,7 +347,7 @@ protected function extractNative($archive, $destination)
}
else
{
- throw new RuntimeException('Unable to read entry');
+ throw new \RuntimeException('Unable to read entry');
}
}
}
@@ -362,7 +362,7 @@ protected function extractNative($archive, $destination)
}
else
{
- throw new RuntimeException('Unable to open archive');
+ throw new \RuntimeException('Unable to open archive');
}
}
@@ -431,7 +431,7 @@ private function _readZipInfo(&$data)
}
else
{
- throw new RuntimeException('Invalid Zip Data');
+ throw new \RuntimeException('Invalid Zip Data');
}
}
@@ -468,7 +468,7 @@ private function _readZipInfo(&$data)
}
else
{
- throw new RuntimeException('Invalid ZIP data');
+ throw new \RuntimeException('Invalid ZIP data');
}
}
@@ -490,7 +490,7 @@ private function _readZipInfo(&$data)
}
else
{
- throw new RuntimeException('Invalid Zip Data');
+ throw new \RuntimeException('Invalid Zip Data');
}
}
View
16 libraries/joomla/cache/cache.php
@@ -94,7 +94,7 @@ public static function getStores()
$handlers = array();
// Get an iterator and loop trough the driver classes.
- $iterator = new DirectoryIterator(__DIR__ . '/storage');
+ $iterator = new \DirectoryIterator(__DIR__ . '/storage');
foreach ($iterator as $file)
{
@@ -232,7 +232,7 @@ public function store($data, $id, $group = null)
// Get the storage and store the cached data
$handler = $this->_getStorage();
- if (!($handler instanceof Exception) && $this->_options['caching'])
+ if (!($handler instanceof \Exception) && $this->_options['caching'])
{
$handler->_lifetime = $this->_options['lifetime'];
@@ -259,7 +259,7 @@ public function remove($id, $group = null)
// Get the storage
$handler = $this->_getStorage();
- if (!($handler instanceof Exception))
+ if (!($handler instanceof \Exception))
{
return $handler->remove($id, $group);
}
@@ -287,7 +287,7 @@ public function clean($group = null, $mode = 'group')
// Get the storage handler
$handler = $this->_getStorage();
- if (!($handler instanceof Exception))
+ if (!($handler instanceof \Exception))
{
return $handler->clean($group, $mode);
}
@@ -306,7 +306,7 @@ public function gc()
// Get the storage handler
$handler = $this->_getStorage();
- if (!($handler instanceof Exception))
+ if (!($handler instanceof \Exception))
{
return $handler->gc();
}
@@ -339,7 +339,7 @@ public function lock($id, $group = null, $locktime = null)
// NOTE drivers with lock need also unlock or unlocking will fail because of false $id
$handler = $this->_getStorage();
- if (!($handler instanceof Exception) && $this->_options['locking'] == true && $this->_options['caching'] == true)
+ if (!($handler instanceof \Exception) && $this->_options['locking'] == true && $this->_options['caching'] == true)
{
$locked = $handler->lock($id, $group, $locktime);
@@ -422,7 +422,7 @@ public function unlock($id, $group = null)
// Allow handlers to perform unlocking on their own
$handler = $this->_getStorage();
- if (!($handler instanceof Exception) && $this->_options['caching'])
+ if (!($handler instanceof \Exception) && $this->_options['caching'])
{
$unlocked = $handler->unlock($id, $group);
@@ -679,7 +679,7 @@ public static function makeId()
$registeredurlparams->tpl = 'CMD';
$registeredurlparams->id = 'INT';
- $safeuriaddon = new stdClass;
+ $safeuriaddon = new \stdClass;
foreach ($registeredurlparams as $key => $value)
{
View
6 libraries/joomla/cache/controller.php
@@ -99,7 +99,7 @@ public static function getInstance($type = 'output', $options = array())
}
else
{
- throw new RuntimeException('Unable to load Cache Controller: ' . $type, 500);
+ throw new \RuntimeException('Unable to load Cache Controller: ' . $type, 500);
}
}
@@ -177,7 +177,7 @@ public function get($id, $group = null)
if ($data === false)
{
- $locktest = new stdClass;
+ $locktest = new \stdClass;
$locktest->locked = null;
$locktest->locklooped = null;
$locktest = $this->cache->lock($id, $group);
@@ -214,7 +214,7 @@ public function get($id, $group = null)
*/
public function store($data, $id, $group = null)
{
- $locktest = new stdClass;
+ $locktest = new \stdClass;
$locktest->locked = null;
$locktest->locklooped = null;
View
4 libraries/joomla/cache/storage.php
@@ -117,7 +117,7 @@ public static function getInstance($handler = null, $options = array())
if (empty($handler))
{
- throw new UnexpectedValueException('Cache Storage Handler not set.');
+ throw new \UnexpectedValueException('Cache Storage Handler not set.');
}
}
@@ -144,7 +144,7 @@ public static function getInstance($handler = null, $options = array())
}
else
{
- throw new RuntimeException(sprintf('Unable to load Cache Storage: %s', $handler));
+ throw new \RuntimeException(sprintf('Unable to load Cache Storage: %s', $handler));
}
}
View
4 libraries/joomla/cache/storage/cachelite.php
@@ -111,7 +111,7 @@ public function getAll()
parent::getAll();
$path = $this->_root;
- $folders = new DirectoryIterator($path);
+ $folders = new \DirectoryIterator($path);
$data = array();
foreach ($folders as $folder)
@@ -123,7 +123,7 @@ public function getAll()
$foldername = $folder->getFilename();
- $files = new DirectoryIterator($path . '/' . $foldername);
+ $files = new \DirectoryIterator($path . '/' . $foldername);
$item = new JCacheStorageHelper($foldername);
foreach ($files as $file)
View
4 libraries/joomla/cache/storage/memcache.php
@@ -90,7 +90,7 @@ protected function getConnection()
if ($memcachetest == false)
{
- throw new RuntimeException('Could not connect to memcache server', 404);
+ throw new \RuntimeException('Could not connect to memcache server', 404);
}
// Memcahed has no list keys, we do our own accounting, initialise key index
@@ -316,7 +316,7 @@ public static function isSupported()
$host = $config->get('memcache_server_host', 'localhost');
$port = $config->get('memcache_server_port', 11211);
- $memcache = new Memcache;
+ $memcache = new \Memcache;
$memcachetest = @$memcache->connect($host, $port);
if (!$memcachetest)
View
10 libraries/joomla/cache/storage/memcached.php
@@ -90,13 +90,13 @@ protected function getConnection()
}
else
{
- self::$_db = new Memcached;
+ self::$_db = new \Memcached;
}
$memcachedtest = self::$_db->addServer($server['host'], $server['port']);
if ($memcachedtest == false)
{
- throw new RuntimeException('Could not connect to memcached server', 404);
+ throw new \RuntimeException('Could not connect to memcached server', 404);
}
self::$_db->setOption(Memcached::OPT_COMPRESSION, $this->_compress);
@@ -207,7 +207,7 @@ public function store($id, $group, $data)
$index = array();
}
- $tmparr = new stdClass;
+ $tmparr = new \stdClass;
$tmparr->name = $cache_id;
$tmparr->size = strlen($data);
$index[] = $tmparr;
@@ -324,7 +324,7 @@ public static function isSupported()
$host = $config->get('memcache_server_host', 'localhost');
$port = $config->get('memcache_server_port', 11211);
- $memcached = new Memcached;
+ $memcached = new \Memcached;
$memcachedtest = @$memcached->addServer($host, $port);
if (!$memcachedtest)
@@ -369,7 +369,7 @@ public function lock($id, $group, $locktime)
$index = array();
}
- $tmparr = new stdClass;
+ $tmparr = new \stdClass;
$tmparr->name = $cache_id;
$tmparr->size = 1;
View
2  libraries/joomla/client/helper.php
@@ -225,7 +225,7 @@ public static function setCredentialsFromRequest($client)
}
else
{
- throw new InvalidArgumentException('Invalid user credentials');
+ throw new \InvalidArgumentException('Invalid user credentials');
}
}
}
View
2  libraries/joomla/controller/base.php
@@ -105,7 +105,7 @@ public function unserialize($input)
if (!($this->input instanceof JInput))
{
- throw new UnexpectedValueException(sprintf('%s::unserialize would not accept a `%s`.', get_class($this), gettype($this->input)));
+ throw new \UnexpectedValueException(sprintf('%s::unserialize would not accept a `%s`.', get_class($this), gettype($this->input)));
}
return $this;
View
2  libraries/joomla/controller/controller.php
@@ -16,7 +16,7 @@
* @subpackage Controller
* @since 12.1
*/
-interface JController extends Serializable
+interface JController extends \Serializable
{
/**
* Execute the controller.
View
6 libraries/joomla/crypt/cipher/mcrypt.php
@@ -48,7 +48,7 @@ public function __construct()
{
if (!is_callable('mcrypt_encrypt'))
{
- throw new RuntimeException('The mcrypt extension is not available.');
+ throw new \RuntimeException('The mcrypt extension is not available.');
}
}
@@ -67,7 +67,7 @@ public function decrypt($data, JCryptKey $key)
// Validate key.
if ($key->type != $this->keyType)
{
- throw new InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected ' . $this->keyType . '.');
+ throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected ' . $this->keyType . '.');
}
// Decrypt the data.
@@ -91,7 +91,7 @@ public function encrypt($data, JCryptKey $key)
// Validate key.
if ($key->type != $this->keyType)
{
- throw new InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected ' . $this->keyType . '.');
+ throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected ' . $this->keyType . '.');
}
// Encrypt the data.
View
4 libraries/joomla/crypt/cipher/simple.php
@@ -34,7 +34,7 @@ public function decrypt($data, JCryptKey $key)
// Validate key.
if ($key->type != 'simple')
{
- throw new InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected simple.');
+ throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected simple.');
}
$decrypted = '';
@@ -75,7 +75,7 @@ public function encrypt($data, JCryptKey $key)
// Validate key.
if ($key->type != 'simple')
{
- throw new InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected simple.');
+ throw new \InvalidArgumentException('Invalid key of type: ' . $key->type . '. Expected simple.');
}
$encrypted = '';
View
2  libraries/joomla/crypt/password/simple.php
@@ -78,7 +78,7 @@ public function create($password, $type = null)
return md5($password . $salt) . ':' . $salt;
default:
- throw new InvalidArgumentException(sprintf('Hash type %s is not supported', $type));
+ throw new \InvalidArgumentException(sprintf('Hash type %s is not supported', $type));
break;
}
}
View
16 libraries/joomla/data/data.php
@@ -17,7 +17,7 @@
* @subpackage Data
* @since 12.3
*/
-class JData implements JDataDumpable, IteratorAggregate, JsonSerializable, Countable
+class JData implements JDataDumpable, \IteratorAggregate, \JsonSerializable, \Countable
{
/**
* The data properties.
@@ -130,11 +130,11 @@ public function bind($properties, $updateNulls = true)
// Check the properties data type.
if (!is_array($properties) && !is_object($properties))
{
- throw new InvalidArgumentException(sprintf('%s(%s)', __METHOD__, gettype($properties)));
+ throw new \InvalidArgumentException(sprintf('%s(%s)', __METHOD__, gettype($properties)));
}
// Check if the object is traversable.
- if ($properties instanceof Traversable)
+ if ($properties instanceof \Traversable)
{
// Convert iterator to array.
$properties = iterator_to_array($properties);
@@ -174,19 +174,19 @@ public function bind($properties, $updateNulls = true)
*
* @since 12.3
*/
- public function dump($depth = 3, SplObjectStorage $dumped = null)
+ public function dump($depth = 3, \SplObjectStorage $dumped = null)
{
// Check if we should initialise the recursion tracker.
if ($dumped === null)
{
- $dumped = new SplObjectStorage;
+ $dumped = new \SplObjectStorage;
}
// Add this object to the dumped stack.
$dumped->attach($this);
// Setup a container.
- $dump = new stdClass;
+ $dump = new \stdClass;
// Dump all object properties.
foreach (array_keys($this->_properties) as $property)
@@ -210,7 +210,7 @@ public function dump($depth = 3, SplObjectStorage $dumped = null)
*/
public function getIterator()
{
- return new ArrayIterator($this->dump(0));
+ return new \ArrayIterator($this->dump(0));
}
/**
@@ -239,7 +239,7 @@ public function jsonSerialize()
*
* @since 12.3
*/
- protected function dumpProperty($property, $depth, SplObjectStorage $dumped)
+ protected function dumpProperty($property, $depth, \SplObjectStorage $dumped)
{
$value = $this->getProperty($property);
View
2  libraries/joomla/data/dumpable.php
@@ -30,5 +30,5 @@
*
* @since 12.3
*/
- public function dump($depth = 3, SplObjectStorage $dumped = null);
+ public function dump($depth = 3, \SplObjectStorage $dumped = null);
}
View
8 libraries/joomla/data/set.php
@@ -17,7 +17,7 @@
* @subpackage Data
* @since 12.3
*/
-class JDataSet implements JDataDumpable, ArrayAccess, Countable, Iterator
+class JDataSet implements JDataDumpable, \ArrayAccess, \Countable, \Iterator
{
/**
* The current position of the iterator.
@@ -226,12 +226,12 @@ public function current()
* @see JData::dump()
* @since 12.3
*/
- public function dump($depth = 3, SplObjectStorage $dumped = null)
+ public function dump($depth = 3, \SplObjectStorage $dumped = null)
{
// Check if we should initialise the recursion tracker.
if ($dumped === null)
{
- $dumped = new SplObjectStorage;
+ $dumped = new \SplObjectStorage;
}
// Add this object to the dumped stack.
@@ -371,7 +371,7 @@ public function offsetSet($offset, $object)
// Check if the object is a JData object.
if (!($object instanceof JData))
{
- throw new InvalidArgumentException(sprintf('%s("%s", *%s*)', __METHOD__, $offset, gettype($object)));
+ throw new \InvalidArgumentException(sprintf('%s("%s", *%s*)', __METHOD__, $offset, gettype($object)));
}
// Set the offset.
View
16 libraries/joomla/database/driver.php
@@ -184,7 +184,7 @@ public static function getConnectors()
$connectors = array();
// Get an iterator and loop trough the driver classes.
- $iterator = new DirectoryIterator(__DIR__ . '/driver');
+ $iterator = new \DirectoryIterator(__DIR__ . '/driver');
foreach ($iterator as $file)
{
@@ -253,7 +253,7 @@ public static function getInstance($options = array())
// If the class still doesn't exist we have nothing left to do but throw an exception. We did our best.
if (!class_exists($class))
{
- throw new RuntimeException(sprintf('Unable to load Database Driver: %s', $options['driver']));
+ throw new \RuntimeException(sprintf('Unable to load Database Driver: %s', $options['driver']));
}
// Create our new JDatabaseDriver connector based on the options given.
@@ -261,9 +261,9 @@ public static function getInstance($options = array())
{
$instance = new $class($options);
}
- catch (RuntimeException $e)
+ catch (\RuntimeException $e)
{
- throw new RuntimeException(sprintf('Unable to connect to the Database: %s', $e->getMessage()));
+ throw new \RuntimeException(sprintf('Unable to connect to the Database: %s', $e->getMessage()));
}
// Set the new connector to the global instances based on signature.
@@ -621,7 +621,7 @@ public function getExporter()
if (!class_exists($class))
{
// If it doesn't exist we are at an impasse so throw an exception.
- throw new RuntimeException('Database Exporter not found.');
+ throw new \RuntimeException('Database Exporter not found.');
}
$o = new $class;
@@ -647,7 +647,7 @@ public function getImporter()
if (!class_exists($class))
{
// If it doesn't exist we are at an impasse so throw an exception.
- throw new RuntimeException('Database Importer not found');
+ throw new \RuntimeException('Database Importer not found');
}
$o = new $class;
@@ -677,7 +677,7 @@ public function getQuery($new = false)
if (!class_exists($class))
{
// If it doesn't exist we are at an impasse so throw an exception.
- throw new RuntimeException('Database Query Class not found.');
+ throw new \RuntimeException('Database Query Class not found.');
}
return new $class($this);
@@ -708,7 +708,7 @@ public function getIterator($column = null, $class = 'stdClass')
if (!class_exists($iteratorClass))
{
// If it doesn't exist we are at an impasse so throw an exception.
- throw new RuntimeException(sprintf('class *%s* is not defined', $iteratorClass));
+ throw new \RuntimeException(sprintf('class *%s* is not defined', $iteratorClass));
}
// Return a new iterator
View
14 libraries/joomla/database/driver/mysql.php
@@ -78,13 +78,13 @@ public function connect()
// Make sure the MySQL extension for PHP is installed and enabled.
if (!function_exists('mysql_connect'))
{
- throw new RuntimeException('Could not connect to MySQL.');
+ throw new \RuntimeException('Could not connect to MySQL.');
}
// Attempt to connect to the server.
if (!($this->connection = @ mysql_connect($this->options['host'], $this->options['user'], $this->options['password'], true)))
{
- throw new RuntimeException('Could not connect to MySQL.');
+ throw new \RuntimeException('Could not connect to MySQL.');
}
// Set sql_mode to non_strict mode
@@ -241,7 +241,7 @@ public function execute()
if (!is_resource($this->connection))
{
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'database');
- throw new RuntimeException($this->errorMsg, $this->errorNum);
+ throw new \RuntimeException($this->errorMsg, $this->errorNum);
}
// Take a local copy so that we don't modify the original query and cause issues later
@@ -284,7 +284,7 @@ public function execute()
$this->connect();
}
// If connect fails, ignore that exception and throw the normal exception.
- catch (RuntimeException $e)
+ catch (\RuntimeException $e)
{
// Get the error number and message.
$this->errorNum = (int) mysql_errno($this->connection);
@@ -292,7 +292,7 @@ public function execute()
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'databasequery');
- throw new RuntimeException($this->errorMsg, $this->errorNum);
+ throw new \RuntimeException($this->errorMsg, $this->errorNum);
}
// Since we were able to reconnect, run the query again.
@@ -307,7 +307,7 @@ public function execute()
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'databasequery');
- throw new RuntimeException($this->errorMsg, $this->errorNum);
+ throw new \RuntimeException($this->errorMsg, $this->errorNum);
}
}
@@ -335,7 +335,7 @@ public function select($database)
if (!mysql_select_db($database, $this->connection))
{
- throw new RuntimeException('Could not connect to database');
+ throw new \RuntimeException('Could not connect to database');
}
return true;
View
14 libraries/joomla/database/driver/mysqli.php
@@ -134,7 +134,7 @@ public function connect()
// Make sure the MySQLi extension for PHP is installed and enabled.
if (!function_exists('mysqli_connect'))
{
- throw new RuntimeException('The MySQL adapter mysqli is not available');
+ throw new \RuntimeException('The MySQL adapter mysqli is not available');
}
$this->connection = @mysqli_connect(
@@ -144,7 +144,7 @@ public function connect()
// Attempt to connect to the server.
if (!$this->connection)
{
- throw new RuntimeException('Could not connect to MySQL.');
+ throw new \RuntimeException('Could not connect to MySQL.');
}
// Set sql_mode to non_strict mode
@@ -475,7 +475,7 @@ public function execute()
if (!is_object($this->connection))
{
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'database');
- throw new RuntimeException($this->errorMsg, $this->errorNum);
+ throw new \RuntimeException($this->errorMsg, $this->errorNum);
}
// Take a local copy so that we don't modify the original query and cause issues later
@@ -521,10 +521,10 @@ public function execute()
$this->connect();
}
// If connect fails, ignore that exception and throw the normal exception.
- catch (RuntimeException $e)
+ catch (\RuntimeException $e)
{
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'databasequery');
- throw new RuntimeException($this->errorMsg, $this->errorNum);
+ throw new \RuntimeException($this->errorMsg, $this->errorNum);
}
// Since we were able to reconnect, run the query again.
@@ -534,7 +534,7 @@ public function execute()
else
{
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'databasequery');
- throw new RuntimeException($this->errorMsg, $this->errorNum);
+ throw new \RuntimeException($this->errorMsg, $this->errorNum);
}
}
@@ -582,7 +582,7 @@ public function select($database)
if (!mysqli_select_db($this->connection, $database))
{
- throw new RuntimeException('Could not connect to database.');
+ throw new \RuntimeException('Could not connect to database.');
}
return true;
View
2  libraries/joomla/database/driver/oracle.php
@@ -519,7 +519,7 @@ public function unlockTables()
*/
public static function isSupported()
{
- return class_exists('PDO') && in_array('oci', PDO::getAvailableDrivers());
+ return class_exists('PDO') && in_array('oci', \PDO::getAvailableDrivers());
@realityking Collaborator

Shouldn't this be class_exists('\PDO')?

@dongilbert Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
}
/**
View
50 libraries/joomla/database/driver/pdo.php
@@ -112,7 +112,7 @@ public function connect()
// Make sure the PDO extension for PHP is installed and enabled.
if (!self::isSupported())
{
- throw new RuntimeException('PDO Extension is not available.', 1);
+ throw new \RuntimeException('PDO Extension is not available.', 1);
}
// Initialize the connection string variable:
@@ -294,9 +294,9 @@ public function connect()
$this->options['driverOptions']
);
}
- catch (PDOException $e)
+ catch (\PDOException $e)
{
- throw new RuntimeException('Could not connect to PDO' . ': ' . $e->getMessage(), 2, $e);
+ throw new \RuntimeException('Could not connect to PDO' . ': ' . $e->getMessage(), 2, $e);
}
}
@@ -362,7 +362,7 @@ public function execute()
if (!is_object($this->connection))
{
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'database');
- throw new RuntimeException($this->errorMsg, $this->errorNum);
+ throw new \RuntimeException($this->errorMsg, $this->errorNum);
}
// Take a local copy so that we don't modify the original query and cause issues later
@@ -393,7 +393,7 @@ public function execute()
// Execute the query.
$this->executed = false;
- if ($this->prepared instanceof PDOStatement)
+ if ($this->prepared instanceof \PDOStatement)
{
// Bind the variables:
if ($this->sql instanceof JDatabaseQueryPreparable)
@@ -426,7 +426,7 @@ public function execute()
$this->connect();
}
// If connect fails, ignore that exception and throw the normal exception.
- catch (RuntimeException $e)
+ catch (\RuntimeException $e)
{
// Get the error number and message.
$this->errorNum = (int) $this->connection->errorCode();
@@ -434,7 +434,7 @@ public function execute()
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'databasequery');
- throw new RuntimeException($this->errorMsg, $this->errorNum);
+ throw new \RuntimeException($this->errorMsg, $this->errorNum);
}
// Since we were able to reconnect, run the query again.
@@ -449,7 +449,7 @@ public function execute()
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'databasequery');
- throw new RuntimeException($this->errorMsg, $this->errorNum);
+ throw new \RuntimeException($this->errorMsg, $this->errorNum);
}
}
@@ -584,7 +584,7 @@ public function getAffectedRows()
{
$this->connect();
- if ($this->prepared instanceof PDOStatement)
+ if ($this->prepared instanceof \PDOStatement)
{
return $this->prepared->rowCount();
}
@@ -607,11 +607,11 @@ public function getNumRows($cursor = null)
{
$this->connect();
- if ($cursor instanceof PDOStatement)
+ if ($cursor instanceof \PDOStatement)
{
return $cursor->rowCount();
}
- elseif ($this->prepared instanceof PDOStatement)
+ elseif ($this->prepared instanceof \PDOStatement)
{
return $this->prepared->rowCount();
}
@@ -781,13 +781,13 @@ public function transactionStart($asSavepoint = false)
*/
protected function fetchArray($cursor = null)
{
- if (!empty($cursor) && $cursor instanceof PDOStatement)
+ if (!empty($cursor) && $cursor instanceof \PDOStatement)
{
- return $cursor->fetch(PDO::FETCH_NUM);
+ return $cursor->fetch(\PDO::FETCH_NUM);
}
- if ($this->prepared instanceof PDOStatement)
+ if ($this->prepared instanceof \PDOStatement)
{
- return $this->prepared->fetch(PDO::FETCH_NUM);
+ return $this->prepared->fetch(\PDO::FETCH_NUM);
}
}
@@ -802,13 +802,13 @@ protected function fetchArray($cursor = null)
*/
protected function fetchAssoc($cursor = null)
{
- if (!empty($cursor) && $cursor instanceof PDOStatement)
+ if (!empty($cursor) && $cursor instanceof \PDOStatement)
{
- return $cursor->fetch(PDO::FETCH_ASSOC);
+ return $cursor->fetch(\PDO::FETCH_ASSOC);
}
- if ($this->prepared instanceof PDOStatement)
+ if ($this->prepared instanceof \PDOStatement)
{
- return $this->prepared->fetch(PDO::FETCH_ASSOC);
+ return $this->prepared->fetch(\PDO::FETCH_ASSOC);
}
}
@@ -824,11 +824,11 @@ protected function fetchAssoc($cursor = null)
*/
protected function fetchObject($cursor = null, $class = 'stdClass')
{
- if (!empty($cursor) && $cursor instanceof PDOStatement)
+ if (!empty($cursor) && $cursor instanceof \PDOStatement)
{
return $cursor->fetchObject($class);
}
- if ($this->prepared instanceof PDOStatement)
+ if ($this->prepared instanceof \PDOStatement)
{
return $this->prepared->fetchObject($class);
}
@@ -847,12 +847,12 @@ protected function freeResult($cursor = null)
{
$this->executed = false;
- if ($cursor instanceof PDOStatement)
+ if ($cursor instanceof \PDOStatement)
{
$cursor->closeCursor();
$cursor = null;
}
- if ($this->prepared instanceof PDOStatement)
+ if ($this->prepared instanceof \PDOStatement)
{
$this->prepared->closeCursor();
$this->prepared = null;
@@ -971,7 +971,7 @@ public function __sleep()
{
$serializedProperties = array();
- $reflect = new ReflectionClass($this);
+ $reflect = new \ReflectionClass($this);
// Get properties of the current class
$properties = $reflect->getProperties();
@@ -979,7 +979,7 @@ public function __sleep()
foreach ($properties as $property)
{
// Do not serialize properties that are PDO
- if ($property->isStatic() == false && !($this->{$property->name} instanceof PDO))
+ if ($property->isStatic() == false && !($this->{$property->name} instanceof \PDO))
{
array_push($serializedProperties, $property->name);
}
View
16 libraries/joomla/database/driver/postgresql.php
@@ -108,7 +108,7 @@ public function connect()
// Make sure the postgresql extension for PHP is installed and enabled.
if (!function_exists('pg_connect'))
{
- throw new RuntimeException('PHP extension pg_connect is not available.');
+ throw new \RuntimeException('PHP extension pg_connect is not available.');
}
// Build the DSN for the connection.
@@ -117,7 +117,7 @@ public function connect()
// Attempt to connect to the server.
if (!($this->connection = @pg_connect($dsn)))
{
- throw new RuntimeException('Error connecting to PGSQL database.');
+ throw new \RuntimeException('Error connecting to PGSQL database.');
}
pg_set_error_verbosity($this->connection, PGSQL_ERRORS_DEFAULT);
@@ -282,7 +282,7 @@ public function getQuery($new = false, $asObj = false)
// Make sure we have a query class for this driver.
if (!class_exists('JDatabaseQueryPostgresql'))
{
- throw new RuntimeException('JDatabaseQueryPostgresql Class not found.');
+ throw new \RuntimeException('JDatabaseQueryPostgresql Class not found.');
}
$this->queryObject = new JDatabaseQueryPostgresql($this);
@@ -614,7 +614,7 @@ public function execute()
if (!is_resource($this->connection))
{
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'database');
- throw new RuntimeException($this->errorMsg, $this->errorNum);
+ throw new \RuntimeException($this->errorMsg, $this->errorNum);
}
// Take a local copy so that we don't modify the original query and cause issues later
@@ -657,7 +657,7 @@ public function execute()
$this->connect();
}
// If connect fails, ignore that exception and throw the normal exception.
- catch (RuntimeException $e)
+ catch (\RuntimeException $e)
{
// Get the error number and message.
$this->errorNum = (int) pg_result_error_field($this->cursor, PGSQL_DIAG_SQLSTATE) . ' ';
@@ -665,7 +665,7 @@ public function execute()
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'databasequery');
- throw new RuntimeException($this->errorMsg);
+ throw new \RuntimeException($this->errorMsg);
}
// Since we were able to reconnect, run the query again.
@@ -680,7 +680,7 @@ public function execute()
// Throw the normal query exception.
JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'databasequery');
- throw new RuntimeException($this->errorMsg);
+ throw new \RuntimeException($this->errorMsg);
}
}
@@ -711,7 +711,7 @@ public function renameTable($oldTable, $newTable, $backup = null, $prefix = null
if ( !in_array($oldTable, $tableList) )
{
// Origin Table not found
- throw new RuntimeException('Table not found in Postgresql database.');
+