1
0
Fork 0

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.
pull/870/head
Henrik Bjørnskov 2012-07-03 18:31:01 +02:00
parent 0a55707f3e
commit 0e73f3187b
1 changed files with 11 additions and 0 deletions

View File

@ -109,6 +109,17 @@ EOT
$warnings[] = 'No license specified, it is recommended to do so'; $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 // output errors/warnings
if (!$errors && !$publishErrors && !$warnings) { if (!$errors && !$publishErrors && !$warnings) {
$output->writeln('<info>' . $file . ' is valid</info>'); $output->writeln('<info>' . $file . ' is valid</info>');