From 314741c1eca6a6323761b3ee81dab8b07166f00a Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 4 Dec 2015 14:33:04 +0100 Subject: [PATCH 1/2] [ClassLoader] use str_replace instead of strtr --- src/Composer/Autoload/ClassLoader.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Autoload/ClassLoader.php b/src/Composer/Autoload/ClassLoader.php index 990cfdcfa..3fb935341 100644 --- a/src/Composer/Autoload/ClassLoader.php +++ b/src/Composer/Autoload/ClassLoader.php @@ -344,7 +344,7 @@ class ClassLoader private function findFileWithExtension($class, $ext) { // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + $logicalPathPsr4 = str_replace('\\', DIRECTORY_SEPARATOR, $class) . $ext; $first = $class[0]; if (isset($this->prefixLengthsPsr4[$first])) { @@ -370,10 +370,10 @@ class ClassLoader if (false !== $pos = strrpos($class, '\\')) { // namespaced class name $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + . str_replace('_', DIRECTORY_SEPARATOR, substr($logicalPathPsr4, $pos + 1)); } else { // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + $logicalPathPsr0 = str_replace('_', DIRECTORY_SEPARATOR, $class) . $ext; } if (isset($this->prefixesPsr0[$first])) { From a76ce9b25a5369c264eb281206bad2b1a5386823 Mon Sep 17 00:00:00 2001 From: Tobias Schultze Date: Fri, 4 Dec 2015 15:15:36 +0100 Subject: [PATCH 2/2] [ClassLoader] no need to call str_replace on Windows --- src/Composer/Autoload/ClassLoader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Autoload/ClassLoader.php b/src/Composer/Autoload/ClassLoader.php index 3fb935341..edca5384a 100644 --- a/src/Composer/Autoload/ClassLoader.php +++ b/src/Composer/Autoload/ClassLoader.php @@ -344,7 +344,7 @@ class ClassLoader private function findFileWithExtension($class, $ext) { // PSR-4 lookup - $logicalPathPsr4 = str_replace('\\', DIRECTORY_SEPARATOR, $class) . $ext; + $logicalPathPsr4 = ('\\' !== DIRECTORY_SEPARATOR ? str_replace('\\', DIRECTORY_SEPARATOR, $class) : $class) . $ext; $first = $class[0]; if (isset($this->prefixLengthsPsr4[$first])) {