From 046f89cc334ec08b6b2e04803bce011bbe6522f1 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 14 Dec 2022 01:56:14 +0100 Subject: [PATCH] option 'dynamic' and option 'class' used instead of 'type' are deprecated --- src/DI/Extensions/DefinitionSchema.php | 1 + tests/DI/Compiler.services.imported.phpt | 4 ++-- tests/DI/DefinitionSchema.normalize.phpt | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/DI/Extensions/DefinitionSchema.php b/src/DI/Extensions/DefinitionSchema.php index 1198598d5..e2f28c75b 100644 --- a/src/DI/Extensions/DefinitionSchema.php +++ b/src/DI/Extensions/DefinitionSchema.php @@ -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]); } diff --git a/tests/DI/Compiler.services.imported.phpt b/tests/DI/Compiler.services.imported.phpt index c97811f04..19cbd5815 100644 --- a/tests/DI/Compiler.services.imported.phpt +++ b/tests/DI/Compiler.services.imported.phpt @@ -18,7 +18,7 @@ class Service } -$container = createContainer(new DI\Compiler, ' +$container = @createContainer(new DI\Compiler, ' services: one: type: Service @@ -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 diff --git a/tests/DI/DefinitionSchema.normalize.phpt b/tests/DI/DefinitionSchema.normalize.phpt index dbe7b5ff4..cdd132740 100644 --- a/tests/DI/DefinitionSchema.normalize.phpt +++ b/tests/DI/DefinitionSchema.normalize.phpt @@ -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);