Skip to content

Commit d9846e8

Browse files
authored
Merge pull request #88 from patchlevel/remove-deprecations
remove deprecations
2 parents c09d02c + be9169f commit d9846e8

14 files changed

Lines changed: 42 additions & 396 deletions

baseline.xml

Lines changed: 10 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@
5454
<InvalidOperand>
5555
<code><![CDATA[$guessers]]></code>
5656
</InvalidOperand>
57+
<MixedReturnStatement>
58+
<code><![CDATA[(new ReflectionClass($class))->newLazyProxy(
59+
function () use ($metadata, $data): object {
60+
return $this->doHydrate($metadata, $data);
61+
},
62+
)]]></code>
63+
</MixedReturnStatement>
5764
<PossiblyInvalidArgument>
5865
<code><![CDATA[[
5966
...$guessers,
@@ -67,21 +74,7 @@
6774
<code><![CDATA[$result[$field]]]></code>
6875
</MixedAssignment>
6976
</file>
70-
<file src="src/Normalizer/EnumNormalizer.php">
71-
<DeprecatedClass>
72-
<code><![CDATA[ReflectionTypeUtil::classStringInstanceOf($reflectionType, BackedEnum::class)]]></code>
73-
</DeprecatedClass>
74-
<DeprecatedInterface>
75-
<code><![CDATA[EnumNormalizer]]></code>
76-
</DeprecatedInterface>
77-
</file>
7877
<file src="src/Normalizer/ObjectNormalizer.php">
79-
<DeprecatedClass>
80-
<code><![CDATA[ReflectionTypeUtil::classString($reflectionType)]]></code>
81-
</DeprecatedClass>
82-
<DeprecatedInterface>
83-
<code><![CDATA[ObjectNormalizer]]></code>
84-
</DeprecatedInterface>
8578
<MixedArgument>
8679
<code><![CDATA[$value]]></code>
8780
</MixedArgument>
@@ -121,15 +114,9 @@
121114
</InvalidArgument>
122115
</file>
123116
<file src="tests/Unit/Fixture/IdNormalizer.php">
124-
<DeprecatedClass>
125-
<code><![CDATA[ReflectionTypeUtil::classStringInstanceOf(
126-
$reflectionType,
127-
Id::class,
128-
)]]></code>
129-
</DeprecatedClass>
130-
<DeprecatedInterface>
131-
<code><![CDATA[IdNormalizer]]></code>
132-
</DeprecatedInterface>
117+
<PropertyTypeCoercion>
118+
<code><![CDATA[$type->getClassName()]]></code>
119+
</PropertyTypeCoercion>
133120
</file>
134121
<file src="tests/Unit/Metadata/AttributeMetadataFactoryTest.php">
135122
<ArgumentTypeCoercion>
@@ -163,33 +150,4 @@
163150
<code><![CDATA[['foo' => $normalizer]]]></code>
164151
</InvalidArgument>
165152
</file>
166-
<file src="tests/Unit/Normalizer/ReflectionTypeUtilTest.php">
167-
<DeprecatedClass>
168-
<code><![CDATA[ReflectionTypeUtil::classString($this->reflectionType($object, 'notAObject'))]]></code>
169-
<code><![CDATA[ReflectionTypeUtil::classString($this->reflectionType($object, 'object'))]]></code>
170-
<code><![CDATA[ReflectionTypeUtil::classString($this->reflectionType($object, 'objectNullable'))]]></code>
171-
<code><![CDATA[ReflectionTypeUtil::classString($this->reflectionType($object, 'objectUnionNullable'))]]></code>
172-
<code><![CDATA[ReflectionTypeUtil::classStringInstanceOf(
173-
$this->reflectionType($object, 'object'),
174-
ProfileCreated::class,
175-
)]]></code>
176-
<code><![CDATA[ReflectionTypeUtil::classStringInstanceOf(
177-
$this->reflectionType($object, 'objectNullable'),
178-
ProfileCreated::class,
179-
)]]></code>
180-
<code><![CDATA[ReflectionTypeUtil::classStringInstanceOf(
181-
$this->reflectionType($object, 'objectUnionNullable'),
182-
ProfileCreated::class,
183-
)]]></code>
184-
<code><![CDATA[ReflectionTypeUtil::classStringInstanceOf(
185-
$this->reflectionType($object, 'object'),
186-
ChildDto::class,
187-
)]]></code>
188-
<code><![CDATA[ReflectionTypeUtil::type($this->reflectionType($object, 'intersection'))]]></code>
189-
<code><![CDATA[ReflectionTypeUtil::type($this->reflectionType($object, 'nullableString'))]]></code>
190-
<code><![CDATA[ReflectionTypeUtil::type($this->reflectionType($object, 'string'))]]></code>
191-
<code><![CDATA[ReflectionTypeUtil::type($this->reflectionType($object, 'union'))]]></code>
192-
<code><![CDATA[ReflectionTypeUtil::type($this->reflectionType($object, 'unionNullableString'))]]></code>
193-
</DeprecatedClass>
194-
</file>
195153
</files>

phpstan-baseline.neon

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,3 @@ parameters:
101101
identifier: assign.propertyType
102102
count: 1
103103
path: src/Normalizer/ObjectNormalizer.php
104-
105-
-
106-
message: '#^Method Patchlevel\\Hydrator\\Normalizer\\ReflectionTypeUtil\:\:classStringInstanceOf\(\) should return class\-string\<T\> but returns class\-string\<T\>\|\(string&T\)\.$#'
107-
identifier: return.type
108-
count: 1
109-
path: src/Normalizer/ReflectionTypeUtil.php

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ parameters:
55
level: max
66
paths:
77
- src
8+
reportUnmatchedIgnoredErrors: false

src/Metadata/AttributeMetadataFactory.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Patchlevel\Hydrator\Normalizer\ArrayNormalizer;
1717
use Patchlevel\Hydrator\Normalizer\ArrayShapeNormalizer;
1818
use Patchlevel\Hydrator\Normalizer\Normalizer;
19-
use Patchlevel\Hydrator\Normalizer\ReflectionTypeAwareNormalizer;
2019
use Patchlevel\Hydrator\Normalizer\TypeAwareNormalizer;
2120
use ReflectionAttribute;
2221
use ReflectionClass;
@@ -364,10 +363,6 @@ private function getNormalizer(ReflectionProperty $reflectionProperty): Normaliz
364363
$normalizer->handleType($type ?? $this->typeResolver->resolve($reflectionProperty));
365364
}
366365

367-
if ($normalizer instanceof ReflectionTypeAwareNormalizer) {
368-
$normalizer->handleReflectionType($reflectionProperty->getType());
369-
}
370-
371366
return $normalizer;
372367
}
373368

src/Normalizer/EnumNormalizer.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Attribute;
88
use BackedEnum;
9-
use ReflectionType;
109
use Symfony\Component\TypeInfo\Type;
1110
use Symfony\Component\TypeInfo\Type\BackedEnumType;
1211
use Symfony\Component\TypeInfo\Type\NullableType;
@@ -16,7 +15,7 @@
1615
use function is_string;
1716

1817
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_CLASS)]
19-
final class EnumNormalizer implements Normalizer, ReflectionTypeAwareNormalizer, TypeAwareNormalizer
18+
final class EnumNormalizer implements Normalizer, TypeAwareNormalizer
2019
{
2120
/** @param class-string<BackedEnum>|null $enum */
2221
public function __construct(
@@ -58,15 +57,6 @@ public function denormalize(mixed $value): BackedEnum|null
5857
}
5958
}
6059

