Permalink
Browse files

Processor: names of anonymous services are just numbers

  • Loading branch information...
dg committed Oct 30, 2018
1 parent 2caae85 commit 3b3b1b53e47f7f59a1abd6ab9ec0075476443029
@@ -374,10 +374,10 @@ public function applyNamespace(array $services, string $namespace): array
private function createDefinitionName($name, array $config): string
{
if (is_int($name)) {
$factory = $config['factory'] ?? null;
$postfix = $factory instanceof Statement && is_string($factory->getEntity()) ? '.' . $factory->getEntity(
) : (is_scalar($factory) ? ".$factory" : '');
$name = (count($this->builder->getDefinitions()) + 1) . preg_replace('#\W+#', '_', $postfix);
$counter = 1;
do {
$name = (string) $counter++;
} while ($this->builder->hasDefinition($name));
} elseif (preg_match('#^@[\w\\\\]+\z#', $name)) {
$name = $this->builder->getByType(substr($name, 1), true);
}
@@ -14,7 +14,7 @@ Assert::throws(function () {
services:
-
');
}, Nette\InvalidStateException::class, "Service '2': Factory and type are missing in definition of service.");
}, Nette\InvalidStateException::class, "Service '1': Factory and type are missing in definition of service.");
Assert::throws(function () {
@@ -22,4 +22,4 @@ Assert::throws(function () {
setups: []
foo: bar
');
}, Nette\InvalidStateException::class, "Service '2_stdClass': Unknown key 'autowire', 'setups', 'foo' in definition of service, did you mean 'autowired', 'setup'?");
}, Nette\InvalidStateException::class, "Service '1': Unknown key 'autowire', 'setups', 'foo' in definition of service, did you mean 'autowired', 'setup'?");

0 comments on commit 3b3b1b5

Please sign in to comment.