From 7c1d1a1c3ab9e357b9401d95853ebe72c23b4655 Mon Sep 17 00:00:00 2001 From: Giuseppe Mazzapica Date: Wed, 9 Mar 2022 13:35:15 +0100 Subject: [PATCH] Revert "Don't calculate basePath in LibraryProperties::buildNames" This reverts commit 9b73d04b4f6af77342d161a7f2f5b5707eb6b959. --- src/Properties/LibraryProperties.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Properties/LibraryProperties.php b/src/Properties/LibraryProperties.php index b68795d..11e52df 100644 --- a/src/Properties/LibraryProperties.php +++ b/src/Properties/LibraryProperties.php @@ -79,8 +79,7 @@ public static function new(string $composerJsonFile, ?string $baseUrl = null): L $properties[self::PROP_VERSION] = $version; } - $basePath = dirname($composerJsonFile); - [$baseName, $name] = static::buildNames($composerJsonData, $composerJsonFile); + [$basePath, $baseName, $name] = static::buildNames($composerJsonData, $composerJsonFile); if (empty($properties[self::PROP_NAME])) { $properties[self::PROP_NAME] = $name; } @@ -95,11 +94,15 @@ public static function new(string $composerJsonFile, ?string $baseUrl = null): L /** * @param array $composerJsonData + * @param string $composerJsonFile * - * @return array{string, string} + * @return array{string, string, string} */ - private static function buildNames(array $composerJsonData): array + private static function buildNames(array $composerJsonData, string $composerJsonFile): array { + $composerName = (string) ($composerJsonData['name'] ?? ''); + $basePath = dirname($composerJsonFile); + $packageNamePieces = explode('/', $composerName, 2); $basename = implode('-', $packageNamePieces); // "inpsyde/foo-bar-baz" => "Inpsyde Foo Bar Baz" @@ -108,7 +111,7 @@ private static function buildNames(array $composerJsonData): array MB_CASE_TITLE ); - return [$basename, $name]; + return [$basePath, $basename, $name]; } /**