Skip to content

Commit 7411ee9

Browse files
[TASK] Upgrade to Symfony 6.4 (#683)
With this commit, Datahub is finally upgraded to Symfony 6.4. All Symfony packages have been upgraded, along with the following key changes: UUID ---- The previously used UUID implementation provided by `ramsey/uuid` and its related packages is replaced by `symfony/uid` in order to get a tighter coupling to Symfony. Naturally, Symfony wants to store UUIDs as a binary value, which is not suitable for our use-cases as we need to search for specific UUIDs in the database via MySQL CLI. Therefore, a custom UUID Doctrine type is implemented that forces to write UUIDs as plain string values. Doctrine -------- All `doctrine/*` packages are updated to their respective latest version. The upgrade of `doctrine/dbal` to v4 brought a major change how `\DateTimeInterface` values are treated. It is now **mandatory** to set the correct instance type, either `\DateTime` or `\DateTimeImmutable` and use it consistently. OpenAPI ------- All OpenAPI annotations are migrated to PHP-native attributes. Since there is no functional Rector configuration available, this tedious migration was done manually. Message Handling ---------------- Since Symfony 6.2 it's possible to configure rate limiting to a message queue. This comes in handy for our Pretix integration as they have a rate limit we're exceeding on a regular basis. A new message queue `async_pretix` is established that now receives all messages implementing `VoucherCodeMessageInterface`, having a rate limiter configured according to Pretix's documentation.
1 parent 0eec841 commit 7411ee9

38 files changed

+102
-226
lines changed

composer.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@
4646
"psr/log": "^1.0 || ^2.0 || ^3.0"
4747
},
4848
"require-dev": {
49-
"drupol/phpermutations": "^1.3",
49+
"drupol/phpermutations": "^1.4",
5050
"friendsofphp/php-cs-fixer": "^3.16",
5151
"guzzlehttp/guzzle": "^7.0",
52-
"http-interop/http-factory-guzzle": "^1.0",
53-
"monolog/monolog": "^2.0",
54-
"phpunit/phpunit": "^10.1",
55-
"symfony/serializer": "^5.4"
52+
"http-interop/http-factory-guzzle": "^1.2",
53+
"monolog/monolog": "^3.0",
54+
"phpunit/phpunit": "^11.5",
55+
"symfony/serializer": "^5.4 || ^6.4"
5656
},
5757
"extra": {
5858
"branch-alias": {
@@ -69,6 +69,9 @@
6969
"T3G\\DatahubApiLibrary\\Tests\\": "tests/"
7070
}
7171
},
72+
"config": {
73+
"sort-packages": true
74+
},
7275
"scripts": {
7376
"t3g:cgl": [
7477
"php-cs-fixer fix --config .php-cs-fixer.dist.php -v --dry-run"

src/Demand/OrganizationSearchDemand.php

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,6 @@ class OrganizationSearchDemand implements \JsonSerializable
4646
*/
4747
private ?array $countries = null;
4848

49-
/**
50-
* @param string|null $term
51-
*
52-
* @deprecated Setting term via constructor is deprecated, use ->setTerm() instead
53-
*/
54-
public function __construct(?string $term = null)
55-
{
56-
if (null !== $term) {
57-
$this->setTerm($term);
58-
trigger_error(
59-
sprintf('Calling %s with $term is deprecated, call setTerm() instead.', __METHOD__),
60-
E_USER_DEPRECATED
61-
);
62-
}
63-
}
64-
6549
/**
6650
* @return array<string, mixed>
6751
*/
@@ -110,42 +94,6 @@ public function isWithOrders(): bool
11094
return $this->withOrders;
11195
}
11296

113-
/**
114-
* @param bool $withSubscriptions
115-
*
116-
* @return $this
117-
*
118-
* @deprecated use setSubscriptionTypes()
119-
*/
120-
public function setWithSubscriptions(bool $withSubscriptions = true): self
121-
{
122-
trigger_error(
123-
sprintf('Calling %s is deprecated, call setSubscriptionTypes() instead.', __METHOD__),
124-
E_USER_DEPRECATED
125-
);
126-
127-
if ($withSubscriptions) {
128-
$this->setSubscriptionTypes([SubscriptionType::MEMBERSHIP, SubscriptionType::PSL]);
129-
}
130-
131-
return $this;
132-
}
133-
134-
/**
135-
* @return bool
136-
*
137-
* @deprecated use getSubscriptionTypes()
138-
*/
139-
public function isWithSubscriptions(): bool
140-
{
141-
trigger_error(
142-
sprintf('Calling %s is deprecated, call getSubscriptionTypes() instead.', __METHOD__),
143-
E_USER_DEPRECATED
144-
);
145-
146-
return null !== $this->getSubscriptionTypes();
147-
}
148-
14997
/**
15098
* @param array<int, SubscriptionType::*> $subscriptionTypes
15199
*

src/Dto/Admin/CreateCompanyDto.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@
1212

1313
use Symfony\Component\Validator\Constraints as Assert;
1414
use T3G\DatahubApiLibrary\Dto\AbstractDto;
15+
use T3G\DatahubApiLibrary\Enum\CompanyType;
1516

1617
class CreateCompanyDto extends AbstractDto
1718
{
1819
/**
1920
* @Assert\NotBlank
2021
*/
22+
#[Assert\NotBlank]
2123
public string $title;
2224

2325
/**
2426
* @Assert\NotBlank
2527
*
2628
* @Assert\Choice(callback={"T3G\DatahubApiLibrary\Enum\CompanyType", "getAvailableOptions"})
2729
*/
30+
#[Assert\NotBlank]
31+
#[Assert\Choice(callback: [CompanyType::class, 'getAvailableOptions'])]
2832
public string $companyType;
2933
public ?string $owner = null;
3034
}

