Merge pull request #2855 from karptonite/patchambiguous

Bugfix: Don't show Ambiguous class resolution warning when not ambiguous
main
Jordi Boggiano 10 years ago
commit 321bd3e1f7

@ -84,7 +84,7 @@ class ClassMapGenerator
foreach ($classes as $class) {
if (!isset($map[$class])) {
$map[$class] = $filePath;
} elseif ($io) {
} elseif ($io && $map[$class] !== $filePath) {
$io->write(
'<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
' was found in both "'.$map[$class].'" and "'.$filePath.'", the first will be used.</warning>'

@ -133,6 +133,27 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(in_array($msg, $messages, true), $msg.' not found in expected messages ('.var_export($messages, true).')');
}
/**
* If one file has a class or interface defined more than once,
* an ambiguous reference warning should not be produced
*/
public function testUnambiguousReference()
{
$this->checkIfFinderIsAvailable();
$finder = new Finder();
$finder->files()->in(__DIR__ . '/Fixtures/Unambiguous');
$io = $this->getMockBuilder('Composer\IO\ConsoleIO')
->disableOriginalConstructor()
->getMock();
$io->expects($this->never())
->method('write');
ClassMapGenerator::createMap($finder, null, $io);
}
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage Could not scan for classes inside

@ -0,0 +1,6 @@
<?php
if (PHP_VERSION_ID < 50400) {
interface A extends Iterator, ArrayAccess { }
} else {
interface A extends Iterator, ArrayAccess, JsonSerializable { }
}
Loading…
Cancel
Save