Skip to content

Commit

Permalink
Remove ability to get service by Reference
Browse files Browse the repository at this point in the history
  • Loading branch information
yiiliveext committed Jul 14, 2020
1 parent 7251880 commit 970fce7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 19 deletions.
6 changes: 0 additions & 6 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public function has($id): bool
*/
public function get($id)
{
$id = $this->getId($id);
if (!isset($this->instances[$id])) {
$this->instances[$id] = $this->build($id);
}
Expand Down Expand Up @@ -191,11 +190,6 @@ private function validateDefinition($definition): void
throw new InvalidConfigException('Invalid definition:' . var_export($definition, true));
}

private function getId($id): string
{
return is_string($id) ? $id : $id->getId();
}

/**
* @param string $id
*
Expand Down
13 changes: 0 additions & 13 deletions tests/Unit/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,19 +319,6 @@ public function testReferencesInArrayInDependencies(): void
$this->assertSame($container->get('engine4'), $moreEngines['more']['more']['engine4']);
}

public function testGetByReference(): void
{
$container = new Container([
'engine' => EngineMarkOne::class,
'e1' => Reference::to('engine'),
]);
$one = $container->get(Reference::to('engine'));
$two = $container->get(Reference::to('e1'));
$this->assertInstanceOf(EngineMarkOne::class, $one);
$this->assertInstanceOf(EngineMarkOne::class, $two);
$this->assertSame($one, $two);
}

public function testSameInstance(): void
{
$container = new Container([
Expand Down

0 comments on commit 970fce7

Please sign in to comment.