Skip to content

Commit 366405b

Browse files
javiereguiluznicolas-grekas
authored andcommitted
[DI] Renamed some PHP-DSL functions
1 parent a73523b commit 366405b

File tree

15 files changed

+69
-54
lines changed

15 files changed

+69
-54
lines changed

UPGRADE-5.1.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ 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
27+
* The `inline()` function from the PHP-DSL has been deprecated, use `inline_service()` instead
28+
* The `ref()` function from the PHP-DSL has been deprecated, use `service()` instead
2829

2930
Dotenv
3031
------

UPGRADE-6.0.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ 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
27+
* The `inline()` function from the PHP-DSL has been removed, use `inline_service()` instead.
28+
* The `ref()` function from the PHP-DSL has been removed, use `service()` instead.
2829

2930
Dotenv
3031
------

src/Symfony/Component/DependencyInjection/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
5.1.0
55
-----
66

7+
* deprecated `inline()` in favor of `inline_service()` and `ref()` in favor of `service()` when using the PHP-DSL
78
* allow decorators to reference their decorated service using the special `.inner` id
89
* added support to autowire public typed properties in php 7.4
910
* added support for defining method calls, a configurator, and property setters in `InlineServiceConfigurator`

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,40 @@ final public function withPath(string $path): self
8484

8585
/**
8686
* Creates a service reference.
87+
*
88+
* @deprecated since Symfony 5.1, use service() instead.
8789
*/
8890
function ref(string $id): ReferenceConfigurator
8991
{
92+
trigger_deprecation('symfony/dependency-injection', '5.1', '"%s()" is deprecated, use "service()" instead.', __FUNCTION__);
93+
9094
return new ReferenceConfigurator($id);
9195
}
9296

97+
/**
98+
* Creates a reference to a service.
99+
*/
100+
function service(string $serviceId): ReferenceConfigurator
101+
{
102+
return new ReferenceConfigurator($serviceId);
103+
}
104+
93105
/**
94106
* Creates an inline service.
95107
*
96-
* @deprecated since Symfony 5.1, use service() instead.
108+
* @deprecated since Symfony 5.1, use inline_service() instead.
97109
*/
98110
function inline(string $class = null): InlineServiceConfigurator
99111
{
100-
trigger_deprecation('symfony/dependency-injection', '5.1', '"%s()" is deprecated, use "service()" instead.', __FUNCTION__);
112+
trigger_deprecation('symfony/dependency-injection', '5.1', '"%s()" is deprecated, use "inline_service()" instead.', __FUNCTION__);
101113

102114
return new InlineServiceConfigurator(new Definition($class));
103115
}
104116

105117
/**
106118
* Creates an inline service.
107119
*/
108-
function service(string $class = null): InlineServiceConfigurator
120+
function inline_service(string $class = null): InlineServiceConfigurator
109121
{
110122
return new InlineServiceConfigurator(new Definition($class));
111123
}

src/Symfony/Component/DependencyInjection/Loader/Configurator/Traits/FactoryTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final public function factory($factory): self
2727
if (\is_string($factory) && 1 === substr_count($factory, ':')) {
2828
$factoryParts = explode(':', $factory);
2929

30-
throw new InvalidArgumentException(sprintf('Invalid factory "%s": the "service:method" notation is not available when using PHP-based DI configuration. Use "[ref(\'%s\'), \'%s\']" instead.', $factory, $factoryParts[0], $factoryParts[1]));
30+
throw new InvalidArgumentException(sprintf('Invalid factory "%s": the "service:method" notation is not available when using PHP-based DI configuration. Use "[service(\'%s\'), \'%s\']" instead.', $factory, $factoryParts[0], $factoryParts[1]));
3131
}
3232

3333
$this->definition->setFactory(static::processValue($factory, true));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
$s->set(null, StdClassDecorator::class)
1515
->decorate('decorated', 'decorator42')
16-
->args([ref('decorator42')]);
16+
->args([service('decorator42')]);
1717

1818
$s->set('listener_aggregator', FooClass::class)->public()->args([tagged_iterator('listener')]);
1919

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()->defaults()->public();
99
$s->set(BarService::class)
10-
->args([service('FooClass')]);
10+
->args([inline_service('FooClass')]);
1111
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
->parent(BarService::class)
1616
->public()
1717
->decorate('bar', 'b', 1)
18-
->args([ref('b')])
18+
->args([service('b')])
1919
->class('Class2')
2020
->file('file.php')
2121
->parent('bar')

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
->autoconfigure()
1414
->autowire()
1515
->tag('t', ['a' => 'b'])
16-
->bind(Foo::class, ref('bar'))
16+
->bind(Foo::class, service('bar'))
1717
->public();
1818

19-
$s->set(Foo::class)->args([ref('bar')])->public();
19+
$s->set(Foo::class)->args([service('bar')])->public();
2020
$s->set('bar', Foo::class)->call('setFoo')->autoconfigure(false);
2121
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
$s = $c->services()->defaults()->public();
1010
$s->instanceof(Prototype\Foo::class)
1111
->property('p', 0)
12-
->call('setFoo', [ref('foo')])
12+
->call('setFoo', [service('foo')])
1313
->tag('tag', ['k' => 'v'])
1414
->share(false)
1515
->lazy()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy