Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6a8629e

Browse files
authored
refactor #14039 [Behat] Introduce PHP 8.0 syntax (GSadee)
This PR was merged into the 1.11 branch. Discussion ---------- | Q | A | |-----------------|--------------------------------------------------------------| | Branch? | 1.11 | | Bug fix? | no | | New feature? | no | | BC breaks? | no | | Deprecations? | no | | Related tickets | based on #14038, continuation of https://github.com/Sylius/Sylius/pull/13502| | License | MIT | I've included here also [the PR](#13970) as it has been removed only from master, and now it was making the build failed on this PR <!-- - Bug fixes must be submitted against the 1.10 or 1.11 branch(the lowest possible) - Features and deprecations must be submitted against the master branch - Make sure that the correct base branch is set To be sure you are not breaking any Backward Compatibilities, check the documentation: https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html --> Commits ------- 3acaac2 [Behat] Introduce PHP 8.0 syntax cb6d604 [Behat] Fix CS after introducing PHP 8.0 syntax 204e6d5 [Behat] Fix arguments order
2 parents 3f77414 + 204e6d5 commit 6a8629e

242 files changed

Lines changed: 936 additions & 3151 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Sylius/Behat/Client/ApiClientInterface.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,15 @@ public function buildUploadRequest(): void;
5454

5555
public function setRequestData(array $data): void;
5656

57-
/** @param string|int $value */
58-
public function addParameter(string $key, $value): void;
57+
public function addParameter(string $key, int|string $value): void;
5958

60-
/** @param string|int $value */
61-
public function addFilter(string $key, $value): void;
59+
public function addFilter(string $key, int|string $value): void;
6260

6361
public function clearParameters(): void;
6462

6563
public function addFile(string $key, UploadedFile $file): void;
6664

67-
/** @param string|int|array $value */
68-
public function addRequestData(string $key, $value): void;
65+
public function addRequestData(string $key, array|int|string $value): void;
6966

7067
public function setSubResourceData(string $key, array $data): void;
7168

src/Sylius/Behat/Client/ApiPlatformClient.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,15 @@
2121

