Skip to content

Commit db1ff46

Browse files
author
Matej Grgić
committed
refactor: Rector - TypedPropertyFromStrictConstructor rule
1 parent a63b0a3 commit db1ff46

Some content is hidden

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

51 files changed

+210
-254
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

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
7+
8+
return RectorConfig::configure()
9+
->withRules([
10+
TypedPropertyFromStrictConstructorRector::class,
11+
]);

src/Bridge/OpenApi/Model/Api.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,13 @@
1212

1313
class Api implements Contract\Api
1414
{
15-
/** @var string */
16-
private $title;
15+
private string $title;
1716

18-
/** @var string */
19-
private $version;
17+
private string $version;
2018

21-
/** @var string */
22-
private $description;
19+
private string $description;
2320

24-
/** @var null|string */
25-
private $email;
21+
private ?string $email;
2622

2723
/** @var Endpoint[] */
2824
private $endpoints = [];

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

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

1515
class CreateResourceEndpoint implements Endpoint
1616
{
17-
/** @var ReadSchema */
18-
private $readSchema;
17+
private ReadSchema $readSchema;
1918

20-
/** @var CreateSchema */
21-
private $createSchema;
19+
private CreateSchema $createSchema;
2220

23-
/** @var string */
24-
private $path;
21+
private string $path;
2522

2623
/** @var Response[] */
27-
private $responses;
24+
private array $responses;
2825

2926
/**
3027
* @param Response[] $errorResponses

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

+5-7
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@
1515

1616
class GetResourceEndpoint implements Endpoint
1717
{
18-
/** @var ReadSchema */
19-
private $readSchema;
18+
private ReadSchema $readSchema;
2019

21-
/** @var string */
22-
private $path;
20+
private string $path;
2321

2422
/** @var Response[] */
25-
private $responses;
23+
private array $responses;
2624

2725
/** @var ReadSchema[] */
28-
private $includes;
26+
private array $includes;
2927

3028
/** @var null|mixed[] */
31-
private $fields;
29+
private ?array $fields;
3230

3331
/**
3432
* @param ReadSchema[] $includes

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

+8-11
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,30 @@
1616

1717
class ResourceCollectionEndpoint implements Endpoint
1818
{
19-
/** @var ReadSchema */
20-
private $schema;
19+
private ReadSchema $schema;
2120

22-
/** @var string */
23-
private $path;
21+
private string $path;
2422

2523
/** @var Response[] */
26-
private $responses;
24+
private array $responses;
2725

2826
/** @var mixed[] */
29-
private $filters;
27+
private array $filters;
3028

3129
/** @var array<string, ReadSchema> */
32-
private $includes;
30+
private array $includes;
3331

3432
/** @var mixed[] */
35-
private $fields;
33+
private array $fields;
3634

3735
/**
3836
* @var mixed[]
3937
*
4038
* @psalm-suppress UnusedProperty
4139
*/
42-
private $sorts;
40+
private array $sorts;
4341

44-
/** @var null|Schema */
45-
private $pagination;
42+
private ?Schema $pagination;
4643

4744
/**
4845
* @param Filter[] $filters

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

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

1515
class UpdateResourceEndpoint implements Endpoint
1616
{
17-
/** @var UpdateSchema */
18-
private $resourceUpdateSchema;
17+
private UpdateSchema $resourceUpdateSchema;
1918

20-
/** @var string */
21-
private $path;
19+
private string $path;
2220

2321
/** @var Response[] */
24-
private $responses;
22+
private array $responses;
2523

2624
/**
2725
* @param Response[] $errorResponses

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99

1010
class CreateResourceRequest implements Request
1111
{
12-
/** @var string */
13-
private $resourceType;
12+
private string $resourceType;
1413

15-
/** @var ResourceSchema */
16-
private $schema;
14+
private ResourceSchema $schema;
1715

1816
public function __construct(string $resourceType, ResourceSchema $schema)
1917
{

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99

1010
class UpdateResourceRequest implements Request
1111
{
12-
/** @var string */
13-
private $resourceType;
12+
private string $resourceType;
1413

15-
/** @var UpdateSchema */
16-
private $schema;
14+
private UpdateSchema $schema;
1715

1816
public function __construct(string $resourceType, UpdateSchema $schema)
1917
{

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111

1212
class CollectionResponse implements Response
1313
{
14-
/** @var ReadSchema */
15-
private $schema;
14+
private ReadSchema $schema;
1615

1716
/** @var array<string, ReadSchema> */
18-
private $includes;
17+
private array $includes;
1918

2019
/**
2120
* @param array<string, ReadSchema> $includes

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class IncludedSchema implements Schema
1616
*
1717
* @var array<string, ReadSchema>
1818
*/
19-
private $includes;
19+
private array $includes;
2020

2121
/**
2222
* @param array<string, ReadSchema> $includes

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111

1212
class ResourceResponse implements Response
1313
{
14-
/** @var ReadSchema */
15-
private $readSchema;
14+
private ReadSchema $readSchema;
1615

1716
/** @var array<string, ReadSchema> */
18-
private $includes;
17+
private array $includes;
1918

2019
/**
2120
* @param array<string, ReadSchema> $includes

src/Bridge/OpenApi/Model/JsonApi/Schema/AttributeSchema.php

+6-12
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,17 @@
99

1010
class AttributeSchema implements Schema
1111
{
12-
/** @var string */
13-
private $name;
12+
private string $name;
1413

15-
/** @var string */
16-
private $type;
14+
private string $type;
1715

18-
/** @var bool */
19-
private $nullable;
16+
private bool $nullable;
2017

21-
/** @var null|string */
22-
private $description;
18+
private ?string $description;
2319

24-
/** @var null|string */
25-
private $format;
20+
private ?string $format;
2621

27-
/** @var null|string */
28-
private $example;
22+
private ?string $example;
2923

3024
public function __construct(
3125
string $name,

src/Bridge/OpenApi/Model/JsonApi/Schema/Filter/Filter.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@
1010

1111
final class Filter
1212
{
13-
/** @var string */
14-
private $name;
13+
private string $name;
1514

16-
/** @var Schema */
17-
private $schema;
15+
private Schema $schema;
1816

19-
/** @var bool */
20-
private $required;
17+
private bool $required;
2118

2219
public function __construct(string $name, Schema $schema, bool $required = false)
2320
{

src/Bridge/OpenApi/Model/JsonApi/Schema/Filter/FilterSetQueryParam.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88

99
class FilterSetQueryParam implements Schema
1010
{
11-
/** @var string */
12-
private $name;
11+
private string $name;
1312

1413
/** @var Filter[] */
15-
private $filters;
14+
private array $filters;
1615

1716
/**
1817
* @param Filter[] $filters

src/Bridge/OpenApi/Model/JsonApi/Schema/IntegerSchema.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88

99
class IntegerSchema implements Schema
1010
{
11-
/** @var null|int */
12-
private $example;
11+
private ?int $example;
1312

14-
/** @var null|string */
15-
private $description;
13+
private ?string $description;
1614

1715
public function __construct(?int $example, ?string $description)
1816
{

src/Bridge/OpenApi/Model/JsonApi/Schema/PathParam.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@
88

99
class PathParam implements Schema
1010
{
11-
/** @var string */
12-
private $name;
11+
private string $name;
1312

14-
/** @var bool */
15-
private $required;
13+
private bool $required;
1614

17-
/** @var string */
18-
private $description;
15+
private string $description;
1916

20-
/** @var Schema */
21-
private $schema;
17+
private Schema $schema;
2218

2319
public function __construct(string $name, bool $required, string $description, Schema $schema)
2420
{

0 commit comments

Comments
 (0)