8000 [DI] deprecate the `inline()` function from the PHP-DSL in favor of `… · symfony/symfony@095255d · GitHub
[go: up one dir, main page]

Skip to content

Commit 095255d

Browse files
[DI] deprecate the inline() function from the PHP-DSL in favor of service()
1 parent 168574d commit 095255d

File tree

6 files changed

+17
-2
lines changed

6 files changed

+17
-2
lines changed

UPGRADE-5.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ DependencyInjection
2424
configure them explicitly instead.
2525
* Deprecated `Definition::getDeprecationMessage()`, use `Definition::getDeprecation()` instead.
2626
* Deprecated `Alias::getDeprecationMessage()`, use `Alias::getDeprecation()` instead.
27+
* The `inline()` function from the PHP-DSL has been deprecated, use `service()` instead
2728

2829
Dotenv
2930
------

UPGRADE-6.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ DependencyInjection
2424
configure them explicitly instead.
2525
* Removed `Definition::getDeprecationMessage()`, use `Definition::getDeprecation()` instead.
2626
* Removed `Alias::getDeprecationMessage()`, use `Alias::getDeprecation()` instead.
27+
* The `inline()` function from the PHP-DSL has been removed, use `service()` instead
2728

2829
Dotenv
2930
------

src/Symfony/Component/DependencyInjection/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ CHANGELOG
1616
* added tags `container.preload`/`.no_preload` to declare extra classes to preload/services to not preload
1717
* deprecated `Definition::getDeprecationMessage()`, use `Definition::getDeprecation()` instead
1818
* deprecated `Alias::getDeprecationMessage()`, use `Alias::getDeprecation()` instead
19+
* deprecated PHP-DSL's `inline()` function, use `service()` instead
1920

2021
5.0.0
2122
-----

src/Symfony/Component/DependencyInjection/Loader/Configurator/ContainerConfigurator.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,20 @@ function ref(string $id): ReferenceConfigurator
9292

9393
/**
9494
* Creates an inline service.
95+
*
96+
* @deprecated since Symfony 5.1, use service() instead.
9597
*/
9698
function inline(string $class = null): InlineServiceConfigurator
99+
{
100+
trigger_deprecation('symfony/dependency-injection', '5.1', '"%s()" is deprecated, use "service()" instead.', __FUNCTION__);
101+
102+
return new InlineServiceConfigurator(new Definition($class));
103+
}
104+
105+
/**
106+
* Creates an inline service.
107+
*/
108+
function service(string $class = null): InlineServiceConfigurator
97109
{
98110
return new InlineServiceConfigurator(new Definition($class));
99111
}

src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/basic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
return function (ContainerConfigurator $c) {
88
$s = $c->services();
99
$s->set(BarService::class)
10-
->args([inline('FooClass')]);
10+
->args([service('FooClass')]);
1111
};

src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/object.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ public function __invoke(ContainerConfigurator $c)
99
{
1010
$s = $c->services();
1111
$s->set(BarService::class)
12-
->args([inline('FooClass')]);
12+
->args([service('FooClass')]);
1313
}
1414
};

0 commit comments

Comments
 (0)
0