Skip to content

Commit

Permalink
[DI] deprecate the inline() function from the PHP-DSL in favor of `…
Browse files Browse the repository at this point in the history
…service()`
  • Loading branch information
nicolas-grekas committed Apr 9, 2020
1 parent 168574d commit 647d971
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions UPGRADE-5.1.md
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
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
------
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Component/DependencyInjection/CHANGELOG.md
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
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
Expand Up @@ -18,7 +18,7 @@
*/
class InlineServiceConfigurator extends AbstractConfigurator
{
const FACTORY = 'inline';
const FACTORY = 'service';

use Traits\ArgumentTrait;
use Traits\AutowireTrait;
Expand Down
Expand Up @@ -7,5 +7,5 @@
return function (ContainerConfigurator $c) {
$s = $c->services();
$s->set(BarService::class)
->args([inline('FooClass')]);
->args([service('FooClass')]);
};
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 comments on commit 647d971

Please sign in to comment.