Fixing a bug where abstract classes were wired

This commit is contained in:
Ryan Weaver 2017-05-09 11:03:31 -04:00
parent 3646d08735
commit 5326bab10a
5 changed files with 27 additions and 2 deletions

View File

@ -108,7 +108,8 @@ abstract class FileLoader extends BaseFileLoader
if (!$r = $this->container->getReflectionClass($class)) {
throw new InvalidArgumentException(sprintf('Expected to find class "%s" in file "%s" while importing services from resource "%s", but it was not found! Check the namespace prefix used with the resource.', $class, $path, $pattern));
}
if (!$r->isInterface() && !$r->isTrait()) {
if (!$r->isInterface() && !$r->isTrait() && !$r->isAbstract()) {
$classes[] = $class;
}
}

View File

@ -0,0 +1,7 @@
<?php
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub;
abstract class NoLoadAbstractBar
{
}

View File

@ -0,0 +1,7 @@
<?php
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub;
interface NoLoadBarInterface
{
}

View File

@ -0,0 +1,7 @@
<?php
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub;
trait NoLoadBarTrait
{
}

View File

@ -84,7 +84,10 @@ class FileLoaderTest extends TestCase
$loader->registerClasses(new Definition(), 'Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\\', 'Prototype/%sub_dir%/*');
$this->assertTrue($container->has(Bar::class));
$this->assertEquals(
array('service_container', Bar::class),
array_keys($container->getDefinitions())
);
}
/**