Throw RuntimeException when ambiguous reference was found.
parent
70a20ebcc1
commit
13b57112a9
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class A
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
class A
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in New Issue