Skip to content

Commit

Permalink
Remove redundant dependencies from builder
Browse files Browse the repository at this point in the history
  • Loading branch information
mabar authored and Milan Felix Šulc committed Feb 25, 2019
1 parent 6988ee7 commit 115bb3b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 18 deletions.
10 changes: 0 additions & 10 deletions src/DI/Loader/AbstractContainerLoader.php
Expand Up @@ -27,14 +27,4 @@ protected function findControllers(): array
return $this->builder->findByType(IController::class);
}

/**
* @param ServiceDefinition[] $definitions
*/
protected function addDependencies(array $definitions): void
{
foreach ($definitions as $def) {
$this->builder->addDependency($def->getType());
}
}

}
3 changes: 0 additions & 3 deletions src/DI/Loader/DoctrineAnnotationLoader.php
Expand Up @@ -42,9 +42,6 @@ public function load(SchemaBuilder $builder): SchemaBuilder
// Find all controllers by type (interface, annotation)
$controllers = $this->findControllers();

// Add controllers as dependencies to DIC
$this->addDependencies($controllers);

// Iterate over all controllers
foreach ($controllers as $def) {
$type = $def->getType();
Expand Down
6 changes: 1 addition & 5 deletions tests/cases/DI/Loader/DoctrineAnnotationLoader.phpt
Expand Up @@ -18,7 +18,7 @@ use Tests\Fixtures\Controllers\InvalidGroupAnnotationController;
use Tests\Fixtures\Controllers\InvalidGroupPathAnnotationController;
use Tests\Fixtures\Controllers\PrefixedAnnotationController;

// Check if controller is found and add as dependency to DIC
// Check if controller is found
test(function (): void {
$builder = Mockery::mock(ContainerBuilder::class);
$builder->shouldReceive('findByType')
Expand All @@ -32,10 +32,6 @@ test(function (): void {
return $controllers;
});

$builder->shouldReceive('addDependency')
->once()
->with(FoobarController::class);

$loader = new DoctrineAnnotationLoader($builder);
$schemaBuilder = $loader->load(new SchemaBuilder());

Expand Down

0 comments on commit 115bb3b

Please sign in to comment.