Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed an issue with lookup of namespaces in UniversalLoader #2

Closed
wants to merge 1 commit into from

1 participant

@baldurrensch

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.

@baldurrensch baldurrensch 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.
a7b7f90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 16, 2012
  1. @baldurrensch

    Fixed an issue with lookup of namespaces in UniversalLoader

    baldurrensch authored
    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.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/Opl/Autoloader/UniversalLoader.php
View
5 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();
Something went wrong with that request. Please try again.