diff --git a/src/ComposerJson.php b/src/ComposerJson.php index 6280556..4e1d48f 100644 --- a/src/ComposerJson.php +++ b/src/ComposerJson.php @@ -128,7 +128,11 @@ private function extractAutoloadPaths(string $basePath, array $autoload, bool $i } foreach ($paths as $path) { - $absolutePath = $basePath . '/' . $path; + if (Path::isAbsolute($path)) { + $absolutePath = $path; + } else { + $absolutePath = $basePath . '/' . $path; + } if (strpos($path, '*') !== false) { // https://getcomposer.org/doc/04-schema.md#classmap $globPaths = glob($absolutePath); diff --git a/tests/ComposerJsonTest.php b/tests/ComposerJsonTest.php index 96bf1b4..401e0c0 100644 --- a/tests/ComposerJsonTest.php +++ b/tests/ComposerJsonTest.php @@ -41,6 +41,7 @@ public function testComposerJson(): void realpath(__DIR__ . '/data/not-autoloaded/composer/dir2/file1.php') => false, realpath(__DIR__ . '/data/not-autoloaded/composer/dir1') => false, realpath(__DIR__ . '/data/not-autoloaded/composer/dir2') => false, + DIRECTORY_SEPARATOR . 'absolute' . DIRECTORY_SEPARATOR . 'dir' => false, ], $composerJson->autoloadPaths ); diff --git a/tests/data/not-autoloaded/composer/sample.json b/tests/data/not-autoloaded/composer/sample.json index 56a307f..ef9ce40 100644 --- a/tests/data/not-autoloaded/composer/sample.json +++ b/tests/data/not-autoloaded/composer/sample.json @@ -8,7 +8,8 @@ }, "autoload": { "classmap": [ - "dir*" + "dir*", + "/absolute/dir" ], "files": [ "dir2/file1.php"