Permalink
Browse files

Fixed an issue with lookup of namespaces in UniversalLoader

The problem occured when you have two namespaces, such as:
name\
named\

In this case order matters, since when you use named\foo, it will try to load name\foo which is wrong.
  • Loading branch information...
Baldur Rensch
Baldur Rensch committed Jul 16, 2012
1 parent 5dd8520 commit a7b7f900cf5b3e7899e84c550fcc7d0c00e8db70
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/Opl/Autoloader/UniversalLoader.php
@@ -194,15 +194,16 @@ public function loadClass($className)
foreach($this->namespaces as $namespace => $path)
{
- if(0 === strpos($className, $namespace))
+ if(0 === strpos($className, $namespace . $this->namespaceSeparator))
{
$rest = strrchr($className, $this->namespaceSeparator);
$replacement =
str_replace($this->namespaceSeparator, '/', substr($className, 0, strlen($className) - strlen($rest))).
str_replace(array('_', $this->namespaceSeparator), '/', $rest);
require($path.$replacement.$this->extensions[$namespace]);
+
return true;
- }
+ }
}
return false;
} // end loadClass();

0 comments on commit a7b7f90

Please sign in to comment.