2222
final class ApiPlatformClient implements ApiClientInterface
2323
{
24-
private AbstractBrowser $client;
25-
26-
private SharedStorageInterface $sharedStorage;
27-
28-
private string $authorizationHeader;
29-
30-
private string $resource;
31-
32-
private ?string $section;
33-
3424
private ?RequestInterface $request = null;
3525

3626
public function __construct(
37-
AbstractBrowser $client,
38-
SharedStorageInterface $sharedStorage,
39-
string $authorizationHeader,
40-
string $resource,
41-
?string $section = null
27+
private AbstractBrowser $client,
28+
private SharedStorageInterface $sharedStorage,
29+
private string $authorizationHeader,
30+
private string $resource,
31+
private ?string $section = null
4232
) {
43-
$this->client = $client;
44-
$this->sharedStorage = $sharedStorage;
45-
$this->authorizationHeader = $authorizationHeader;
46-
$this->resource = $resource;
47-
$this->section = $section;
4833
}
4934

5035
public function index(): Response

src/Sylius/Behat/Client/ApiPlatformIriClient.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,11 @@
2020

2121
final class ApiPlatformIriClient implements ApiIriClientInterface
2222
{
23-
private AbstractBrowser $client;
24-
25-
private SharedStorageInterface $sharedStorage;
26-
27-
private string $authorizationHeader;
28-
2923
public function __construct(
30-
AbstractBrowser $client,
31-
SharedStorageInterface $sharedStorage,
32-
string $authorizationHeader
24+
private AbstractBrowser $client,
25+
private SharedStorageInterface $sharedStorage,
26+
private string $authorizationHeader
3327
) {
34-
$this->client = $client;
35-
$this->sharedStorage = $sharedStorage;
36-
$this->authorizationHeader = $authorizationHeader;
3728
}
3829

3930
public function showByIri(string $iri): Response

src/Sylius/Behat/Client/ApiPlatformSecurityClient.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,13 @@
1919

2020
final class ApiPlatformSecurityClient implements ApiSecurityClientInterface
2121
{
22-
private AbstractBrowser $client;
23-
24-
private string $section;
25-
26-
private SharedStorageInterface $sharedStorage;
27-
2822
private array $request = [];
2923

30-
public function __construct(AbstractBrowser $client, string $section, SharedStorageInterface $sharedStorage)
31-
{
32-
$this->client = $client;
33-
$this->section = $section;
34-
$this->sharedStorage = $sharedStorage;
24+
public function __construct(
25+
private AbstractBrowser $client,
26+
private string $section,
27+
private SharedStorageInterface $sharedStorage
28+
) {
3529
}
3630

3731
public function prepareLoginRequest(): void

src/Sylius/Behat/Client/Request.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717

1818
final class Request implements RequestInterface
1919
{
20-
private string $url;
21-
22-
private string $method;
23-
2420
private array $headers = ['HTTP_ACCEPT' => 'application/ld+json'];
2521

2622
private array $content = [];
@@ -29,10 +25,11 @@ final class Request implements RequestInterface
2925

3026
private array $files = [];
3127

32-
private function __construct(string $url, string $method, array $headers = [])
33-
{
34-
$this->url = $url;
35-
$this->method = $method;
28+
private function __construct(
29+
private string $url,
30+
private string $method,
31+
array $headers = []
32+
) {
3633
$this->headers = array_merge($this->headers, $headers);
3734
}
3835

src/Sylius/Behat/Client/ResponseCheckerInterface.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,15 @@ public function hasAccessDenied(Response $response): bool;
4343

4444
public function hasCollection(Response $response): bool;
4545

46-
/** @param string|int $value */
47-
public function hasValue(Response $response, string $key, $value): bool;
46+
public function hasValue(Response $response, string $key, int|string $value): bool;
4847

49-
/** @param string|int $value */
50-
public function hasValueInCollection(Response $response, string $key, $value): bool;
48+
public function hasValueInCollection(Response $response, string $key, int|string $value): bool;
5149

52-
/** @param string|int $value */
53-
public function hasItemWithValue(Response $response, string $key, $value): bool;
50+
public function hasItemWithValue(Response $response, string $key, int|string $value): bool;
5451

55-
/** @param string|int $value */
56-
public function hasSubResourceWithValue(Response $response, string $subResource, string $key, $value): bool;
52+
public function hasSubResourceWithValue(Response $response, string $subResource, string $key, int|string $value): bool;
5753

58-
/** @param string|array $value */
59-
public function hasItemOnPositionWithValue(Response $response, int $position, string $key, $value): bool;
54+
public function hasItemOnPositionWithValue(Response $response, int $position, string $key, array|string $value): bool;
6055

6156
public function hasItemWithTranslation(Response $response, string $locale, string $key, string $translation): bool;
6257

src/Sylius/Behat/Context/Api/Admin/AjaxContext.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,10 @@
2222

2323
final class AjaxContext implements Context
2424
{
25-
private AbstractBrowser $client;
26-
27-
private SessionInterface $session;
28-
29-
public function __construct(AbstractBrowser $client, SessionInterface $session)
30-
{
31-
$this->client = $client;
32-
$this->session = $session;
25+
public function __construct(
26+
private AbstractBrowser $client,
27+
private SessionInterface $session
28+
) {
3329
}
3430

3531
/**

src/Sylius/Behat/Context/Api/Admin/LoginContext.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@
1919

2020
final class LoginContext implements Context
2121
{
22-
private ApiSecurityClientInterface $client;
23-
24-
public function __construct(ApiSecurityClientInterface $client)
22+
public function __construct(private ApiSecurityClientInterface $client)
2523
{
26-
$this->client = $client;
2724
}
2825

2926
/**

src/Sylius/Behat/Context/Api/Admin/ManagingAdministratorsContext.php

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,14 @@
2525

2626
final class ManagingAdministratorsContext implements Context
2727
{
28-
private ApiClientInterface $client;
29-
30-
private ApiClientInterface $avatarImagesClient;
31-
32-
private ResponseCheckerInterface $responseChecker;
33-
34-
private IriConverterInterface $iriConverter;
35-
36-
private SharedStorageInterface $sharedStorage;
37-
38-
private \ArrayAccess $minkParameters;
39-
4028
public function __construct(
41-
ApiClientInterface $client,
42-
ApiClientInterface $avatarImagesClient,
43-
ResponseCheckerInterface $responseChecker,
44-
IriConverterInterface $iriConverter,
45-
SharedStorageInterface $sharedStorage,
46-
\ArrayAccess $minkParameters
29+
private ApiClientInterface $client,
30+
private ApiClientInterface $avatarImagesClient,
31+
private ResponseCheckerInterface $responseChecker,
32+
private IriConverterInterface $iriConverter,
33+
private SharedStorageInterface $sharedStorage,
34+
private \ArrayAccess $minkParameters
4735
) {
48-
$this->client = $client;
49-
$this->avatarImagesClient = $avatarImagesClient;
50-
$this->responseChecker = $responseChecker;
51-
$this->iriConverter = $iriConverter;
52-
$this->sharedStorage = $sharedStorage;
53-
$this->minkParameters = $minkParameters;
5436
}
5537

5638
/**

src/Sylius/Behat/Context/Api/Admin/ManagingCatalogPromotionsContext.php

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,13 @@
3535

3636
final class ManagingCatalogPromotionsContext implements Context
3737
{
38-
private ApiClientInterface $client;
39-
40-
private ResponseCheckerInterface $responseChecker;
41-
42-
private MessageBusInterface $messageBus;
43-
44-
private IriConverterInterface $iriConverter;
45-
46-
private SharedStorageInterface $sharedStorage;
47-
4838
public function __construct(
49-
ApiClientInterface $client,
50-
ResponseCheckerInterface $responseChecker,
51-
MessageBusInterface $messageBus,
52-
IriConverterInterface $iriConverter,
53-
SharedStorageInterface $sharedStorage
39+
private ApiClientInterface $client,
40+
private ResponseCheckerInterface $responseChecker,
41+
private MessageBusInterface $messageBus,
42+
private IriConverterInterface $iriConverter,
43+
private SharedStorageInterface $sharedStorage
5444
) {
55-
$this->client = $client;
56-
$this->responseChecker = $responseChecker;
57-
$this->messageBus = $messageBus;
58-
$this->iriConverter = $iriConverter;
59-
$this->sharedStorage = $sharedStorage;
6045
}
6146

6247
/**

0 commit comments

Comments
 (0)