Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 148 additions & 43 deletions src/Hydra/Serializer/DocumentationNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
use ApiPlatform\Metadata\ResourceClassResolverInterface;
use ApiPlatform\Metadata\UrlGeneratorInterface;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
use Symfony\Component\PropertyInfo\Type as LegacyType;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\TypeInfo\Type;
use Symfony\Component\TypeInfo\Type\CollectionType;
use Symfony\Component\TypeInfo\Type\CompositeTypeInterface;
use Symfony\Component\TypeInfo\Type\ObjectType;
use Symfony\Component\TypeInfo\Type\WrappingTypeInterface;
use Symfony\Component\TypeInfo\TypeIdentifier;

use const ApiPlatform\JsonLd\HYDRA_CONTEXT;

Expand Down Expand Up @@ -356,73 +363,171 @@
return $jsonldContext['@type'];
}

$builtInTypes = $propertyMetadata->getBuiltinTypes() ?? [];
$types = [];

foreach ($builtInTypes as $type) {
if ($type->isCollection() && null !== $collectionType = $type->getCollectionValueTypes()[0] ?? null) {
$type = $collectionType;
if (method_exists(PropertyInfoExtractor::class, 'getType')) {
$nativeType = $propertyMetadata->getNativeType();
if (null === $nativeType) {
return null;
}

switch ($type->getBuiltinType()) {
case Type::BUILTIN_TYPE_STRING:
if (!\in_array('xmls:string', $types, true)) {
$types[] = 'xmls:string';
}
break;
case Type::BUILTIN_TYPE_INT:
if (!\in_array('xmls:integer', $types, true)) {
$types[] = 'xmls:integer';
}
break;
case Type::BUILTIN_TYPE_FLOAT:
if (!\in_array('xmls:decimal', $types, true)) {
$types[] = 'xmls:decimal';
}
break;
case Type::BUILTIN_TYPE_BOOL:
if (!\in_array('xmls:boolean', $types, true)) {
$types[] = 'xmls:boolean';
}
break;
case Type::BUILTIN_TYPE_OBJECT:
if (null === $className = $type->getClassName()) {
continue 2;
/** @var Type|null $collectionValueType */
$collectionValueType = null;
$typeIsCollection = static function (Type $type) use (&$typeIsCollection, &$collectionValueType): bool {
return match (true) {

Check warning on line 377 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L377

Added line #L377 was not covered by tests
$type instanceof CollectionType => null !== $collectionValueType = $type->getCollectionValueType(),
$type instanceof WrappingTypeInterface => $type->wrappedTypeIsSatisfiedBy($typeIsCollection),
$type instanceof CompositeTypeInterface => $type->composedTypesAreSatisfiedBy($typeIsCollection),
default => false,
};

Check warning on line 382 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L382

Added line #L382 was not covered by tests
};

if ($nativeType->isSatisfiedBy($typeIsCollection)) {
$nativeType = $collectionValueType;
}

// Check for specific types after potentially unwrapping the collection
if (null === $nativeType) {
return null; // Should not happen if collection had a value type, but safety check

Check warning on line 391 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L391

Added line #L391 was not covered by tests
}

if ($nativeType->isIdentifiedBy(TypeIdentifier::STRING)) {
$types[] = 'xmls:string';
}

if ($nativeType->isIdentifiedBy(TypeIdentifier::INT)) {
$types[] = 'xmls:integer';
}

if ($nativeType->isIdentifiedBy(TypeIdentifier::FLOAT)) {
$types[] = 'xmls:decimal';
}

if ($nativeType->isIdentifiedBy(TypeIdentifier::BOOL)) {
$types[] = 'xmls:boolean';
}

if ($nativeType->isIdentifiedBy(\DateTimeInterface::class)) {
$types[] = 'xmls:dateTime';
}

/** @var class-string|null $className */
$className = null;

$typeIsResourceClass = function (Type $type) use (&$typeIsResourceClass, &$className): bool {
return match (true) {

Check warning on line 418 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L418

Added line #L418 was not covered by tests
$type instanceof WrappingTypeInterface => $type->wrappedTypeIsSatisfiedBy($typeIsResourceClass),
$type instanceof CompositeTypeInterface => $type->composedTypesAreSatisfiedBy($typeIsResourceClass),
default => $type instanceof ObjectType && $this->resourceClassResolver->isResourceClass($className = $type->getClassName()),
};

Check warning on line 422 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L422

Added line #L422 was not covered by tests
};

if ($nativeType->isSatisfiedBy($typeIsResourceClass) && $className) {
$resourceMetadata = $this->resourceMetadataFactory->create($className);
$operation = $resourceMetadata->getOperation();

if (!$operation instanceof HttpOperation || !$operation->getTypes()) {
if (!\in_array("#{$operation->getShortName()}", $types, true)) {
$types[] = "#{$operation->getShortName()}";
}
} else {
$types = array_unique(array_merge($types, $operation->getTypes()));
}
}
// TODO: remove in 5.x
} else {
$builtInTypes = $propertyMetadata->getBuiltinTypes() ?? [];

Check warning on line 439 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L439

Added line #L439 was not covered by tests

foreach ($builtInTypes as $type) {
if ($type->isCollection() && null !== $collectionType = $type->getCollectionValueTypes()[0] ?? null) {
$type = $collectionType;

Check warning on line 443 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L441-L443

Added lines #L441 - L443 were not covered by tests
}

if (is_a($className, \DateTimeInterface::class, true)) {
if (!\in_array('xmls:dateTime', $types, true)) {
$types[] = 'xmls:dateTime';
switch ($type->getBuiltinType()) {
case LegacyType::BUILTIN_TYPE_STRING:
if (!\in_array('xmls:string', $types, true)) {
$types[] = 'xmls:string';

Check warning on line 449 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L446-L449

Added lines #L446 - L449 were not covered by tests
}
break;
}

if ($this->resourceClassResolver->isResourceClass($className)) {
$resourceMetadata = $this->resourceMetadataFactory->create($className);
$operation = $resourceMetadata->getOperation();
case LegacyType::BUILTIN_TYPE_INT:
if (!\in_array('xmls:integer', $types, true)) {
$types[] = 'xmls:integer';

Check warning on line 454 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L452-L454

Added lines #L452 - L454 were not covered by tests
}
break;
case LegacyType::BUILTIN_TYPE_FLOAT:
if (!\in_array('xmls:decimal', $types, true)) {
$types[] = 'xmls:decimal';

Check warning on line 459 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L456-L459

Added lines #L456 - L459 were not covered by tests
}
break;
case LegacyType::BUILTIN_TYPE_BOOL:
if (!\in_array('xmls:boolean', $types, true)) {
$types[] = 'xmls:boolean';

Check warning on line 464 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L461-L464

Added lines #L461 - L464 were not covered by tests
}
break;
case LegacyType::BUILTIN_TYPE_OBJECT:
if (null === $className = $type->getClassName()) {
continue 2;

Check warning on line 469 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L466-L469

Added lines #L466 - L469 were not covered by tests
}

if (!$operation instanceof HttpOperation || !$operation->getTypes()) {
if (!\in_array("#{$operation->getShortName()}", $types, true)) {
$types[] = "#{$operation->getShortName()}";
if (is_a($className, \DateTimeInterface::class, true)) {
if (!\in_array('xmls:dateTime', $types, true)) {
$types[] = 'xmls:dateTime';

Check warning on line 474 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L472-L474

Added lines #L472 - L474 were not covered by tests
}
break;
}

$types = array_unique(array_merge($types, $operation->getTypes()));
break;
}
if ($this->resourceClassResolver->isResourceClass($className)) {
$resourceMetadata = $this->resourceMetadataFactory->create($className);
$operation = $resourceMetadata->getOperation();

Check warning on line 481 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L479-L481

Added lines #L479 - L481 were not covered by tests

if (!$operation instanceof HttpOperation || !$operation->getTypes()) {
if (!\in_array("#{$operation->getShortName()}", $types, true)) {
$types[] = "#{$operation->getShortName()}";

Check warning on line 485 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L483-L485

Added lines #L483 - L485 were not covered by tests
}
break;

Check warning on line 487 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L487

Added line #L487 was not covered by tests
}

$types = array_unique(array_merge($types, $operation->getTypes()));
break;

Check warning on line 491 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L490-L491

Added lines #L490 - L491 were not covered by tests
}
}
}
}

if ([] === $types) {
return null;
}

$types = array_unique($types);

return 1 === \count($types) ? $types[0] : $types;
}

private function isSingleRelation(ApiProperty $propertyMetadata): bool
{
if (method_exists(PropertyInfoExtractor::class, 'getType')) {
$nativeType = $propertyMetadata->getNativeType();
if (null === $nativeType) {
return false;
}

if ($nativeType instanceof CollectionType) {
return false;
}

$typeIsResourceClass = function (Type $type) use (&$typeIsResourceClass): bool {
return match (true) {

Check warning on line 519 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L519

Added line #L519 was not covered by tests
$type instanceof CollectionType => false,
$type instanceof WrappingTypeInterface => $type->wrappedTypeIsSatisfiedBy($typeIsResourceClass),
$type instanceof CompositeTypeInterface => $type->composedTypesAreSatisfiedBy($typeIsResourceClass),
default => $type instanceof ObjectType && $this->resourceClassResolver->isResourceClass($type->getClassName()),
};

Check warning on line 524 in src/Hydra/Serializer/DocumentationNormalizer.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Serializer/DocumentationNormalizer.php#L524

Added line #L524 was not covered by tests
};

return $nativeType->isSatisfiedBy($typeIsResourceClass);
}

// TODO: remove in 5.x
$builtInTypes = $propertyMetadata->getBuiltinTypes() ?? [];

foreach ($builtInTypes as $type) {
Expand Down
28 changes: 14 additions & 14 deletions src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\PropertyInfo\Type;
use Symfony\Component\TypeInfo\Type;

use const ApiPlatform\JsonLd\HYDRA_CONTEXT;

Expand Down Expand Up @@ -77,15 +77,15 @@

$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
$propertyMetadataFactoryProphecy->create('dummy', 'name', Argument::type('array'))->shouldBeCalled()->willReturn(
(new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('name')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)
(new ApiProperty())->withNativeType(Type::string())->withDescription('name')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)

Check warning on line 80 in src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php#L80

Added line #L80 was not covered by tests
);
$propertyMetadataFactoryProphecy->create('dummy', 'description', Argument::type('array'))->shouldBeCalled()->willReturn(
(new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('description')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)->withJsonldContext(['@type' => '@id'])
(new ApiProperty())->withNativeType(Type::string())->withDescription('description')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)->withJsonldContext(['@type' => '@id'])

Check warning on line 83 in src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php#L83

Added line #L83 was not covered by tests
);
$propertyMetadataFactoryProphecy->create('dummy', 'nameConverted', Argument::type('array'))->shouldBeCalled()->willReturn(
(new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('name converted')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)
(new ApiProperty())->withNativeType(Type::string())->withDescription('name converted')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)

Check warning on line 86 in src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php#L86

Added line #L86 was not covered by tests
);
$propertyMetadataFactoryProphecy->create('dummy', 'relatedDummy', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_OBJECT, false, 'dummy', true, null, new Type(Type::BUILTIN_TYPE_OBJECT, false, 'relatedDummy'))])->withDescription('This is a name.')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
$propertyMetadataFactoryProphecy->create('dummy', 'relatedDummy', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withNativeType(Type::collection(Type::object('dummy'), Type::object('relatedDummy')))->withDescription('This is a name.')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)); // @phpstan-ignore-line

Check warning on line 88 in src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php#L88

Added line #L88 was not covered by tests
$propertyMetadataFactoryProphecy->create('dummy', 'iri', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withIris(['https://schema.org/Dummy']));

$resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class);
Expand Down Expand Up @@ -365,10 +365,10 @@
]));

