Skip to content

Commit d179532

Browse files
committed
prs got merged
1 parent 3a78472 commit d179532

File tree

3 files changed

+4
-48
lines changed

3 files changed

+4
-48
lines changed

src/Metadata/Property/Factory/SerializerPropertyMetadataFactory.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function create(string $resourceClass, string $property, array $options =
6565
$propertyMetadata = $this->transformReadWrite($propertyMetadata, $resourceClass, $property, $normalizationGroups, $denormalizationGroups, $ignoredAttributes);
6666

6767
$type = $propertyMetadata->getPhpType();
68-
if (null !== $type && !$this->isResourceClass($resourceClass) && TypeHelper::isSatisfiedBy($type, static fn (Type $t): bool => $t instanceof CollectionType)) {
68+
if (null !== $type && !$this->isResourceClass($resourceClass) && $type->isSatisfiedBy(static fn (Type $t): bool => $t instanceof CollectionType)) {
6969
return $propertyMetadata->withReadableLink(true)->withWritableLink(true);
7070
}
7171

src/Metadata/UriVariablesConverter.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use ApiPlatform\Metadata\Exception\InvalidUriVariableException;
1717
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
1818
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
19-
use ApiPlatform\Metadata\Util\TypeHelper;
2019
use Symfony\Component\TypeInfo\Type\CompositeTypeInterface;
2120
use Symfony\Component\TypeInfo\Type\WrappingTypeInterface;
2221

@@ -91,7 +90,7 @@ private function getIdentifierTypeStrings(string $resourceClass, array $properti
9190
continue;
9291
}
9392

94-
foreach (TypeHelper::traverse($type) as $t) {
93+
foreach ($type->traverse() as $t) {
9594
if (!$t instanceof CompositeTypeInterface && !$t instanceof WrappingTypeInterface) {
9695
$typeStrings[] = (string) $t;
9796
}

src/Metadata/Util/TypeHelper.php

+2-45
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515

1616
use Symfony\Component\TypeInfo\Type;
1717
use Symfony\Component\TypeInfo\Type\CollectionType;
18-
use Symfony\Component\TypeInfo\Type\CompositeTypeInterface;
1918
use Symfony\Component\TypeInfo\Type\ObjectType;
20-
use Symfony\Component\TypeInfo\Type\WrappingTypeInterface;
2119

2220
/**
2321
* @internal
@@ -30,50 +28,9 @@ private function __construct()
3028
{
3129
}
3230

33-
/**
34-
* https://github.com/symfony/symfony/pull/59845.
35-
*
36-
* @return iterable<Type>
37-
*/
38-
public static function traverse(Type $type, bool $traverseComposite = true, bool $traverseWrapped = true): iterable
39-
{
40-
yield $type;
41-
42-
if ($type instanceof CompositeTypeInterface && $traverseComposite) {
43-
foreach ($type->getTypes() as $t) {
44-
yield $t;
45-
}
46-
47-
// prevent yielding twice when having a type that is both composite and wrapped
48-
return;
49-
}
50-
51-
if ($type instanceof WrappingTypeInterface && $traverseWrapped) {
52-
yield $type->getWrappedType();
53-
}
54-
}
55-
56-
/**
57-
* https://github.com/symfony/symfony/pull/59844.
58-
*
59-
* @param callable(Type): bool $specification
60-
*/
61-
public static function isSatisfiedBy(Type $type, callable $specification): bool
62-
{
63-
if ($type instanceof WrappingTypeInterface && $type->wrappedTypeIsSatisfiedBy($specification)) {
64-
return true;
65-
}
66-
67-
if ($type instanceof CompositeTypeInterface && $type->composedTypesAreSatisfiedBy($specification)) {
68-
return true;
69-
}
70-
71-
return $specification($type);
72-
}
73-
7431
public static function getCollectionValueType(Type $type): ?Type
7532
{
76-
foreach (self::traverse($type) as $t) {
33+
foreach ($type->traverse() as $t) {
7734
if ($t instanceof CollectionType) {
7835
return $t->getCollectionValueType();
7936
}
@@ -87,7 +44,7 @@ public static function getCollectionValueType(Type $type): ?Type
8744
*/
8845
public static function getClassName(Type $type): ?string
8946
{
90-
foreach (self::traverse($type) as $t) {
47+
foreach ($type->traverse() as $t) {
9148
if ($t instanceof ObjectType) {
9249
return $t->getClassName();
9350
}

0 commit comments

Comments
 (0)