Skip to content

Commit

Permalink
feat: apply rule TypedPropertyFromStrictConstructor from rector (#2283)
Browse files Browse the repository at this point in the history
| 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
  • Loading branch information
shakaran committed May 3, 2024
1 parent 2af8c5d commit 2d45e53
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 36 deletions.
9 changes: 3 additions & 6 deletions src/ApiDocGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ final class ApiDocGenerator
/** @var iterable|ModelDescriberInterface[] */
private $modelDescribers;

/** @var CacheItemPoolInterface|null */
private $cacheItemPool;
private ?CacheItemPoolInterface $cacheItemPool;

/** @var string */
private $cacheItemId;
private string $cacheItemId;

/** @var string[] */
private $alternativeNames = [];
Expand All @@ -53,8 +51,7 @@ final class ApiDocGenerator
*/
private $openApiVersion;

/** @var Generator */
private $generator;
private Generator $generator;

/**
* @param DescriberInterface[]|iterable $describers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,14 @@ class SymfonyConstraintAnnotationReader
{
use SetsContextTrait;

/**
* @var Reader|null
*/
private $annotationsReader;
private ?Reader $annotationsReader;

/**
* @var OA\Schema
*/
private $schema;

/**
* @var bool
*/
private $useValidationGroups;
private bool $useValidationGroups;

public function __construct(?Reader $annotationsReader, bool $useValidationGroups = false)
{
Expand Down
16 changes: 6 additions & 10 deletions src/ModelDescriber/ObjectModelDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,16 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar
use ModelRegistryAwareTrait;
use ApplyOpenApiDiscriminatorTrait;

/** @var PropertyInfoExtractorInterface */
private $propertyInfo;
/** @var ClassMetadataFactoryInterface|null */
private $classMetadataFactory;
/** @var Reader|null */
private $doctrineReader;
private PropertyInfoExtractorInterface $propertyInfo;
private ?ClassMetadataFactoryInterface $classMetadataFactory;
private ?Reader $doctrineReader;
/** @var PropertyDescriberInterface|PropertyDescriberInterface[] */
private $propertyDescriber;
/** @var string[] */
private $mediaTypes;
private array $mediaTypes;
/** @var (NameConverterInterface&AdvancedNameConverterInterface)|null */
private $nameConverter;
/** @var bool */
private $useValidationGroups;
private ?NameConverterInterface $nameConverter;
private bool $useValidationGroups;

/**
* @param PropertyDescriberInterface|PropertyDescriberInterface[] $propertyDescribers
Expand Down
5 changes: 1 addition & 4 deletions tests/Functional/Entity/VirtualProperty80.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ class VirtualProperty80
*/
private $id;

/**
* @var User
*/
private $user;
private User $user;

/**
* @Serializer\Accessor(getter="getFoo", setter="setFoo")
Expand Down
5 changes: 1 addition & 4 deletions tests/Functional/Entity/VirtualProperty81.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ class VirtualProperty81
#[Serializer\Expose]
private $id;

/**
* @var User
*/
private $user;
private User $user;

#[Serializer\Accessor(getter: 'getFoo', setter: 'setFoo')]
#[Serializer\Type('string')]
Expand Down
5 changes: 1 addition & 4 deletions tests/Functional/ModelDescriber/NameConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@

class NameConverter implements AdvancedNameConverterInterface
{
/**
* @var MetadataAwareNameConverter
*/
private $inner;
private MetadataAwareNameConverter $inner;

public function __construct(MetadataAwareNameConverter $inner)
{
Expand Down

0 comments on commit 2d45e53

Please sign in to comment.