Skip to content

Commit e36eb98

Browse files
authored
Merge pull request #21 from Setono/compat-layer
Add compatibility layer with setono/client-bundle
2 parents cbd6d06 + 7b0fc9c commit e36eb98

16 files changed

Lines changed: 152 additions & 102 deletions

File tree

.github/workflows/build.yaml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ jobs:
1515
strategy:
1616
matrix:
1717
php-version:
18-
- "7.4"
18+
- "8.1"
1919

2020
dependencies:
2121
- "highest"
2222

2323
steps:
2424
- name: "Checkout"
25-
uses: "actions/checkout@v3"
25+
uses: "actions/checkout@v4"
2626

2727
- name: "Setup PHP, with composer and extensions"
2828
uses: "shivammathur/setup-php@v2"
@@ -32,7 +32,7 @@ jobs:
3232
coverage: "none"
3333

3434
- name: "Install composer dependencies"
35-
uses: "ramsey/composer-install@v2"
35+
uses: "ramsey/composer-install@v3"
3636
with:
3737
dependency-versions: "${{ matrix.dependencies }}"
3838

@@ -53,8 +53,6 @@ jobs:
5353
strategy:
5454
matrix:
5555
php-version:
56-
- "7.4"
57-
- "8.0"
5856
- "8.1"
5957
- "8.2"
6058

@@ -63,7 +61,7 @@ jobs:
6361

6462
steps:
6563
- name: "Checkout"
66-
uses: "actions/checkout@v3"
64+
uses: "actions/checkout@v4"
6765

6866
- name: "Setup PHP, with composer and extensions"
6967
uses: "shivammathur/setup-php@v2"
@@ -74,7 +72,7 @@ jobs:
7472
tools: "composer-require-checker, composer-unused"
7573

7674
- name: "Install composer dependencies"
77-
uses: "ramsey/composer-install@v2"
75+
uses: "ramsey/composer-install@v3"
7876
with:
7977
dependency-versions: "${{ matrix.dependencies }}"
8078

@@ -92,8 +90,6 @@ jobs:
9290
strategy:
9391
matrix:
9492
php-version:
95-
- "7.4"
96-
- "8.0"
9793
- "8.1"
9894
- "8.2"
9995

@@ -102,7 +98,7 @@ jobs:
10298

10399
steps:
104100
- name: "Checkout"
105-
uses: "actions/checkout@v3"
101+
uses: "actions/checkout@v4"
106102

107103
- name: "Setup PHP, with composer and extensions"
108104
uses: "shivammathur/setup-php@v2"
@@ -112,7 +108,7 @@ jobs:
112108
coverage: "none"
113109

114110
- name: "Install composer dependencies"
115-
uses: "ramsey/composer-install@v2"
111+
uses: "ramsey/composer-install@v3"
116112
with:
117113
dependency-versions: "${{ matrix.dependencies }}"
118114

@@ -127,8 +123,6 @@ jobs:
127123
strategy:
128124
matrix:
129125
php-version:
130-
- "7.4"
131-
- "8.0"
132126
- "8.1"
133127
- "8.2"
134128

@@ -137,7 +131,7 @@ jobs:
137131

138132
steps:
139133
- name: "Checkout"
140-
uses: "actions/checkout@v3"
134+
uses: "actions/checkout@v4"
141135

142136
- name: "Setup PHP, with composer and extensions"
143137
uses: "shivammathur/setup-php@v2"
@@ -147,7 +141,7 @@ jobs:
147141
coverage: "none"
148142

149143
- name: "Install composer dependencies"
150-
uses: "ramsey/composer-install@v2"
144+
uses: "ramsey/composer-install@v3"
151145
with:
152146
dependency-versions: "${{ matrix.dependencies }}"
153147

@@ -169,7 +163,7 @@ jobs:
169163

170164
steps:
171165
- name: "Checkout"
172-
uses: "actions/checkout@v3"
166+
uses: "actions/checkout@v4"
173167

174168
- name: "Setup PHP, with composer and extensions"
175169
uses: "shivammathur/setup-php@v2"
@@ -182,7 +176,7 @@ jobs:
182176
run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\""
183177

184178
- name: "Install composer dependencies"
185-
uses: "ramsey/composer-install@v2"
179+
uses: "ramsey/composer-install@v3"
186180
with:
187181
dependency-versions: "${{ matrix.dependencies }}"
188182

@@ -209,7 +203,7 @@ jobs:
209203

210204
steps:
211205
- name: "Checkout"
212-
uses: "actions/checkout@v3"
206+
uses: "actions/checkout@v4"
213207

214208
- name: "Setup PHP, with composer and extensions"
215209
uses: "shivammathur/setup-php@v2"
@@ -219,7 +213,7 @@ jobs:
219213
php-version: "${{ matrix.php-version }}"
220214

221215
- name: "Install composer dependencies"
222-
uses: "ramsey/composer-install@v2"
216+
uses: "ramsey/composer-install@v3"
223217
with:
224218
dependency-versions: "${{ matrix.dependencies }}"
225219

composer-require-checker.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"symbol-whitelist": [
3+
"Setono\\ClientBundle\\Context\\ClientContextInterface"
4+
]
5+
}

