Skip to content

Commit

Permalink
cs
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed May 20, 2020
1 parent 34d3e47 commit 862d4a4
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 20 deletions.
3 changes: 2 additions & 1 deletion src/DI/Extensions/ParametersExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public function loadConfiguration()

// expand all except 'services'
$slice = array_diff_key($this->compilerConfig, ['services' => 1]);
$this->compilerConfig = Nette\DI\Helpers::expand($slice, $builder->parameters) + $this->compilerConfig;
$slice = Nette\DI\Helpers::expand($slice, $builder->parameters);
$this->compilerConfig = $slice + $this->compilerConfig;
}


Expand Down
4 changes: 2 additions & 2 deletions src/DI/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ public static function filterArguments(array $args): array
} elseif (is_array($v)) {
$args[$k] = self::filterArguments($v);
} elseif ($v instanceof Statement) {
$tmp = self::filterArguments([$v->getEntity()]);
$args[$k] = new Statement($tmp[0], self::filterArguments($v->arguments));
[$tmp] = self::filterArguments([$v->getEntity()]);
$args[$k] = new Statement($tmp, self::filterArguments($v->arguments));
}
}
return $args;
Expand Down
9 changes: 6 additions & 3 deletions tests/DI/Definitions.AccessorDefinition.render.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ test(function () {
$method = $phpGenerator->generateMethod($def);

Assert::match(
'public function createServiceAbc(): Good2
<<<'XX'
public function createServiceAbc(): Good2
{
return new class ($this) implements Good2 {
private $container;
Expand All @@ -49,8 +50,10 @@ test(function () {
public function get(): stdClass
{
return $this->container->getService(\'a\');
return $this->container->getService('a');
}
};
}', $method->__toString());
}
XX
, $method->__toString());
});
9 changes: 6 additions & 3 deletions tests/DI/Definitions.ImportedDefinition.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ test(function () {
$method = $phpGenerator->generateMethod($def);

Assert::match(
'public function createServiceAbc(): void
<<<'XX'
public function createServiceAbc(): void
{
throw new Nette\DI\ServiceCreationException(\'Unable to create imported service \\\'abc\\\', it must be added using addService()\');
}', $method->__toString());
throw new Nette\DI\ServiceCreationException('Unable to create imported service \'abc\', it must be added using addService()');
}
XX
, $method->__toString());
});
11 changes: 7 additions & 4 deletions tests/DI/Definitions.LocatorDefinition.render.create.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ test(function () {
$method = $phpGenerator->generateMethod($def);

Assert::match(
'public function createServiceAbc(): Good
<<<'XX'
public function createServiceAbc(): Good
{
return new class ($this) implements Good {
private $container;%A?%
private $mapping = [\'first\' => \'a\', \'second\' => \'a\'];
private $mapping = ['first' => 'a', 'second' => 'a'];
public function __construct($container)
Expand All @@ -52,10 +53,12 @@ test(function () {
public function create($name): stdClass
{
if (!isset($this->mapping[$name])) {
throw new Nette\DI\MissingServiceException("Service \'$name\' is not defined.");
throw new Nette\DI\MissingServiceException("Service '$name' is not defined.");
}
return $this->container->createService($this->mapping[$name]);
}
};
}', $method->__toString());
}
XX
, $method->__toString());
});
11 changes: 7 additions & 4 deletions tests/DI/Definitions.LocatorDefinition.render.get.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ test(function () {
$method = $phpGenerator->generateMethod($def);

Assert::match(
'public function createServiceAbc(): Good
<<<'XX'
public function createServiceAbc(): Good
{
return new class ($this) implements Good {
private $container;%A?%
private $mapping = [\'first\' => \'a\', \'second\' => \'a\'];
private $mapping = ['first' => 'a', 'second' => 'a'];
public function __construct($container)
Expand All @@ -52,10 +53,12 @@ test(function () {
public function get($name): stdClass
{
if (!isset($this->mapping[$name])) {
throw new Nette\DI\MissingServiceException("Service \'$name\' is not defined.");
throw new Nette\DI\MissingServiceException("Service '$name' is not defined.");
}
return $this->container->getService($this->mapping[$name]);
}
};
}', $method->__toString());
}
XX
, $method->__toString());
});
9 changes: 6 additions & 3 deletions tests/DI/Definitions.LocatorDefinition.render.multi.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ test(function () {
$method = $phpGenerator->generateMethod($def);

Assert::match(
'public function createServiceAbc(): Good
<<<'XX'
public function createServiceAbc(): Good
{
return new class ($this) implements Good {
private $container;
Expand All @@ -58,8 +59,10 @@ test(function () {
public function getSecond(): ?stdClass
{
return $this->container->getService(\'a\');
return $this->container->getService('a');
}
};
}', $method->__toString());
}
XX
, $method->__toString());
});

0 comments on commit 862d4a4

Please sign in to comment.