src/Dto/Admin/MergeCompanyDto.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class MergeCompanyDto extends AbstractDto
2323
*
2424
* @Assert\Uuid
2525
*/
26+
#[Assert\NotBlank]
27+
#[Assert\Uuid]
2628
public string $title = '';
2729

2830
/**
@@ -33,6 +35,8 @@ class MergeCompanyDto extends AbstractDto
3335
*
3436
* @Assert\Uuid
3537
*/
38+
#[Assert\NotBlank]
39+
#[Assert\Uuid]
3640
public string $slug = '';
3741

3842
/**
@@ -43,6 +47,8 @@ class MergeCompanyDto extends AbstractDto
4347
*
4448
* @Assert\Uuid
4549
*/
50+
#[Assert\NotBlank]
51+
#[Assert\Uuid]
4652
public string $companyType = '';
4753

4854
/**
@@ -53,6 +59,8 @@ class MergeCompanyDto extends AbstractDto
5359
*
5460
* @Assert\Uuid
5561
*/
62+
#[Assert\NotBlank]
63+
#[Assert\Uuid]
5664
public string $vatId = '';
5765

5866
/**
@@ -63,6 +71,8 @@ class MergeCompanyDto extends AbstractDto
6371
*
6472
* @Assert\Uuid
6573
*/
74+
#[Assert\NotBlank]
75+
#[Assert\Uuid]
6676
public string $domain = '';
6777

6878
/**
@@ -72,5 +82,6 @@ class MergeCompanyDto extends AbstractDto
7282
*
7383
* @Assert\NotBlank
7484
*/
85+
#[Assert\NotBlank]
7586
public array $emails = [];
7687
}

src/Dto/Admin/TransferEntityDto.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,34 @@
1212

1313
use Symfony\Component\Validator\Constraints as Assert;
1414
use T3G\DatahubApiLibrary\Dto\AbstractDto;
15+
use T3G\DatahubApiLibrary\Enum\TransferableType;
1516

1617
class TransferEntityDto extends AbstractDto
1718
{
1819
/**
1920
* @Assert\NotBlank
2021
*/
22+
#[Assert\NotBlank]
2123
public string $source = '';
2224

2325
/**
2426
* @Assert\NotBlank
2527
*/
28+
#[Assert\NotBlank]
2629
public string $target = '';
2730

2831
/**
2932
* @Assert\NotBlank
3033
*
3134
* @Assert\Choice(callback={"T3G\DatahubApiLibrary\Enum\TransferableType", "getAvailableOptions"})
3235
*/
36+
#[Assert\NotBlank]
37+
#[Assert\Choice(callback: [TransferableType::class, 'getAvailableOptions'])]
3338
public string $type = '';
3439

3540
/**
3641
* @Assert\NotBlank
3742
*/
43+
#[Assert\NotBlank]
3844
public string $entityDescriber = '';
3945
}

src/Dto/Admin/UpdateCompanyDto.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@
1212

1313
use Symfony\Component\Validator\Constraints as Assert;
1414
use T3G\DatahubApiLibrary\Dto\AbstractDto;
15+
use T3G\DatahubApiLibrary\Enum\CompanyType;
1516

