Skip to content

Commit

Permalink
Fixed an issue with lookup of namespaces in UniversalLoader
Browse files Browse the repository at this point in the history
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 committed Jul 16, 2012
1 parent 5dd8520 commit a7b7f90
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Opl/Autoloader/UniversalLoader.php
Expand Up @@ -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();
Expand Down

0 comments on commit a7b7f90

Please sign in to comment.