$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
$propertyMetadataFactoryProphecy->create('inputClass', 'a', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('a')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
$propertyMetadataFactoryProphecy->create('inputClass', 'b', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('b')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
$propertyMetadataFactoryProphecy->create('outputClass', 'c', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('c')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
$propertyMetadataFactoryProphecy->create('outputClass', 'd', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('d')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
$propertyMetadataFactoryProphecy->create('inputClass', 'a', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withNativeType(Type::string())->withDescription('a')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
$propertyMetadataFactoryProphecy->create('inputClass', 'b', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withNativeType(Type::string())->withDescription('b')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
$propertyMetadataFactoryProphecy->create('outputClass', 'c', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withNativeType(Type::string())->withDescription('c')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
$propertyMetadataFactoryProphecy->create('outputClass', 'd', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withNativeType(Type::string())->withDescription('d')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));

Check warning on line 371 in src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php#L368-L371

Added lines #L368 - L371 were not covered by tests

$resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class);
$resourceClassResolverProphecy->isResourceClass(Argument::type('string'))->willReturn(true);
Expand Down Expand Up @@ -502,7 +502,7 @@
$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
$propertyMetadataFactoryProphecy->create('dummy', 'name', Argument::type('array'))->shouldBeCalled()->willReturn(
(new ApiProperty())
->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])
->withNativeType(Type::string())

Check warning on line 505 in src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php#L505

Added line #L505 was not covered by tests
->withDescription('b')
->withReadable(true)
->withWritable(true)
Expand Down Expand Up @@ -564,15 +564,15 @@

$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
$propertyMetadataFactoryProphecy->create('dummy', 'name', Argument::type('array'))->shouldBeCalled()->willReturn(
(new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('name')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)
(new ApiProperty())->withNativeType(Type::string())->withDescription('name')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)

Check warning on line 567 in src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php#L567

Added line #L567 was not covered by tests
);
$propertyMetadataFactoryProphecy->create('dummy', 'description', Argument::type('array'))->shouldBeCalled()->willReturn(
(new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('description')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)->withJsonldContext(['@type' => '@id'])
(new ApiProperty())->withNativeType(Type::string())->withDescription('description')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)->withJsonldContext(['@type' => '@id'])

Check warning on line 570 in src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php#L570

Added line #L570 was not covered by tests
);
$propertyMetadataFactoryProphecy->create('dummy', 'nameConverted', Argument::type('array'))->shouldBeCalled()->willReturn(
(new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('name converted')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)
(new ApiProperty())->withNativeType(Type::string())->withDescription('name converted')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)

Check warning on line 573 in src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php#L573

Added line #L573 was not covered by tests
);
$propertyMetadataFactoryProphecy->create('dummy', 'relatedDummy', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_OBJECT, false, 'dummy', true, null, new Type(Type::BUILTIN_TYPE_OBJECT, false, 'relatedDummy'))])->withDescription('This is a name.')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
$propertyMetadataFactoryProphecy->create('dummy', 'relatedDummy', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withNativeType(Type::collection(Type::object('dummy'), Type::object('relatedDummy')))->withDescription('This is a name.')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)); // @phpstan-ignore-line

Check warning on line 575 in src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php

View check run for this annotation

Codecov / codecov/patch

src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php#L575

Added line #L575 was not covered by tests
$propertyMetadataFactoryProphecy->create('dummy', 'iri', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withIris(['https://schema.org/Dummy']));

$resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class);
Expand Down
Loading
Loading