1617
class UpdateCompanyDto extends AbstractDto
1718
{
1819
/**
1920
* @Assert\NotBlank
2021
*/
22+
#[Assert\NotBlank]
2123
public string $title;
2224

2325
/**
2426
* @Assert\NotBlank
2527
*
2628
* @Assert\Choice(callback={"T3G\DatahubApiLibrary\Enum\CompanyType", "getAvailableOptions"})
2729
*/
30+
#[Assert\NotBlank]
31+
#[Assert\Choice(callback: [CompanyType::class, 'getAvailableOptions'])]
2832
public string $companyType;
2933
public ?string $vatId = null;
3034
public ?string $domain = null;

tests/Api/CompanyApiTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public function testGetSearchCompanies(): void
119119
$handler = new MockHandler([
120120
require __DIR__ . '/../Fixtures/GetSearchCompanyResponse.php',
121121
]);
122-
$response = (new CompanyApi($this->getClient($handler)))
123-
->search(new OrganizationSearchDemand('Test Company'));
122+
$searchDemand = (new OrganizationSearchDemand())->setTerm('Test Company');
123+
$response = (new CompanyApi($this->getClient($handler)))->search($searchDemand);
124124
self::assertCount(2, $response);
125125
}
126126

tests/Api/OrderApiTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespace T3G\DatahubApiLibrary\Tests\Api;
1212

1313
use GuzzleHttp\Handler\MockHandler;
14+
use PHPUnit\Framework\Attributes\DataProvider;
1415
use Psr\Http\Client\ClientExceptionInterface;
1516
use T3G\DatahubApiLibrary\Api\OrderApi;
1617
use T3G\DatahubApiLibrary\Demand\OrderSearchDemand;
@@ -43,9 +44,8 @@ public function testGetOrder(): void
4344
* @throws \JsonException
4445
* @throws ClientExceptionInterface
4546
* @throws DatahubResponseException
46-
*
47-
* @dataProvider searchOrdersDataProvider
4847
*/
48+
#[DataProvider('searchOrdersDataProvider')]
4949
public function testSearchOrders(string $fixtureFile, ?int $limit): void
5050
{
5151
$handler = new MockHandler([

tests/Demand/OrganizationSearchDemandTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace T3G\DatahubApiLibrary\Tests\Demand;
1212

13+
use PHPUnit\Framework\Attributes\DataProvider;
1314
use PHPUnit\Framework\TestCase;
1415
use T3G\DatahubApiLibrary\Demand\OrganizationSearchDemand;
1516
use T3G\DatahubApiLibrary\Enum\SubscriptionType;
@@ -53,15 +54,12 @@ public function testNullValuesAreIgnoredFromSerialization(): void
5354
public function testWithSubscriptionsSetsValueAsExpected(): void
5455
{
5556
$demand = new OrganizationSearchDemand();
56-
$demand->setWithSubscriptions();
57+
$demand->setSubscriptionTypes([SubscriptionType::MEMBERSHIP, SubscriptionType::PSL]);
5758

58-
self::assertTrue($demand->isWithSubscriptions());
5959
self::assertSame([SubscriptionType::MEMBERSHIP, SubscriptionType::PSL], $demand->getSubscriptionTypes());
6060
}
6161

62-
/**
63-
* @dataProvider setMembersRangeAsExpectedDataProvider
64-
*/
62+
#[DataProvider('setMembersRangeAsExpectedDataProvider')]
6563
public function testSetMembersRangeAsExpected(array $input, ?array $expectation): void
6664
{
6765
$demand = new OrganizationSearchDemand();
@@ -79,9 +77,7 @@ public static function setMembersRangeAsExpectedDataProvider(): array
7977
];
8078
}
8179

82-
/**
83-
* @dataProvider setMembersRangeThrowsExceptionDataProvider
84-
*/
80+
#[DataProvider('setMembersRangeThrowsExceptionDataProvider')]
8581
public function testSetMembersRangeThrowsException(array $input, string $expectedExceptionClass, int $expectedExceptionCode): void
8682
{
8783
$this->expectException($expectedExceptionClass);

tests/Demand/SubscriptionFilterQueryTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace T3G\DatahubApiLibrary\Tests\Demand;
1212

13+
use PHPUnit\Framework\Attributes\DataProvider;
1314
use PHPUnit\Framework\TestCase;
1415
use T3G\DatahubApiLibrary\Demand\SubscriptionFilterQuery;
1516

@@ -38,9 +39,7 @@ public static function getQueryAsStringDataProvider(): array
3839
];
3940
}
4041

41-
/**
42-
* @dataProvider getQueryAsStringDataProvider
43-
*/
42+
#[DataProvider('getQueryAsStringDataProvider')]
4443
public function testGetQueryAsString(array $inputValues, string $expectedOutput): void
4544
{
4645
$subscriptionFilterQuery = new SubscriptionFilterQuery();

0 commit comments

Comments
 (0)