diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 87a6a24..0d1e486 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -66,12 +66,6 @@ parameters: count: 3 path: src/Metadata/AttributeMetadataFactory.php - - - message: '#^Property Patchlevel\\Hydrator\\Metadata\\AttributeMetadataFactory\:\:\$guesser \(Patchlevel\\Hydrator\\Guesser\\Guesser\|null\) is never assigned null so it can be removed from the property type\.$#' - identifier: property.unusedType - count: 1 - path: src/Metadata/AttributeMetadataFactory.php - - message: '#^Property Patchlevel\\Hydrator\\Metadata\\ClassMetadata\\:\:\$reflection \(ReflectionClass\\) does not accept ReflectionClass\\.$#' identifier: assign.propertyType diff --git a/src/Guesser/BuiltInGuesser.php b/src/Guesser/BuiltInGuesser.php index 51d7f47..a0c92eb 100644 --- a/src/Guesser/BuiltInGuesser.php +++ b/src/Guesser/BuiltInGuesser.php @@ -16,10 +16,10 @@ use Symfony\Component\TypeInfo\Type\BackedEnumType; use Symfony\Component\TypeInfo\Type\ObjectType; -final class BuiltInGuesser implements Guesser +final readonly class BuiltInGuesser implements Guesser { public function __construct( - private readonly bool $fallbackObjectNormalizer = true, + private bool $fallbackObjectNormalizer = true, ) { } diff --git a/src/Guesser/ChainGuesser.php b/src/Guesser/ChainGuesser.php index 9a3a54d..619afc6 100644 --- a/src/Guesser/ChainGuesser.php +++ b/src/Guesser/ChainGuesser.php @@ -7,11 +7,11 @@ use Patchlevel\Hydrator\Normalizer\Normalizer; use Symfony\Component\TypeInfo\Type\ObjectType; -final class ChainGuesser implements Guesser +final readonly class ChainGuesser implements Guesser { /** @param iterable $guessers */ public function __construct( - private readonly iterable $guessers, + private iterable $guessers, ) { } diff --git a/src/Metadata/AttributeMetadataFactory.php b/src/Metadata/AttributeMetadataFactory.php index 6fb7980..f53d6af 100644 --- a/src/Metadata/AttributeMetadataFactory.php +++ b/src/Metadata/AttributeMetadataFactory.php @@ -42,7 +42,7 @@ final class AttributeMetadataFactory implements MetadataFactory private readonly TypeResolver $typeResolver; - private readonly Guesser|null $guesser; + private readonly Guesser $guesser; public function __construct( TypeResolver|null $typeResolver = null, @@ -375,6 +375,7 @@ private function getNormalizer(ReflectionProperty $reflectionProperty): Normaliz private function findNormalizerOnProperty(ReflectionProperty $reflectionProperty): Normalizer|null { + /** @var list> $attributeReflectionList */ $attributeReflectionList = $reflectionProperty->getAttributes( Normalizer::class, ReflectionAttribute::IS_INSTANCEOF, @@ -479,6 +480,7 @@ private function findNormalizerOnClass(string $class): Normalizer|null { $reflectionClass = new ReflectionClass($class); + /** @var list> $attributes */ $attributes = $reflectionClass->getAttributes( Normalizer::class, ReflectionAttribute::IS_INSTANCEOF, diff --git a/src/Metadata/CallbackMetadata.php b/src/Metadata/CallbackMetadata.php index cd0e29e..bb577d9 100644 --- a/src/Metadata/CallbackMetadata.php +++ b/src/Metadata/CallbackMetadata.php @@ -12,10 +12,10 @@ * method: string, * } */ -final class CallbackMetadata +final readonly class CallbackMetadata { public function __construct( - private readonly ReflectionMethod $reflection, + private ReflectionMethod $reflection, ) { } diff --git a/src/Metadata/ClassMetadata.php b/src/Metadata/ClassMetadata.php index c3ead0a..4227a33 100644 --- a/src/Metadata/ClassMetadata.php +++ b/src/Metadata/ClassMetadata.php @@ -17,7 +17,7 @@ * } * @template T of object = object */ -final class ClassMetadata +final readonly class ClassMetadata { /** * @param ReflectionClass $reflection @@ -26,12 +26,12 @@ final class ClassMetadata * @param list $preExtractCallbacks */ public function __construct( - private readonly ReflectionClass $reflection, - private readonly array $properties = [], - private readonly string|null $dataSubjectIdField = null, - private readonly array $postHydrateCallbacks = [], - private readonly array $preExtractCallbacks = [], - private readonly bool|null $lazy = null, + private ReflectionClass $reflection, + private array $properties = [], + private string|null $dataSubjectIdField = null, + private array $postHydrateCallbacks = [], + private array $preExtractCallbacks = [], + private bool|null $lazy = null, ) { } diff --git a/src/Metadata/Psr16MetadataFactory.php b/src/Metadata/Psr16MetadataFactory.php index d5c86d4..603e674 100644 --- a/src/Metadata/Psr16MetadataFactory.php +++ b/src/Metadata/Psr16MetadataFactory.php @@ -6,11 +6,11 @@ use Psr\SimpleCache\CacheInterface; -final class Psr16MetadataFactory implements MetadataFactory +final readonly class Psr16MetadataFactory implements MetadataFactory { public function __construct( - private readonly MetadataFactory $metadataFactory, - private readonly CacheInterface $cache, + private MetadataFactory $metadataFactory, + private CacheInterface $cache, ) { } diff --git a/src/Metadata/Psr6MetadataFactory.php b/src/Metadata/Psr6MetadataFactory.php index ca608e5..f2cf0b5 100644 --- a/src/Metadata/Psr6MetadataFactory.php +++ b/src/Metadata/Psr6MetadataFactory.php @@ -6,11 +6,11 @@ use Psr\Cache\CacheItemPoolInterface; -final class Psr6MetadataFactory implements MetadataFactory +final readonly class Psr6MetadataFactory implements MetadataFactory { public function __construct( - private readonly MetadataFactory $metadataFactory, - private readonly CacheItemPoolInterface $cache, + private MetadataFactory $metadataFactory, + private CacheItemPoolInterface $cache, ) { } diff --git a/src/Normalizer/ArrayNormalizer.php b/src/Normalizer/ArrayNormalizer.php index c9c33be..b410f17 100644 --- a/src/Normalizer/ArrayNormalizer.php +++ b/src/Normalizer/ArrayNormalizer.php @@ -13,10 +13,10 @@ use function is_array; #[Attribute(Attribute::TARGET_PROPERTY)] -final class ArrayNormalizer implements Normalizer, TypeAwareNormalizer, HydratorAwareNormalizer +final readonly class ArrayNormalizer implements Normalizer, TypeAwareNormalizer, HydratorAwareNormalizer { public function __construct( - private readonly Normalizer $normalizer, + private Normalizer $normalizer, ) { } diff --git a/src/Normalizer/ArrayShapeNormalizer.php b/src/Normalizer/ArrayShapeNormalizer.php index 64c10eb..3bae3d4 100644 --- a/src/Normalizer/ArrayShapeNormalizer.php +++ b/src/Normalizer/ArrayShapeNormalizer.php @@ -13,11 +13,11 @@ use function is_array; #[Attribute(Attribute::TARGET_PROPERTY)] -final class ArrayShapeNormalizer implements Normalizer, TypeAwareNormalizer, HydratorAwareNormalizer +final readonly class ArrayShapeNormalizer implements Normalizer, TypeAwareNormalizer, HydratorAwareNormalizer { /** @param array $normalizerMap */ public function __construct( - private readonly array $normalizerMap, + private array $normalizerMap, ) { } diff --git a/src/Normalizer/DateTimeImmutableNormalizer.php b/src/Normalizer/DateTimeImmutableNormalizer.php index 64b65a4..c60c6ed 100644 --- a/src/Normalizer/DateTimeImmutableNormalizer.php +++ b/src/Normalizer/DateTimeImmutableNormalizer.php @@ -10,10 +10,10 @@ use function is_string; #[Attribute(Attribute::TARGET_PROPERTY)] -final class DateTimeImmutableNormalizer implements Normalizer +final readonly class DateTimeImmutableNormalizer implements Normalizer { public function __construct( - private readonly string $format = DateTimeImmutable::ATOM, + private string $format = DateTimeImmutable::ATOM, ) { } diff --git a/src/Normalizer/DateTimeNormalizer.php b/src/Normalizer/DateTimeNormalizer.php index 0beb68b..11be9f0 100644 --- a/src/Normalizer/DateTimeNormalizer.php +++ b/src/Normalizer/DateTimeNormalizer.php @@ -10,10 +10,10 @@ use function is_string; #[Attribute(Attribute::TARGET_PROPERTY)] -final class DateTimeNormalizer implements Normalizer +final readonly class DateTimeNormalizer implements Normalizer { public function __construct( - private readonly string $format = DateTime::ATOM, + private string $format = DateTime::ATOM, ) { } diff --git a/src/Normalizer/DateTimeZoneNormalizer.php b/src/Normalizer/DateTimeZoneNormalizer.php index 97f2e35..3729f89 100644 --- a/src/Normalizer/DateTimeZoneNormalizer.php +++ b/src/Normalizer/DateTimeZoneNormalizer.php @@ -10,7 +10,7 @@ use function is_string; #[Attribute(Attribute::TARGET_PROPERTY)] -final class DateTimeZoneNormalizer implements Normalizer +final readonly class DateTimeZoneNormalizer implements Normalizer { public function normalize(mixed $value): string|null {