Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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\<T of object \= object\>\:\:\$reflection \(ReflectionClass\<T of object \= object\>\) does not accept ReflectionClass\<object\>\.$#'
identifier: assign.propertyType
Expand Down
4 changes: 2 additions & 2 deletions src/Guesser/BuiltInGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Guesser/ChainGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<Guesser> $guessers */
public function __construct(
private readonly iterable $guessers,
private iterable $guessers,
) {
}

Expand Down
4 changes: 3 additions & 1 deletion src/Metadata/AttributeMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -375,6 +375,7 @@ private function getNormalizer(ReflectionProperty $reflectionProperty): Normaliz

private function findNormalizerOnProperty(ReflectionProperty $reflectionProperty): Normalizer|null
{
/** @var list<ReflectionAttribute<Normalizer>> $attributeReflectionList */
$attributeReflectionList = $reflectionProperty->getAttributes(
Normalizer::class,
ReflectionAttribute::IS_INSTANCEOF,
Expand Down Expand Up @@ -479,6 +480,7 @@ private function findNormalizerOnClass(string $class): Normalizer|null
{
$reflectionClass = new ReflectionClass($class);

/** @var list<ReflectionAttribute<Normalizer>> $attributes */
$attributes = $reflectionClass->getAttributes(
Normalizer::class,
ReflectionAttribute::IS_INSTANCEOF,
Expand Down
4 changes: 2 additions & 2 deletions src/Metadata/CallbackMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
* method: string,
* }
*/
final class CallbackMetadata
final readonly class CallbackMetadata
{
public function __construct(
private readonly ReflectionMethod $reflection,
private ReflectionMethod $reflection,
) {
}

Expand Down
14 changes: 7 additions & 7 deletions src/Metadata/ClassMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* }
* @template T of object = object
*/
final class ClassMetadata
final readonly class ClassMetadata
{
/**
* @param ReflectionClass<T> $reflection
Expand All @@ -26,12 +26,12 @@ final class ClassMetadata
* @param list<CallbackMetadata> $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,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Metadata/Psr16MetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand Down
6 changes: 3 additions & 3 deletions src/Metadata/Psr6MetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Normalizer/ArrayNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Normalizer/ArrayShapeNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<array-key, Normalizer> $normalizerMap */
public function __construct(
private readonly array $normalizerMap,
private array $normalizerMap,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Normalizer/DateTimeImmutableNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Normalizer/DateTimeNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Normalizer/DateTimeZoneNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Loading