composer.json

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,28 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">=7.4",
13+
"php": ">=8.1",
14+
"composer/composer": "^2.0",
1415
"doctrine/dbal": "^2.12 || ^3.0",
1516
"setono/client-id": "^0.2",
1617
"setono/client-id-contracts": "^0.2",
17-
"symfony/config": "^5.4 || ^6.0",
18-
"symfony/dependency-injection": "^5.4 || ^6.0",
19-
"symfony/event-dispatcher": "^5.4 || ^6.0",
20-
"symfony/http-foundation": "^5.4 || ^6.0",
21-
"symfony/http-kernel": "^5.4 || ^6.0",
18+
"symfony/config": "^5.4 || ^6.0 || ^7.0",
19+
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
20+
"symfony/event-dispatcher": "^5.4 || ^6.0 || ^7.0",
21+
"symfony/http-foundation": "^5.4 || ^6.0 || ^7.0",
22+
"symfony/http-kernel": "^5.4 || ^6.0 || ^7.0",
2223
"webmozart/assert": "^1.11"
2324
},
2425
"require-dev": {
25-
"infection/infection": "^0.23.0",
26-
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
27-
"nyholm/symfony-bundle-test": "^1.7",
28-
"phpunit/phpunit": "^9.5",
29-
"psalm/plugin-phpunit": "^0.16.0",
30-
"psalm/plugin-symfony": "^2.1",
31-
"setono/code-quality-pack": "^2.4"
26+
"infection/infection": "^0.27.11",
27+
"matthiasnoback/symfony-dependency-injection-test": "^4.3 || ^5.1",
28+
"nyholm/symfony-bundle-test": "^3.0",
29+
"phpspec/prophecy-phpunit": "^2.2",
30+
"phpunit/phpunit": "^9.6",
31+
"psalm/plugin-phpunit": "^0.19",
32+
"psalm/plugin-symfony": "^5.1",
33+
"setono/client-bundle": "dev-master",
34+
"setono/code-quality-pack": "^2.7"
3235
},
3336
"prefer-stable": true,
3437
"autoload": {

ecs.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
declare(strict_types=1);
44

5-
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
6-
use Symplify\EasyCodingStandard\ValueObject\Option;
5+
use Symplify\EasyCodingStandard\Config\ECSConfig;
76

8-
return static function (ContainerConfigurator $containerConfigurator): void {
9-
$containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php');
10-
$containerConfigurator->parameters()->set(Option::PATHS, [
11-
'src', 'tests'
7+
return static function (ECSConfig $config): void {
8+
$config->import('vendor/sylius-labs/coding-standard/ecs.php');
9+
$config->paths([
10+
'src',
11+
'tests',
1212
]);
1313
};

infection.json.dist

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
},
77
"logs": {
88
"text": "php://stderr",
9-
"badge": {
10-
"branch": "master"
9+
"stryker": {
10+
"badge": "master"
1111
}
1212
},
13-
"minMsi": 100,
14-
"minCoveredMsi": 100
13+
"minMsi": 94.87,
14+
"minCoveredMsi": 97.37
1515
}

psalm.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xmlns="https://getpsalm.org/schema/config"
55
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
6+
findUnusedPsalmSuppress="false"
7+
findUnusedVariablesAndParams="false"
8+
findUnusedCode="false"
9+
findUnusedBaselineEntry="false"
610
errorLevel="1"
711
>
812
<projectFiles>

src/DependencyInjection/SetonoClientIdExtension.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Setono\ClientIdBundle\DependencyInjection;
66

7+
use Composer\InstalledVersions;
78
use Symfony\Component\Config\FileLocator;
89
use Symfony\Component\DependencyInjection\ContainerBuilder;
910
use Symfony\Component\DependencyInjection\Extension\Extension;
@@ -15,5 +16,11 @@ public function load(array $configs, ContainerBuilder $container): void
1516
{
1617
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
1718
$loader->load('services.xml');
19+
20+
if (InstalledVersions::isInstalled('setono/client-bundle', false)) {
21+
$loader->load('services/conditional/provider.xml');
22+
} else {
23+
$loader->load('services/conditional/event_listener.xml');
24+
}
1825
}
1926
}

src/Doctrine/Type/ClientIdType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Doctrine\DBAL\Types\Type;
1010
use Setono\ClientId\ClientId;
1111

12-
// todo see this https://github.com/symfony/symfony/blob/5.x/src/Symfony/Bridge/Doctrine/Types/AbstractUidType.php as an example
1312
final class ClientIdType extends Type
1413
{
1514
public const CLIENT_ID = 'client_id';
@@ -21,6 +20,7 @@ public function getName(): string
2120

2221
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
2322
{
23+
/** @psalm-suppress DeprecatedMethod */
2424
return $platform->getVarcharTypeDeclarationSQL($column);
2525
}
2626

src/EventListener/SaveClientIdSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function save(ResponseEvent $event): void
4444
$response->headers->setCookie(Cookie::create(
4545
$this->cookieName,
4646
$this->clientIdProvider->getClientId()->toString(),
47-
new \DateTime('+360 days')
47+
new \DateTime('+360 days'),
4848
));
4949
}
5050
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Setono\ClientIdBundle\Provider;
6+
7+
use Setono\ClientBundle\Context\ClientContextInterface;
8+
use Setono\ClientId\ClientId;
9+
use Setono\ClientId\Provider\ClientIdProviderInterface;
10+
11+
final class CompatibilityProvider implements ClientIdProviderInterface
12+
{
13+
private ClientContextInterface $clientContext;
14+
15+
public function __construct(ClientContextInterface $clientContext)
16+
{
17+
$this->clientContext = $clientContext;
18+
}
19+
20+
public function getClientId(): ClientId
21+
{
22+
return new ClientId($this->clientContext->getClient()->id);
23+
}
24+
}

0 commit comments

Comments
 (0)