Skip to content

Commit

Permalink
fix: Broken serializer interface and adapter not found exception
Browse files Browse the repository at this point in the history
  • Loading branch information
autaut03 committed Oct 17, 2023
1 parent d823db2 commit 7da8da8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
24 changes: 6 additions & 18 deletions src/GoodPhp/Serialization/Serializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@

namespace GoodPhp\Serialization;

use GoodPhp\Reflection\Reflector\Reflection\Attributes\Attributes;
use GoodPhp\Reflection\Reflector\Reflector;
use GoodPhp\Reflection\Type\NamedType;
use GoodPhp\Reflection\Reflection\Attributes\ArrayAttributes;
use GoodPhp\Reflection\Reflection\Attributes\Attributes;
use GoodPhp\Reflection\Reflector;
use GoodPhp\Reflection\Type\Type;
use GoodPhp\Serialization\TypeAdapter\Registry\TypeAdapterRegistry;
use GoodPhp\Serialization\TypeAdapter\TypeAdapter;
use GoodPhp\Serialization\TypeAdapter\TypeAdapterFactory;

final class Serializer
interface Serializer
{
public function __construct(
private readonly TypeAdapterRegistry $typeAdapterRegistry,
public readonly Reflector $reflector,
) {
}
public function reflector(): Reflector;

/**
* @template T
Expand All @@ -27,12 +22,5 @@ public function __construct(
*
* @return A
*/
public function adapter(string $typeAdapterType, Type|string $type, Attributes $attributes = new Attributes(), TypeAdapterFactory $skipPast = null): TypeAdapter
{
if (is_string($type)) {
$type = new NamedType($type);
}

return $this->typeAdapterRegistry->forType($typeAdapterType, $this, $type, $attributes, $skipPast);
}
public function adapter(string $typeAdapterType, Type|string $type, Attributes $attributes = new ArrayAttributes(), TypeAdapterFactory $skipPast = null): TypeAdapter;

Check failure on line 25 in src/GoodPhp/Serialization/Serializer.php

View workflow job for this annotation

GitHub Actions / PHPStan

Generic type GoodPhp\Serialization\TypeAdapter\TypeAdapter<mixed> in PHPDoc tag @return does not specify all template types of interface GoodPhp\Serialization\TypeAdapter\TypeAdapter: DeserializedType, SerializedType

Check failure on line 25 in src/GoodPhp/Serialization/Serializer.php

View workflow job for this annotation

GitHub Actions / PHPStan

Generic type GoodPhp\Serialization\TypeAdapter\TypeAdapter<mixed> in PHPDoc tag @return does not specify all template types of interface GoodPhp\Serialization\TypeAdapter\TypeAdapter: DeserializedType, SerializedType

Check failure on line 25 in src/GoodPhp/Serialization/Serializer.php

View workflow job for this annotation

GitHub Actions / PHPStan

Method GoodPhp\Serialization\Serializer::adapter() has parameter $skipPast with generic interface GoodPhp\Serialization\TypeAdapter\TypeAdapterFactory but does not specify its types: T

Check failure on line 25 in src/GoodPhp/Serialization/Serializer.php

View workflow job for this annotation

GitHub Actions / PHPStan

PHPDoc tag @template A bound has type GoodPhp\Serialization\TypeAdapter\TypeAdapter<mixed> which does not specify all template types of interface GoodPhp\Serialization\TypeAdapter\TypeAdapter: DeserializedType, SerializedType

Check failure on line 25 in src/GoodPhp/Serialization/Serializer.php

View workflow job for this annotation

GitHub Actions / PHPStan

Template type A of method GoodPhp\Serialization\Serializer::adapter() is not referenced in a parameter.
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class TypeAdapterNotFoundException extends RuntimeException
public function __construct(string $typeAdapterType, Type $type, Attributes $attributes, ?TypeAdapterFactory $skipPast, string|int $code = 0, Throwable $previous = null)
{
$message = "A matching type adapter of type '{$typeAdapterType}' for type '{$type}' " .
($attributes->count() ? 'with attributes ' . $attributes : '') .
($attributes->has() ? 'with attributes ' . $attributes : '') .
($skipPast ? 'skipping past ' . get_class($skipPast) . ' ' : '') .
'was not found.';

Expand Down

0 comments on commit 7da8da8

Please sign in to comment.