1
0
Fork 0

Throw RuntimeException when ambiguous reference was found.

pull/2828/head
Jan Brecka 2014-03-20 13:37:05 +01:00
parent 70a20ebcc1
commit 13b57112a9
4 changed files with 32 additions and 0 deletions

View File

@ -79,6 +79,10 @@ class ClassMapGenerator
$classes = self::findClasses($filePath);
foreach ($classes as $class) {
if (array_key_exists($class, $map)) {
throw new \RuntimeException('Ambiguous reference to class "'.$class.'" was found.');
}
$map[$class] = $filePath;
}
}

View File

@ -104,6 +104,22 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
$find->invoke(null, __DIR__.'/no-file');
}
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage Ambiguous reference to class "A" was found.
*/
public function testAmbiguousReference()
{
if (!class_exists('Symfony\\Component\\Finder\\Finder')) {
$this->markTestSkipped('Finder component is not available');
}
$finder = new \Symfony\Component\Finder\Finder();
$finder->files()->in(__DIR__ . '/Fixtures/Ambiguous');
ClassMapGenerator::createMap($finder);
}
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage Could not scan for classes inside

View File

@ -0,0 +1,6 @@
<?php
class A
{
}

View File

@ -0,0 +1,6 @@
<?php
class A
{
}