Skip to content

Commit

Permalink
fix: Improper error when serializing a flattened property
Browse files Browse the repository at this point in the history
  • Loading branch information
autaut03 committed Oct 19, 2023
1 parent d78ae82 commit 86cd9af
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ There are some alternatives to this, but all of them will lack at least one of t
- parses existing PHPDoc information instead of duplicating it through attributes
- supports generic types which are extremely useful for wrapper types
- allows simple extension through mappers and complex stuff through type adapters
- produces developer-friendly error messages on invalid data
- correctly handles optional and `null` values as separate concepts
- produces developer-friendly error messages for invalid data
- correctly handles optional (missing keys) and `null` values as separate concepts
- simple to extend with additional formats
- simple internal structure: no nodes, value wrappers or any limitations

- simple internal structure: no node tree, no value wrappers, no PHP parsing, no inherent limitations
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

final class MemoizingTypeAdapterRegistry implements TypeAdapterRegistry
{
/** @var array<class-string, array<>> */
/** @var array<class-string, array<string, \WeakMap<object, array<int, array{ object[], TypeAdapter }>>>> */
private array $resolved = [];

Check failure on line 18 in src/GoodPhp/Serialization/Serializer/Registry/Cache/MemoizingTypeAdapterRegistry.php

View workflow job for this annotation

GitHub Actions / PHPStan

Property GoodPhp\Serialization\Serializer\Registry\Cache\MemoizingTypeAdapterRegistry::$resolved with generic interface GoodPhp\Serialization\TypeAdapter\TypeAdapter does not specify its types: DeserializedType, SerializedType

public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ public static function rethrow(BoundClassProperty|string $serializedName, callab
try {
return $callback();
} catch (PropertyMappingException $e) {
throw new self($serializedName ? $serializedName . '.' . $e->path : $e->path, $e->getPrevious());
throw new self($serializedName !== null ? $serializedName . '.' . $e->path : $e->path, $e->getPrevious());
} catch (CollectionItemMappingException $e) {
throw new self($serializedName ? $serializedName . '.' . $e->key : $e->key, $e->getPrevious());
throw new self($serializedName !== null ? $serializedName . '.' . $e->key : $e->key, $e->getPrevious());
} catch (Exception $e) {
throw new self($serializedName, $e);
throw $serializedName !== null ? new self($serializedName, $e) : $e;
}
}
}

0 comments on commit 86cd9af

Please sign in to comment.