Skip to content

Commit 71dcf8b

Browse files
authored
Merge pull request #30 from undabot/fix/tests_correction
Fix/tests correction & rector upgrade to php 8.3
2 parents a63b0a3 + ba7ac55 commit 71dcf8b

File tree

90 files changed

+361
-803
lines changed

Some content is hidden

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

90 files changed

+361
-803
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"phpstan/extension-installer": "^1.3",
2626
"phpstan/phpstan": "^1.10",
2727
"phpstan/phpstan-beberlei-assert": "^1.1",
28-
"thecodingmachine/phpstan-strict-rules": "^1.0"
28+
"thecodingmachine/phpstan-strict-rules": "^1.0",
29+
"rector/rector": "^1.0"
2930
},
3031
"autoload": {
3132
"psr-4": {

composer.lock

+60-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rector.php

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
7+
return RectorConfig::configure()
8+
->withPaths([
9+
__DIR__ . '/src',
10+
__DIR__ . '/tests',
11+
])
12+
->withPhpSets(true)
13+
->withRules([
14+
]);

src/Bridge/OpenApi/Model/Api.php

+1-23
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@
1212

1313
class Api implements Contract\Api
1414
{
15-
/** @var string */
16-
private $title;
17-
18-
/** @var string */
19-
private $version;
20-
21-
/** @var string */
22-
private $description;
23-
24-
/** @var null|string */
25-
private $email;
26-
2715
/** @var Endpoint[] */
2816
private $endpoints = [];
2917

@@ -34,17 +22,7 @@ class Api implements Contract\Api
3422
private $schemas = [];
3523

3624
/** @todo add support for security schemas */
37-
public function __construct(
38-
string $title,
39-
string $version,
40-
string $description,
41-
?string $email = null
42-
) {
43-
$this->title = $title;
44-
$this->version = $version;
45-
$this->description = $description;
46-
$this->email = $email;
47-
}
25+
public function __construct(private string $title, private string $version, private string $description, private ?string $email = null) {}
4826

4927
public function addEndpoint(Endpoint $endpoint): void
5028
{

src/Bridge/OpenApi/Model/JsonApi/Endpoint/CreateResourceEndpoint.php

+4-17
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,18 @@
1414

1515
class CreateResourceEndpoint implements Endpoint
1616
{
17-
/** @var ReadSchema */
18-
private $readSchema;
19-
20-
/** @var CreateSchema */
21-
private $createSchema;
22-
23-
/** @var string */
24-
private $path;
25-
2617
/** @var Response[] */
27-
private $responses;
18+
private array $responses;
2819

2920
/**
3021
* @param Response[] $errorResponses
3122
*/
3223
public function __construct(
33-
ReadSchema $readSchema,
34-
CreateSchema $createSchema,
35-
string $path,
24+
private ReadSchema $readSchema,
25+
private CreateSchema $createSchema,
26+
private string $path,
3627
array $errorResponses = []
3728
) {
38-
$this->createSchema = $createSchema;
39-
$this->readSchema = $readSchema;
40-
$this->path = $path;
41-
4229
$this->responses = array_merge(
4330
[
4431
new ResourceCreatedResponse($this->readSchema),

src/Bridge/OpenApi/Model/JsonApi/Endpoint/GetResourceEndpoint.php

+5-17
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,25 @@
1515

1616
class GetResourceEndpoint implements Endpoint
1717
{
18-
/** @var ReadSchema */
19-
private $readSchema;
20-
21-
/** @var string */
22-
private $path;
23-
2418
/** @var Response[] */
25-
private $responses;
19+
private array $responses;
2620

2721
/** @var ReadSchema[] */
28-
private $includes;
29-
30-
/** @var null|mixed[] */
31-
private $fields;
22+
private array $includes;
3223

3324
/**
3425
* @param ReadSchema[] $includes
3526
* @param null|mixed[] $fields
3627
* @param mixed[] $errorResponses
3728
*/
3829
public function __construct(
39-
ReadSchema $readSchema,
40-
string $path,
30+
private ReadSchema $readSchema,
31+
private string $path,
4132
array $includes,
42-
?array $fields,
33+
private ?array $fields,
4334
array $errorResponses = []
4435
) {
4536
Assertion::allIsInstanceOf($includes, ReadSchema::class);
46-
$this->readSchema = $readSchema;
47-
$this->path = $path;
4837
$this->includes = $includes;
4938

5039
/** @var Response[] $mergedResponses */
@@ -53,7 +42,6 @@ public function __construct(
5342
], $errorResponses);
5443

5544
$this->responses = $mergedResponses;
56-
$this->fields = $fields;
5745
}
5846

5947
public function getMethod(): string

src/Bridge/OpenApi/Model/JsonApi/Endpoint/ResourceCollectionEndpoint.php

+14-41
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,29 @@
1616

1717
class ResourceCollectionEndpoint implements Endpoint
1818
{
19-
/** @var ReadSchema */
20-
private $schema;
21-
22-
/** @var string */
23-
private $path;
24-
2519
/** @var Response[] */
26-
private $responses;
27-
28-
/** @var mixed[] */
29-
private $filters;
30-
31-
/** @var array<string, ReadSchema> */
32-
private $includes;
33-
34-
/** @var mixed[] */
35-
private $fields;
36-
37-
/**
38-
* @var mixed[]
39-
*
40-
* @psalm-suppress UnusedProperty
41-
*/
42-
private $sorts;
43-
44-
/** @var null|Schema */
45-
private $pagination;
20+
private array $responses;
4621

4722
/**
4823
* @param Filter[] $filters
4924
* @param array<string, ReadSchema> $includes
5025
*/
5126
public function __construct(
52-
ReadSchema $schema,
53-
string $path,
54-
array $filters = [],
55-
array $sorts = [],
56-
array $includes = [],
57-
array $fields = [],
58-
?Schema $pagination = null,
27+
private ReadSchema $schema,
28+
private string $path,
29+
private array $filters = [],
30+
/**
31+
* @var mixed[]
32+
*
33+
* @psalm-suppress UnusedProperty
34+
*/
35+
private array $sorts = [],
36+
private array $includes = [],
37+
/** @var mixed[] */
38+
private array $fields = [],
39+
private ?Schema $pagination = null,
5940
array $errorResponses = []
6041
) {
61-
$this->schema = $schema;
62-
$this->path = $path;
63-
$this->includes = $includes;
64-
6542
Assertion::allIsInstanceOf($this->includes, ReadSchema::class);
6643

6744
/** @var Response[] $responses */
@@ -73,10 +50,6 @@ public function __construct(
7350
);
7451

7552
$this->responses = $responses;
76-
$this->filters = $filters;
77-
$this->sorts = $sorts;
78-
$this->fields = $fields;
79-
$this->pagination = $pagination;
8053
}
8154

8255
public function getMethod(): string

src/Bridge/OpenApi/Model/JsonApi/Endpoint/UpdateResourceEndpoint.php

+3-12
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,18 @@
1414

1515
class UpdateResourceEndpoint implements Endpoint
1616
{
17-
/** @var UpdateSchema */
18-
private $resourceUpdateSchema;
19-
20-
/** @var string */
21-
private $path;
22-
2317
/** @var Response[] */
24-
private $responses;
18+
private array $responses;
2519

2620
/**
2721
* @param Response[] $errorResponses
2822
*/
2923
public function __construct(
3024
ReadSchema $resourceReadSchema,
31-
UpdateSchema $resourceUpdateSchema,
32-
string $path,
25+
private UpdateSchema $resourceUpdateSchema,
26+
private string $path,
3327
array $errorResponses = []
3428
) {
35-
$this->resourceUpdateSchema = $resourceUpdateSchema;
36-
$this->path = $path;
37-
3829
$this->responses = array_merge(
3930
[new ResourceUpdatedResponse($resourceReadSchema)],
4031
$errorResponses

src/Bridge/OpenApi/Model/JsonApi/Requests/CreateResourceRequest.php

+1-11
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,7 @@
99

1010
class CreateResourceRequest implements Request
1111
{
12-
/** @var string */
13-
private $resourceType;
14-
15-
/** @var ResourceSchema */
16-
private $schema;
17-
18-
public function __construct(string $resourceType, ResourceSchema $schema)
19-
{
20-
$this->resourceType = $resourceType;
21-
$this->schema = $schema;
22-
}
12+
public function __construct(private string $resourceType, private ResourceSchema $schema) {}
2313

2414
public function getContentType(): string
2515
{

src/Bridge/OpenApi/Model/JsonApi/Requests/UpdateResourceRequest.php

+1-11
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,7 @@
99

1010
class UpdateResourceRequest implements Request
1111
{
12-
/** @var string */
13-
private $resourceType;
14-
15-
/** @var UpdateSchema */
16-
private $schema;
17-
18-
public function __construct(string $resourceType, UpdateSchema $schema)
19-
{
20-
$this->resourceType = $resourceType;
21-
$this->schema = $schema;
22-
}
12+
public function __construct(private string $resourceType, private UpdateSchema $schema) {}
2313

2414
public function getContentType(): string
2515
{

src/Bridge/OpenApi/Model/JsonApi/Response/CollectionResponse.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,14 @@
1111

1212
class CollectionResponse implements Response
1313
{
14-
/** @var ReadSchema */
15-
private $schema;
16-
1714
/** @var array<string, ReadSchema> */
18-
private $includes;
15+
private array $includes;
1916

2017
/**
2118
* @param array<string, ReadSchema> $includes
2219
*/
23-
public function __construct(ReadSchema $schema, array $includes)
20+
public function __construct(private ReadSchema $schema, array $includes)
2421
{
25-
$this->schema = $schema;
2622
Assertion::allIsInstanceOf($includes, ReadSchema::class);
2723
$this->includes = $includes;
2824
}

0 commit comments

Comments
 (0)