Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit 4773869

Browse files
committed
Finished this feature
1 parent e1de703 commit 4773869

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

src/Symfony/Installer/NewCommand.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,18 @@ protected function generateComposerProjectName()
395395
*/
396396
private function fixComposerPackageName($name)
397397
{
398-
return strtolower(
399-
preg_replace(
400-
array('~[^\w.-]~iu', '~([A-Z]+)([A-Z][a-z])~u', '~([a-z\d])([A-Z])~u'),
401-
array('', '\\1-\\2', '\\1-\\2'),
402-
strtr($name, '-', '.')
403-
)
398+
$name = str_replace(
399+
['à', 'á', 'â', 'ä', 'æ', 'ã', 'å', 'ā', 'é', 'è', 'ê', 'ë', 'ę', 'ė', 'ē', 'ī', 'į', 'í', 'ì', 'ï', 'î', 'ō', 'ø', 'œ', 'õ', 'ó', 'ò', 'ö', 'ô', 'ū', 'ú', 'ù', 'ü', 'û', 'ç', 'ć', 'č', 'ł', 'ñ', 'ń', 'ß', 'ś', 'š', 'ŵ', 'ŷ', 'ÿ', 'ź', 'ž', 'ż'],
400+
['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'i', 'i', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'u', 'c', 'c', 'c', 'l', 'n', 'n', 's', 's', 's', 'w', 'y', 'y', 'z', 'z', 'z'],
401+
$name
404402
);
403+
$name = strtr($name, '-', '.');
404+
405+
return strtolower(preg_replace(
406+
['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'],
407+
['\\1-\\2', '\\1-\\2'],
408+
$name
409+
));
405410
}
406411

407412
protected function getDownloadedApplicationType()
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Symfony\Installer\Tests;
4+
5+
use Symfony\Installer\NewCommand;
6+
7+
class NewCommandTest extends \PHPUnit_Framework_TestCase
8+
{
9+
/**
10+
* @dataProvider getProjectNames
11+
*/
12+
public function testFixComposerPackageName($originalName, $expectedName)
13+
{
14+
$command = new NewCommand();
15+
$method = new \ReflectionMethod($command, 'fixComposerPackageName');
16+
$method->setAccessible(true);
17+
18+
$fixedName = $method->invoke($command, $originalName);
19+
$this->assertSame($expectedName, $fixedName);
20+
}
21+
22+
public function getProjectNames()
23+
{
24+
return [
25+
['foobar', 'foobar'],
26+
['áèîøūñ', 'aeioun'],
27+
['çįßłŵž', 'cislwz'],
28+
];
29+
}
30+
}

0 commit comments

Comments
 (0)