Skip to content

Commit

Permalink
option 'dynamic' and option 'class' used instead of 'type' are deprec…
Browse files Browse the repository at this point in the history
…ated
  • Loading branch information
dg committed Dec 14, 2022
1 parent 4e01cda commit 046f89c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/DI/Extensions/DefinitionSchema.php
Expand Up @@ -127,6 +127,7 @@ public function normalize($def, Context $context)
));
}

trigger_error(sprintf("Service '%s': option '$alias' should be changed to '$original'.", end($context->path)), E_USER_DEPRECATED);
$def[$original] = $def[$alias];
unset($def[$alias]);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/DI/Compiler.services.imported.phpt
Expand Up @@ -18,7 +18,7 @@ class Service
}


$container = createContainer(new DI\Compiler, '
$container = @createContainer(new DI\Compiler, '
services:
one:
type: Service
Expand All @@ -42,7 +42,7 @@ Assert::exception(function () use ($container) {
}, Nette\DI\ServiceCreationException::class, "Unable to create imported service 'one', it must be added using addService()");


$container = createContainer(new DI\Compiler, '
$container = @createContainer(new DI\Compiler, '
services:
one:
class: Service
Expand Down
2 changes: 1 addition & 1 deletion tests/DI/DefinitionSchema.normalize.phpt
Expand Up @@ -47,7 +47,7 @@ Assert::with(DefinitionSchema::class, function () {
// aliases
Assert::same(['create' => 'val'], $schema->normalize(['class' => 'val'], $context));
Assert::same(['create' => 'val'], $schema->normalize(['factory' => 'val'], $context));
Assert::same(['imported' => 'val'], $schema->normalize(['dynamic' => 'val'], $context));
Assert::same(['imported' => 'val'], @$schema->normalize(['dynamic' => 'val'], $context)); // triggers notice

Assert::exception(function () use ($schema, $context) {
$schema->normalize(['class' => 'val', 'type' => 'val'], $context);
Expand Down

0 comments on commit 046f89c

Please sign in to comment.