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
30 changes: 15 additions & 15 deletions src/JsonMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@
/**
* Creates a mapper that converts JSON data into PHP objects using the configured Symfony services.
*
* @param PropertyInfoExtractorInterface $extractor Extractor that provides type information for mapped properties.
* @param PropertyAccessorInterface $accessor Property accessor used to write values onto target objects.
* @param PropertyInfoExtractorInterface $extractor Extractor that provides type information for mapped properties.
* @param PropertyAccessorInterface $accessor Property accessor used to write values onto target objects.
* @param PropertyNameConverterInterface|null $nameConverter Optional converter to normalise incoming property names.
* @param array<class-string, class-string|Closure(mixed):class-string|Closure(mixed, MappingContext):class-string> $classMap Map of base classes to resolvers that determine the concrete class to instantiate.
* @param CacheItemPoolInterface|null $typeCache Optional cache for resolved type information.
* @param JsonMapperConfiguration $config Default mapper configuration cloned for new mapping contexts.
* @param array<class-string, class-string|Closure(mixed):class-string|Closure(mixed, MappingContext):class-string> $classMap Map of base classes to resolvers that determine the concrete class to instantiate.
* @param CacheItemPoolInterface|null $typeCache Optional cache for resolved type information.
* @param JsonMapperConfiguration $config Default mapper configuration cloned for new mapping contexts.
*/
public function __construct(
private PropertyInfoExtractorInterface $extractor,
Expand Down Expand Up @@ -179,7 +179,7 @@ public function addTypeHandler(TypeHandlerInterface $handler): JsonMapper
* Registers a custom type using a closure-based handler.
*
* @param non-empty-string $type Name of the custom type alias handled by the closure.
* @param Closure $closure Closure that converts the incoming value to the target type.
* @param Closure $closure Closure that converts the incoming value to the target type.
*
* @deprecated Use addTypeHandler() with a TypeHandlerInterface implementation instead.
*
Expand Down Expand Up @@ -213,11 +213,11 @@ public function addCustomClassMapEntry(string $className, Closure $closure): Jso
/**
* Maps the JSON to the specified class entity.
*
* @param mixed $json Source data to map into PHP objects.
* @param class-string|null $className Fully qualified class name that should be instantiated for mapped objects.
* @param class-string|null $collectionClassName Collection class that should wrap the mapped objects when required.
* @param MappingContext|null $context Optional mapping context reused across nested mappings.
* @param JsonMapperConfiguration|null $configuration Optional configuration that overrides the default mapper settings.
* @param mixed $json Source data to map into PHP objects.
* @param class-string|null $className Fully qualified class name that should be instantiated for mapped objects.
* @param class-string|null $collectionClassName Collection class that should wrap the mapped objects when required.
* @param MappingContext|null $context Optional mapping context reused across nested mappings.
* @param JsonMapperConfiguration|null $configuration Optional configuration that overrides the default mapper settings.
*
* @return mixed The mapped PHP value or collection produced from the given JSON.
*/
Expand Down Expand Up @@ -540,9 +540,9 @@ private function convertValue(mixed $json, Type $type, MappingContext $context):
/**
* Converts the value according to the provided union type.
*
* @param mixed $json Value being converted so it matches one of the union candidates.
* @param UnionType<Type> $type Union definition listing acceptable target types.
* @param MappingContext $context Context used to track conversion errors while testing candidates.
* @param mixed $json Value being converted so it matches one of the union candidates.
* @param UnionType<Type> $type Union definition listing acceptable target types.
* @param MappingContext $context Context used to track conversion errors while testing candidates.
*
* @return mixed Value converted to a type accepted by the union.
*/
Expand Down Expand Up @@ -683,7 +683,7 @@ private function isNullType(Type $type): bool
/**
* Creates an instance of the given class name.
*
* @param string $className Fully qualified class name to instantiate.
* @param string $className Fully qualified class name to instantiate.
* @param mixed ...$constructorArguments Arguments forwarded to the constructor of the class.
*
* @return object Newly created instance of the requested class.
Expand Down
2 changes: 1 addition & 1 deletion src/JsonMapper/Attribute/ReplaceProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
final readonly class ReplaceProperty
{
/**
* @param string $value Name of the incoming JSON field that should be renamed.
* @param string $value Name of the incoming JSON field that should be renamed.
* @param string $replaces Target property name that receives the value.
*/
public function __construct(
Expand Down
6 changes: 3 additions & 3 deletions src/JsonMapper/Collection/CollectionDocBlockTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ final class CollectionDocBlockTypeResolver
private DocBlockFactoryInterface $docBlockFactory;

/**
* @param DocBlockFactoryInterface|null $docBlockFactory Optional docblock factory used to parse collection annotations.
* @param ContextFactory $contextFactory Factory for building type resolution contexts for reflected classes.
* @param PhpDocTypeHelper $phpDocTypeHelper Helper translating DocBlock types into Symfony TypeInfo representations.
* @param DocBlockFactoryInterface|null $docBlockFactory Optional docblock factory used to parse collection annotations.
* @param ContextFactory $contextFactory Factory for building type resolution contexts for reflected classes.
* @param PhpDocTypeHelper $phpDocTypeHelper Helper translating DocBlock types into Symfony TypeInfo representations.
*/
public function __construct(
?DocBlockFactoryInterface $docBlockFactory = null,
Expand Down
12 changes: 6 additions & 6 deletions src/JsonMapper/Collection/CollectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public function __construct(
/**
* Converts the provided iterable JSON structure to a PHP array.
*
* @param mixed $json Raw JSON data representing the collection to hydrate.
* @param Type $valueType Type descriptor for individual collection entries.
* @param MappingContext $context Active mapping context providing path and strictness information.
* @param mixed $json Raw JSON data representing the collection to hydrate.
* @param Type $valueType Type descriptor for individual collection entries.
* @param MappingContext $context Active mapping context providing path and strictness information.
*
* @return array<array-key, mixed>|null Normalised collection data or null when conversion fails.
*/
Expand Down Expand Up @@ -100,9 +100,9 @@ public function mapIterable(mixed $json, Type $valueType, MappingContext $contex
/**
* Builds a collection based on the specified collection type description.
*
* @param CollectionType<CollectionWrappedType|GenericType<CollectionWrappedType>> $type Resolved collection metadata from docblocks or attributes.
* @param mixed $json Raw JSON payload containing the collection values.
* @param MappingContext $context Mapping context controlling strict mode and error tracking.
* @param CollectionType<CollectionWrappedType|GenericType<CollectionWrappedType>> $type Resolved collection metadata from docblocks or attributes.
* @param mixed $json Raw JSON payload containing the collection values.
* @param MappingContext $context Mapping context controlling strict mode and error tracking.
*
* @return object|array<array-key, mixed>|null Instantiated collection wrapper or the normalised array values.
*/
Expand Down
12 changes: 6 additions & 6 deletions src/JsonMapper/Collection/CollectionFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ interface CollectionFactoryInterface
/**
* Converts the provided iterable JSON structure to a PHP array.
*
* @param mixed $json Raw JSON data representing the iterable input to normalise.
* @param Type $valueType Type description for the collection values.
* @param MappingContext $context Active mapping context carrying strictness and error reporting configuration.
* @param mixed $json Raw JSON data representing the iterable input to normalise.
* @param Type $valueType Type description for the collection values.
* @param MappingContext $context Active mapping context carrying strictness and error reporting configuration.
*
* @return array<TKey, TValue>|null Normalised array representation or null when conversion fails.
*/
Expand All @@ -43,9 +43,9 @@ public function mapIterable(mixed $json, Type $valueType, MappingContext $contex
/**
* Builds a collection based on the specified collection type description.
*
* @param CollectionType<CollectionWrappedType|GenericType<CollectionWrappedType>> $type Resolved collection metadata from PHPDoc or attributes.
* @param mixed $json Raw JSON payload containing the collection values.
* @param MappingContext $context Mapping context controlling strict mode and error recording.
* @param CollectionType<CollectionWrappedType|GenericType<CollectionWrappedType>> $type Resolved collection metadata from PHPDoc or attributes.
* @param mixed $json Raw JSON payload containing the collection values.
* @param MappingContext $context Mapping context controlling strict mode and error recording.
*
* @return array<TKey, TValue>|object|null Instantiated collection wrapper or the normalised array values.
*/
Expand Down
14 changes: 7 additions & 7 deletions src/JsonMapper/Configuration/JsonMapperConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ final class JsonMapperConfiguration
/**
* Creates a new configuration instance with optional overrides.
*
* @param bool $strictMode Whether unknown/missing properties should trigger errors
* @param bool $collectErrors Whether encountered mapping errors should be collected
* @param bool $emptyStringIsNull Whether empty strings are converted to null
* @param bool $ignoreUnknownProperties Whether properties missing in the destination type are ignored
* @param bool $treatNullAsEmptyCollection Whether null collections are replaced with empty collections
* @param string $defaultDateFormat Default `DateTimeInterface` format used for serialization/deserialization
* @param bool $allowScalarToObjectCasting Whether scalars can be coerced into objects when supported
* @param bool $strictMode Whether unknown/missing properties should trigger errors
* @param bool $collectErrors Whether encountered mapping errors should be collected
* @param bool $emptyStringIsNull Whether empty strings are converted to null
* @param bool $ignoreUnknownProperties Whether properties missing in the destination type are ignored
* @param bool $treatNullAsEmptyCollection Whether null collections are replaced with empty collections
* @param string $defaultDateFormat Default `DateTimeInterface` format used for serialization/deserialization
* @param bool $allowScalarToObjectCasting Whether scalars can be coerced into objects when supported
*/
public function __construct(
private bool $strictMode = false,
Expand Down
4 changes: 2 additions & 2 deletions src/JsonMapper/Context/MappingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ public function withPathSegment(string|int $segment, callable $callback): mixed
/**
* Stores the error message for later consumption.
*
* @param string $message Human-readable description of the failure
* @param MappingException|null $exception Optional exception associated with the failure
* @param string $message Human-readable description of the failure
* @param MappingException|null $exception Optional exception associated with the failure
*
* @return void
*/
Expand Down
6 changes: 3 additions & 3 deletions src/JsonMapper/Context/MappingError.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
final readonly class MappingError
{
/**
* @param string $path JSON path pointing to the failing property
* @param string $message Human-readable description of the failure
* @param MappingException|null $exception Exception that triggered the error, when available
* @param string $path JSON path pointing to the failing property
* @param string $message Human-readable description of the failure
* @param MappingException|null $exception Exception that triggered the error, when available
*/
public function __construct(
private string $path,
Expand Down
6 changes: 3 additions & 3 deletions src/JsonMapper/Exception/MappingException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
abstract class MappingException extends RuntimeException
{
/**
* @param string $message Human readable description of the failure scenario.
* @param string $path JSON pointer or dotted path identifying the failing value.
* @param int $code Optional error code to bubble up to the caller.
* @param string $message Human readable description of the failure scenario.
* @param string $path JSON pointer or dotted path identifying the failing value.
* @param int $code Optional error code to bubble up to the caller.
* @param Throwable|null $previous Underlying cause, if the exception wraps another failure.
*/
public function __construct(
Expand Down
6 changes: 3 additions & 3 deletions src/JsonMapper/Exception/MissingPropertyException.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
final class MissingPropertyException extends MappingException
{
/**
* @param string $path Path indicating where the missing property should have been present.
* @param string $propertyName Name of the required property defined on the PHP target.
* @param class-string $className Fully qualified name of the DTO or object declaring the property.
* @param string $path Path indicating where the missing property should have been present.
* @param string $propertyName Name of the required property defined on the PHP target.
* @param class-string $className Fully qualified name of the DTO or object declaring the property.
*/
public function __construct(
string $path,
Expand Down
6 changes: 3 additions & 3 deletions src/JsonMapper/Exception/UnknownPropertyException.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
final class UnknownPropertyException extends MappingException
{
/**
* @param string $path Path to the JSON value that references the unknown property.
* @param string $propertyName Name of the property that does not exist on the PHP target.
* @param class-string $className Fully qualified name of the object that lacks the property.
* @param string $path Path to the JSON value that references the unknown property.
* @param string $propertyName Name of the property that does not exist on the PHP target.
* @param class-string $className Fully qualified name of the object that lacks the property.
*/
public function __construct(
string $path,
Expand Down
2 changes: 1 addition & 1 deletion src/JsonMapper/Report/MappingResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
final readonly class MappingResult
{
/**
* @param mixed $value The mapped value returned by the mapper.
* @param mixed $value The mapped value returned by the mapper.
* @param MappingReport $report Report containing diagnostics for the mapping operation.
*/
public function __construct(
Expand Down
14 changes: 7 additions & 7 deletions src/JsonMapper/Resolver/ClassResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public function __construct(array $classMap = [])
/**
* Adds a custom resolution rule.
*
* @param class-string $className Base class or interface the resolver handles.
* @param Closure(mixed):class-string|Closure(mixed, MappingContext):class-string $resolver Callback returning a concrete class based on the JSON payload and optional mapping context.
* @param class-string $className Base class or interface the resolver handles.
* @param Closure(mixed):class-string|Closure(mixed, MappingContext):class-string $resolver Callback returning a concrete class based on the JSON payload and optional mapping context.
*
* @phpstan-param class-string $className
* @phpstan-param Closure(mixed):class-string|Closure(mixed, MappingContext):class-string $resolver
Expand All @@ -63,9 +63,9 @@ public function add(string $className, Closure $resolver): void
/**
* Resolves the class name for the provided JSON payload.
*
* @param class-string $className Base class name configured in the resolver map.
* @param mixed $json Raw JSON fragment inspected to determine the target class.
* @param MappingContext $context Mapping context passed to resolution callbacks when required.
* @param class-string $className Base class name configured in the resolver map.
* @param mixed $json Raw JSON fragment inspected to determine the target class.
* @param MappingContext $context Mapping context passed to resolution callbacks when required.
*
* @return class-string Fully-qualified class name that should be instantiated for the payload.
*/
Expand Down Expand Up @@ -100,8 +100,8 @@ public function resolve(string $className, mixed $json, MappingContext $context)
* Executes a resolver callback while adapting the invocation to its declared arity.
*
* @param Closure(mixed):class-string|Closure(mixed, MappingContext):class-string $resolver User-provided resolver that determines the concrete class; the parameter list defines whether the mapping context can be injected.
* @param mixed $json JSON fragment forwarded to the resolver so it can inspect discriminator values.
* @param MappingContext $context Context object passed when supported to supply additional mapping metadata.
* @param mixed $json JSON fragment forwarded to the resolver so it can inspect discriminator values.
* @param MappingContext $context Context object passed when supported to supply additional mapping metadata.
*
* @return mixed Raw resolver result that will subsequently be validated as a class-string.
*/
Expand Down
Loading