Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/Loader.php')
-rw-r--r--core/Loader.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/core/Loader.php b/core/Loader.php
index c0d2d14622..fc913112e9 100644
--- a/core/Loader.php
+++ b/core/Loader.php
@@ -9,12 +9,16 @@
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
+
/**
* Piwik auto loader
*
* @package Piwik
*/
-class Piwik_Loader
+class Loader
{
// our class search path; current directory is intentionally excluded
protected static $dirs = array('/core/', '/plugins/');
@@ -42,8 +46,9 @@ class Piwik_Loader
return $class;
}
- if (!strncmp($class, 'Piwik/', 6)) {
- return substr($class, 6);
+ $vendorPrefixToRemove = 'Piwik/';
+ if (strpos($class, $vendorPrefixToRemove) === 0) {
+ return substr($class, strlen($vendorPrefixToRemove));
}
return $class;
@@ -58,8 +63,9 @@ class Piwik_Loader
public static function loadClass($class)
{
$classPath = self::getClassFileName($class);
- if ($class == 'Piwik'
- || !strncmp($class, 'Piwik', 5) /* catches Piwik_ and Piwik\ */ ) {
+ if (strpos($class, '\Piwik') === 0
+ || strpos($class, 'Piwik') === 0)
+ {
// Piwik classes are in core/ or plugins/
do {
// auto-discover class location
@@ -107,7 +113,7 @@ class Piwik_Loader
// Note: only one __autoload per PHP instance
if (function_exists('spl_autoload_register')) {
// use the SPL autoload stack
- spl_autoload_register(array('Piwik_Loader', 'autoload'));
+ spl_autoload_register(array('Piwik\Loader', 'autoload'));
// preserve any existing __autoload
if (function_exists('__autoload')) {
@@ -116,6 +122,6 @@ if (function_exists('spl_autoload_register')) {
} else {
function __autoload($class)
{
- Piwik_Loader::autoload($class);
+ Loader::autoload($class);
}
}