Skip to content

Commit 2d45e53

Browse files
authored
feat: apply rule TypedPropertyFromStrictConstructor from rector (#2283)
| Q | A | |---------------|---------------------------------------------------------------------------------------------------------------------------| | Bug fix? | no | | New feature? | no | | Deprecations? | no | This apply the rule [TypedPropertyFromStrictConstructor](https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#typedpropertyfromstrictconstructorrector) over src and tests. I plan to add more PR with more rules processed
1 parent 2af8c5d commit 2d45e53

File tree

6 files changed

+14
-36
lines changed

6 files changed

+14
-36
lines changed

src/ApiDocGenerator.php

+3-6
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ final class ApiDocGenerator
3737
/** @var iterable|ModelDescriberInterface[] */
3838
private $modelDescribers;
3939

40-
/** @var CacheItemPoolInterface|null */
41-
private $cacheItemPool;
40+
private ?CacheItemPoolInterface $cacheItemPool;
4241

43-
/** @var string */
44-
private $cacheItemId;
42+
private string $cacheItemId;
4543

4644
/** @var string[] */
4745
private $alternativeNames = [];
@@ -53,8 +51,7 @@ final class ApiDocGenerator
5351
*/
5452
private $openApiVersion;
5553

56-
/** @var Generator */
57-
private $generator;
54+
private Generator $generator;
5855

5956
/**
6057
* @param DescriberInterface[]|iterable $describers

src/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,14 @@ class SymfonyConstraintAnnotationReader
2727
{
2828
use SetsContextTrait;
2929

30-
/**
31-
* @var Reader|null
32-
*/
33-
private $annotationsReader;
30+
private ?Reader $annotationsReader;
3431

3532
/**
3633
* @var OA\Schema
3734
*/
3835
private $schema;
3936

40-
/**
41-
* @var bool
42-
*/
43-
private $useValidationGroups;
37+
private bool $useValidationGroups;
4438

4539
public function __construct(?Reader $annotationsReader, bool $useValidationGroups = false)
4640
{

src/ModelDescriber/ObjectModelDescriber.php

+6-10
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,16 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar
3131
use ModelRegistryAwareTrait;
3232
use ApplyOpenApiDiscriminatorTrait;
3333

34-
/** @var PropertyInfoExtractorInterface */
35-
private $propertyInfo;
36-
/** @var ClassMetadataFactoryInterface|null */
37-
private $classMetadataFactory;
38-
/** @var Reader|null */
39-
private $doctrineReader;
34+
private PropertyInfoExtractorInterface $propertyInfo;
35+
private ?ClassMetadataFactoryInterface $classMetadataFactory;
36+
private ?Reader $doctrineReader;
4037
/** @var PropertyDescriberInterface|PropertyDescriberInterface[] */
4138
private $propertyDescriber;
4239
/** @var string[] */
43-
private $mediaTypes;
40+
private array $mediaTypes;
4441
/** @var (NameConverterInterface&AdvancedNameConverterInterface)|null */
45-
private $nameConverter;
46-
/** @var bool */
47-
private $useValidationGroups;
42+
private ?NameConverterInterface $nameConverter;
43+
private bool $useValidationGroups;
4844

4945
/**
5046
* @param PropertyDescriberInterface|PropertyDescriberInterface[] $propertyDescribers

tests/Functional/Entity/VirtualProperty80.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ class VirtualProperty80
3535
*/
3636
private $id;
3737

38-
/**
39-
* @var User
40-
*/
41-
private $user;
38+
private User $user;
4239

4340
/**
4441
* @Serializer\Accessor(getter="getFoo", setter="setFoo")

tests/Functional/Entity/VirtualProperty81.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ class VirtualProperty81
3131
#[Serializer\Expose]
3232
private $id;
3333

34-
/**
35-
* @var User
36-
*/
37-
private $user;
34+
private User $user;
3835

3936
#[Serializer\Accessor(getter: 'getFoo', setter: 'setFoo')]
4037
#[Serializer\Type('string')]

tests/Functional/ModelDescriber/NameConverter.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818

1919
class NameConverter implements AdvancedNameConverterInterface
2020
{
21-
/**
22-
* @var MetadataAwareNameConverter
23-
*/
24-
private $inner;
21+
private MetadataAwareNameConverter $inner;
2522

2623
public function __construct(MetadataAwareNameConverter $inner)
2724
{

0 commit comments

Comments
 (0)