瀏覽代碼

Merge remote-tracking branch 'henrikbjorn/validate-camelcase'

Jordi Boggiano 12 年之前
父節點
當前提交
47a8dccfb0
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      src/Composer/Command/ValidateCommand.php

+ 11 - 0
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('<info>' . $file . ' is valid</info>');