diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index c4154fc934..58230ca180 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -1076,7 +1076,7 @@ class Application } $lev = levenshtein($subname, $parts[$i]); - if ($lev <= strlen($subname) / 3 || false !== strpos($parts[$i], $subname)) { + if ($lev <= strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) { $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev; } elseif ($exists) { $alternatives[$collectionName] += $threshold; diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 42b9d36e5c..eed6c81323 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -445,6 +445,18 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase $this->assertEquals('foo:sublong', $application->findNamespace('f:sub')); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Command "foo::bar" is not defined. + */ + public function testFindWithDoubleColonInNameThrowsException() + { + $application = new Application(); + $application->add(new \FooCommand()); + $application->add(new \Foo4Command()); + $application->find('foo::bar'); + } + public function testSetCatchExceptions() { $application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));