Skip to content

Commit 8e526e1

Browse files
committed
fix: drop legacy convertType usages and dead instanceof flagged by phpstan
TypeConverterInterface::convertType was replaced by convertPhpType. Remove the leftover convertType implementations in the GraphQl test fixtures, and drop a now-always-true `instanceof Type` on a non-nullable collection value type.
1 parent 9c94061 commit 8e526e1

3 files changed

Lines changed: 1 addition & 23 deletions

File tree

src/GraphQl/Tests/Type/FieldsBuilderTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,6 @@ public function testGetResourceObjectTypeFields(string $resourceClass, Operation
485485
});
486486

487487
$typeConverter = new class implements TypeConverterInterface {
488-
public function convertType(\Symfony\Component\PropertyInfo\Type $type, bool $input, Operation $rootOperation, string $resourceClass, string $rootResource, ?string $property, int $depth): GraphQLType|string|null
489-
{
490-
return null;
491-
}
492-
493488
public function resolveType(string $type): ?GraphQLType
494489
{
495490
return null;

src/Serializer/AbstractItemNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ private function createAndValidateAttributeValue(string $attribute, mixed $value
10301030
// Fix a collection that contains the only one element
10311031
// This is special to xml format only
10321032
if ('xml' === $format && null !== $collectionValueType && (!\is_array($value) || !\is_int(key($value)))) {
1033-
$isMixedType = $collectionValueType instanceof Type && $collectionValueType->isIdentifiedBy(TypeIdentifier::MIXED);
1033+
$isMixedType = $collectionValueType->isIdentifiedBy(TypeIdentifier::MIXED);
10341034
if (!$isMixedType) {
10351035
$value = [$value];
10361036
}

tests/Fixtures/TestBundle/GraphQl/Type/TypeConverter.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use ApiPlatform\Tests\Fixtures\TestBundle\Document\Dummy as DummyDocument;
1919
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Dummy;
2020
use GraphQL\Type\Definition\Type as GraphQLType;
21-
use Symfony\Component\PropertyInfo\Type as LegacyType;
2221
use Symfony\Component\TypeInfo\Type;
2322

2423
/**
@@ -32,22 +31,6 @@ public function __construct(private readonly TypeConverterInterface $defaultType
3231
{
3332
}
3433

35-
/**
36-
* {@inheritdoc}
37-
*/
38-
public function convertType(LegacyType $type, bool $input, Operation $rootOperation, string $resourceClass, string $rootResource, ?string $property, int $depth): GraphQLType|string|null
39-
{
40-
if ('dummyDate' === $property
41-
&& \in_array($rootResource, [Dummy::class, DummyDocument::class], true)
42-
&& LegacyType::BUILTIN_TYPE_OBJECT === $type->getBuiltinType()
43-
&& is_a($type->getClassName(), \DateTimeInterface::class, true)
44-
) {
45-
return \DateTime::class;
46-
}
47-
48-
return $this->defaultTypeConverter->convertType($type, $input, $rootOperation, $resourceClass, $rootResource, $property, $depth);
49-
}
50-
5134
/**
5235
* {@inheritdoc}
5336
*/

0 commit comments

Comments
 (0)