8000 [DI] deprecate the `inline()` function from the PHP-DSL in favor of `service()` by nicolas-grekas · Pull Request #36388 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DI] deprecate the inline() function from the PHP-DSL in favor of service() #36388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[DI] deprecate the inline() function from the PHP-DSL in favor of `…
…service()`
  • Loading branch information
nicolas-grekas committed Apr 9, 2020
commit 647d971ae4df87a1c1b1dba86ca1cb8f6af9c905
1 change: 1 addition & 0 deletions UPGRADE-5.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ DependencyInjection
configure them explicitly instead.
* Deprecated `Definition::getDeprecationMessage()`, use `Definition::getDeprecation()` instead.
* Deprecated `Alias::getDeprecationMessage()`, use `Alias::getDeprecation()` instead.
* The `inline()` function from the PHP-DSL has been deprecated, use `service()` instead

Dotenv
------
Expand Down
1 change: 1 addition & 0 deletions UPGRADE-6.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ DependencyInjection
configure them explicitly instead.
* Removed `Definition::getDeprecationMessage()`, use `Definition::getDeprecation()` instead.
* Removed `Alias::getDeprecationMessage()`, use `Alias::getDeprecation()` instead.
* The `inline()` function from the PHP-DSL has been removed, use `service()` instead

Dotenv
------
1 change: 1 addition & 0 deletions src/Symfony/Component/DependencyInjection/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CHANGELOG
* added tags `container.preload`/`.no_preload` to declare extra classes to preload/services to not preload
* deprecated `Definition::getDeprecationMessage()`, use `Definition::getDeprecation()` instead
* deprecated `Alias::getDeprecationMessage()`, use `Alias::getDeprecation()` instead
* deprecated PHP-DSL's `inline()` function, use `service()` instead

5.0.0
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,20 @@ function ref(string $id): ReferenceConfigurator

/**
* Creates an inline service.
*
* @deprecated since Symfony 5.1, use service() instead.
*/
function inline(string $class = null): InlineServiceConfigurator
{
trigger_deprecation('symfony/dependency-injection', '5.1', '"%s()" is deprecated, use "service()" instead.', __FUNCTION__);

return new InlineServiceConfigurator(new Definition($class));
}

/**
* Creates an inline service.
*/
function service(string $class = null): InlineServiceConfigurator
{
return new InlineServiceConfigurator(new Definition($class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class InlineServiceConfigurator extends AbstractConfigurator
{
const FACTORY = 'inline';
const FACTORY = 'service';

use Traits\ArgumentTrait;
use Traits\AutowireTrait;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
return function (ContainerConfigurator $c) {
$s = $c->services();
$s->set(BarService::class)
->args([inline('FooClass')]);
->args([service('FooClass')]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public function __invoke(ContainerConfigurator $c)
{
$s = $c->services();
$s->set(BarService::class)
->args([inline('FooClass')]);
->args([service('FooClass')]);
}
};
0