8000 Fixing a bug where abstract classes were wired · symfony/symfony@ae3ebc2 · GitHub
[go: up one dir, main page]

Skip to content

Commit ae3ebc2

Browse files
committed
Fixing a bug where abstract classes were wired
1 parent 3646d08 commit ae3ebc2

File tree

6 files changed

+37
-2
lines changed

6 files changed

+37
-2
lines changed

src/Symfony/Component/DependencyInjection/Loader/FileLoader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ private function findClasses($namespace, $pattern)
108108
if (!$r = $this->container->getReflectionClass($class)) {
109109
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));
110110
}
111-
if (!$r->isInterface() && !$r->isTrait()) {
111+
// skip interfaces, traits, abstract classes & private constructors
112+
if ($r->isInstantiable()) {
112113
$classes[] = $class;
113114
}
114115
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub;
4+
5+
abstract class NoLoadAbstractBar
6+
{
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub;
4+
5+
interface NoLoadBarInterface
6+
{
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub;
4+
5+
class NoLoadBarPrivateConstructor
6+
{
7+
private function __construct()
8+
{
9+
}
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub;
4+
5+
trait NoLoadBarTrait
6+
{
7+
}

src/Symfony/Component/DependencyInjection/Tests/Loader/FileLoaderTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ public function testRegisterClasses()
8484

8585
$loader->registerClasses(new Definition(), 'Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\\', 'Prototype/%sub_dir%/*');
8686

87-
$this->assertTrue($container->has(Bar::class));
87+
$this->assertEquals(
88+
array('service_container', Bar::class),
89+
array_keys($container->getDefinitions())
90+
);
8891
}
8992

9093
/**

0 commit comments

Comments
 (0)
0