From 0e73f3187b94f061fe79d0fd29bacfd37286f2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bj=C3=B8rnskov?= Date: Tue, 3 Jul 2012 18:31:01 +0200 Subject: [PATCH] Validate the name. If uppercase characters is found suggest a new name with all lowercase and using - as a seperator where the camelcased characters was found. --- src/Composer/Command/ValidateCommand.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Composer/Command/ValidateCommand.php b/src/Composer/Command/ValidateCommand.php index 430351b40..1b28feaab 100644 --- a/src/Composer/Command/ValidateCommand.php +++ b/src/Composer/Command/ValidateCommand.php @@ -109,6 +109,17 @@ EOT $warnings[] = 'No license specified, it is recommended to do so'; } + if (preg_match('/[A-Z]/', $manifest['name'])) { + $suggestName = preg_replace('/(([a-z])([A-Z])|([A-Z])([A-Z][a-z]))/', '\\2\\4-\\3\\5', $manifest['name']); + $suggestName = strtolower($suggestName); + + $warnings[] = sprintf( + 'Name "%s" is not valid. Name should not be camelCased. May we suggest "%s" instead?', + $manifest['name'], + $suggestName + ); + } + // output errors/warnings if (!$errors && !$publishErrors && !$warnings) { $output->writeln('' . $file . ' is valid');