From 75bf5c5642f1318423bc3f391e5e2a4d70f3ed15 Mon Sep 17 00:00:00 2001 From: Mike Gladysch Date: Mon, 7 Nov 2016 18:47:02 +0100 Subject: [PATCH] fixed #6 - wrong class map on empty 'relative to' path for map --- src/glady/Behind/ClassLoader/ClassMapGenerator.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/glady/Behind/ClassLoader/ClassMapGenerator.php b/src/glady/Behind/ClassLoader/ClassMapGenerator.php index e53b4f4..0027f55 100644 --- a/src/glady/Behind/ClassLoader/ClassMapGenerator.php +++ b/src/glady/Behind/ClassLoader/ClassMapGenerator.php @@ -68,7 +68,13 @@ public function generate($fileNamePattern = null) } $realPath = $file->getRealPath(); $realPath = str_replace("\\", '/', $realPath); - $mapPath = str_replace($me->getRelativeToPath() . '/', '', $realPath); + $relativeToPath = $me->getRelativeToPath(); + if (!empty($relativeToPath) && strpos($realPath, $relativeToPath . '/') === 0) { + $mapPath = substr($realPath, strlen($relativeToPath) + 1); + } + else { + $mapPath = $realPath; + } $map[$class] = $mapPath; if (!$me->acceptsMultipleClassesPerFile()) { return;