61-
public function handleReflectionType(ReflectionType|null $reflectionType): void
62-
{
63-
if ($this->enum !== null || $reflectionType === null) {
64-
return;
65-
}
66-
67-
$this->enum = ReflectionTypeUtil::classStringInstanceOf($reflectionType, BackedEnum::class);
68-
}
69-
7060
public function handleType(Type|null $type): void
7161
{
7262
if ($this->enum !== null || $type === null) {

src/Normalizer/InvalidArgument.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use InvalidArgumentException;
88
use Patchlevel\Hydrator\HydratorException;
99
use Throwable;
10-
use ValueError;
1110

1211
use function get_debug_type;
1312
use function sprintf;
@@ -25,12 +24,6 @@ public static function withWrongType(string $expected, mixed $value): self
2524
);
2625
}
2726

28-
/** @deprecated use ::fromThrowable() */
29-
public static function fromValueError(ValueError $error): self
30-
{
31-
return self::fromThrowable($error);
32-
}
33-
3427
public static function fromThrowable(Throwable $exception): self
3528
{
3629
return new self($exception->getMessage(), 0, $exception);

src/Normalizer/InvalidType.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,13 @@
66

77
use InvalidArgumentException;
88
use Patchlevel\Hydrator\HydratorException;
9-
use ReflectionType;
9+
use Symfony\Component\TypeInfo\Type;
1010

1111
use function sprintf;
1212

1313
final class InvalidType extends InvalidArgumentException implements HydratorException
1414
{
15-
/** @param class-string<ReflectionType> $expected */
16-
public static function unsupportedReflectionType(string $expected, ReflectionType $type): self
17-
{
18-
return new self(sprintf('Unsupported reflection type "%s", expected "%s".', $type::class, $expected));
19-
}
20-
21-
public static function unsupportedType(string $expectedType, string $name): self
15+
public static function unsupportedType(Type $expectedType, Type $name): self
2216
{
2317
return new self(sprintf('Unsupported type "%s", expected "%s".', $name, $expectedType));
2418
}

src/Normalizer/ObjectNormalizer.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@
66

77
use Attribute;
88
use Patchlevel\Hydrator\Hydrator;
9-
use ReflectionType;
109
use Symfony\Component\TypeInfo\Type;
1110
use Symfony\Component\TypeInfo\Type\NullableType;
1211
use Symfony\Component\TypeInfo\Type\ObjectType;
1312

1413
use function is_array;
1514

1615
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_CLASS)]
17-
final class ObjectNormalizer implements Normalizer, ReflectionTypeAwareNormalizer, TypeAwareNormalizer, HydratorAwareNormalizer
16+
final class ObjectNormalizer implements Normalizer, TypeAwareNormalizer, HydratorAwareNormalizer
1817
{
1918
private Hydrator|null $hydrator = null;
2019

@@ -68,15 +67,6 @@ public function setHydrator(Hydrator $hydrator): void
6867
$this->hydrator = $hydrator;
6968
}
7069

71-
public function handleReflectionType(ReflectionType|null $reflectionType): void
72-
{
73-
if ($this->className !== null || $reflectionType === null) {
74-
return;
75-
}
76-
77-
$this->className = ReflectionTypeUtil::classString($reflectionType);
78-
}
79-
8070
public function handleType(Type|null $type): void
8171
{
8272
if ($type === null || $this->className !== null) {

src/Normalizer/ReflectionTypeAwareNormalizer.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/Normalizer/ReflectionTypeUtil.php

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)