Skip to content

Commit d79ef78

Browse files
committed
Deprecate snake-case service aliases, modernize README
The snake_case service IDs (setono_gls_webservice.client and setono_gls_webservice.factory.soap_client) are now aliases marked deprecated since 1.4 in favour of the FQCN interfaces. README usage examples updated to PHP 8 constructor promotion and PHP service config DSL.
1 parent c19a766 commit d79ef78

2 files changed

Lines changed: 22 additions & 19 deletions

File tree

README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,27 @@ use Setono\GLS\Webservice\Client\ClientInterface;
4444

4545
final class YourService
4646
{
47-
private $client;
48-
49-
public function __construct(ClientInterface $client)
47+
public function __construct(private readonly ClientInterface $client)
5048
{
51-
$this->client = $client;
5249
}
5350
}
5451
```
5552

56-
With auto wiring this will work out of the box. If you're not using auto wiring you have to inject it in your service definition:
53+
With autowiring this will work out of the box. If you're not using autowiring you have to inject it in your service definition:
5754

58-
```xml
59-
<?xml version="1.0" encoding="UTF-8" ?>
55+
```php
56+
<?php
57+
58+
use Setono\GLS\Webservice\Client\ClientInterface;
59+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
6060

61-
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
62-
<services>
63-
<service id="YourService">
64-
<argument type="service" id="Setono\GLS\Webservice\Client\ClientInterface"/>
65-
</service>
66-
</services>
67-
</container>
61+
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
6862

63+
return static function (ContainerConfigurator $container): void {
64+
$container->services()
65+
->set(YourService::class)
66+
->args([service(ClientInterface::class)]);
67+
};
6968
```
7069

7170
[ico-version]: https://poser.pugx.org/setono/gls-webservice-bundle/v/stable

src/Resources/config/services.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@
1212
return static function (ContainerConfigurator $container): void {
1313
$services = $container->services();
1414

15-
$services->set('setono_gls_webservice.factory.soap_client', SoapClientFactory::class)
15+
$services->set(SoapClientFactory::class)
1616
->args([
1717
param('setono_gls_webservice.wsdl'),
1818
param('setono_gls_webservice.options'),
1919
]);
2020

21-
$services->alias(SoapClientFactoryInterface::class, 'setono_gls_webservice.factory.soap_client');
21+
$services->alias(SoapClientFactoryInterface::class, SoapClientFactory::class);
22+
$services->alias('setono_gls_webservice.factory.soap_client', SoapClientFactoryInterface::class)
23+
->deprecate('setono/gls-webservice-bundle', '1.4', 'The "%alias_id%" service alias is deprecated. Use "' . SoapClientFactoryInterface::class . '" instead.');
2224

23-
$services->set('setono_gls_webservice.client', Client::class)
24-
->args([service('setono_gls_webservice.factory.soap_client')]);
25+
$services->set(Client::class)
26+
->args([service(SoapClientFactory::class)]);
2527

26-
$services->alias(ClientInterface::class, 'setono_gls_webservice.client');
28+
$services->alias(ClientInterface::class, Client::class);
29+
$services->alias('setono_gls_webservice.client', ClientInterface::class)
30+
->deprecate('setono/gls-webservice-bundle', '1.4', 'The "%alias_id%" service alias is deprecated. Use "' . ClientInterface::class . '" instead.');
2731
};

0 commit comments

Comments
 (0)