Skip to content

Commit

Permalink
removed dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Feb 6, 2024
1 parent 023d506 commit 2645ec3
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 40 deletions.
8 changes: 4 additions & 4 deletions src/DI/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function isCreated(string $name): bool
* Creates new instance of the service.
* @throws MissingServiceException
*/
public function createService(string $name, array $args = []): object
public function createService(string $name): object
{
$name = $this->aliases[$name] ?? $name;
$method = self::getMethodName($name);
Expand All @@ -226,10 +226,10 @@ public function createService(string $name, array $args = []): object
throw new MissingServiceException(sprintf("Service '%s' not found.", $name));
}

$service = $this->preventDeadLock($name, function () use ($callback, $args, $method) {
$service = $this->preventDeadLock($name, function () use ($callback, $method) {
return $callback instanceof \Closure
? $callback(...$args)
: $this->$method(...$args);
? $callback()
: $this->$method();
});

if (!is_object($service)) {
Expand Down
17 changes: 0 additions & 17 deletions tests/DI/Compiler.generatedFactory.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -324,20 +324,3 @@ Assert::exception(function () {
->setImplement(Bad6::class);
$builder->complete();
}, Nette\InvalidStateException::class, "Service 'one' (type of Bad6): Cannot implement Bad6::create(): factory method parameters (\$baz) are not matching Bad5::__construct() parameters (\$xxx).");



interface Bad7
{
public function get(): stdClass;
}

Assert::exception(function () {
$builder = new DI\ContainerBuilder;
$builder->addDefinition(stdClass::class)->setCreator(stdClass::class);
$builder->addAccessorDefinition('one')
->setImplement(Bad7::class)
->setClass(stdClass::class)
->addSetup('method');
$builder->complete();
}, Nette\MemberAccessException::class, 'Call to undefined method Nette\DI\Definitions\AccessorDefinition::addSetup().');
6 changes: 0 additions & 6 deletions tests/DI/Definitions.AccessorDefinition.api.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ interface Good1
}


Assert::exception(function () {
$def = new AccessorDefinition;
$def->setType('Foo');
}, Nette\MemberAccessException::class);


Assert::exception(function () {
$def = new AccessorDefinition;
$def->setImplement('Foo');
Expand Down
6 changes: 0 additions & 6 deletions tests/DI/Definitions.FactoryDefinition.api.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ interface Good1
}


Assert::exception(function () {
$def = new FactoryDefinition;
$def->setType('Foo');
}, Nette\MemberAccessException::class);


Assert::exception(function () {
$def = new FactoryDefinition;
$def->setImplement('Foo');
Expand Down
1 change: 0 additions & 1 deletion tests/DI/Definitions.FactoryDefinition.render.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ test('', function () {
$def->setImplement(Good2::class);

$builder = new Nette\DI\ContainerBuilder;
$builder->addDefinition('a')->setType(stdClass::class);
$resolver = new Nette\DI\Resolver($builder);

$resolver->resolveDefinition($def);
Expand Down
6 changes: 0 additions & 6 deletions tests/DI/Definitions.LocatorDefinition.api.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ interface Good3
}


Assert::exception(function () {
$def = new LocatorDefinition;
$def->setType('Foo');
}, Nette\MemberAccessException::class);


Assert::exception(function () {
$def = new LocatorDefinition;
$def->setImplement('Foo');
Expand Down

0 comments on commit 2645ec3

Please sign in to comment.