• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 16705318661

03 Aug 2025 01:05PM UTC coverage: 0.0% (-21.9%) from 21.944%
16705318661

Pull #7317

github

web-flow
Merge 1ca8642ff into d06b1a0a0
Pull Request #7317: Fix/4372 skip null values in hal

0 of 14 new or added lines in 3 files covered. (0.0%)

11680 existing lines in 376 files now uncovered.

0 of 51817 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Metadata/Property/Factory/PropertyInfoPropertyMetadataFactory.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Metadata\Property\Factory;
15

16
use ApiPlatform\Metadata\ApiProperty;
17
use ApiPlatform\Metadata\Exception\PropertyNotFoundException;
18
use Doctrine\Common\Collections\ArrayCollection;
19
use Symfony\Component\PropertyInfo\PropertyInfoExtractor;
20
use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;
21
use Symfony\Component\PropertyInfo\Type;
22

23
/**
24
 * PropertyInfo metadata loader decorator.
25
 *
26
 * @author Kévin Dunglas <dunglas@gmail.com>
27
 */
28
final class PropertyInfoPropertyMetadataFactory implements PropertyMetadataFactoryInterface
29
{
30
    public function __construct(private readonly PropertyInfoExtractorInterface $propertyInfo, private readonly ?PropertyMetadataFactoryInterface $decorated = null)
31
    {
UNCOV
32
    }
×
33

34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function create(string $resourceClass, string $property, array $options = []): ApiProperty
38
    {
UNCOV
39
        if (null === $this->decorated) {
×
40
            $propertyMetadata = new ApiProperty();
×
41
        } else {
42
            try {
UNCOV
43
                $propertyMetadata = $this->decorated->create($resourceClass, $property, $options);
×
UNCOV
44
            } catch (PropertyNotFoundException) {
×
UNCOV
45
                $propertyMetadata = new ApiProperty();
×
46
            }
47
        }
48

49
        // TODO: remove in 5.x
UNCOV
50
        if (!method_exists(PropertyInfoExtractor::class, 'getType')) {
×
51
            if (!$propertyMetadata->getBuiltinTypes()) {
×
52
                $types = $this->propertyInfo->getTypes($resourceClass, $property, $options) ?? [];
×
53

54
                foreach ($types as $i => $type) {
×
55
                    // Temp fix for https://github.com/symfony/symfony/pull/52699
56
                    if (ArrayCollection::class === $type->getClassName()) {
×
57
                        $types[$i] = new Type($type->getBuiltinType(), $type->isNullable(), $type->getClassName(), true, $type->getCollectionKeyTypes(), $type->getCollectionValueTypes());
×
58
                    }
59
                }
60

61
                $propertyMetadata = $propertyMetadata->withBuiltinTypes($types);
×
62
            }
63
        } else {
UNCOV
64
            if (!$propertyMetadata->getNativeType()) {
×
UNCOV
65
                $propertyMetadata = $propertyMetadata->withNativeType($this->propertyInfo->getType($resourceClass, $property, $options));
×
66
            }
67
        }
68

UNCOV
69
        if (null === $propertyMetadata->getDescription() && null !== $description = $this->propertyInfo->getShortDescription($resourceClass, $property, $options)) {
×
UNCOV
70
            $propertyMetadata = $propertyMetadata->withDescription($description);
×
71
        }
72

UNCOV
73
        if (null === $propertyMetadata->isReadable() && null !== $readable = $this->propertyInfo->isReadable($resourceClass, $property, $options)) {
×
UNCOV
74
            $propertyMetadata = $propertyMetadata->withReadable($readable);
×
75
        }
76

UNCOV
77
        if (null === $propertyMetadata->isWritable() && null !== $writable = $this->propertyInfo->isWritable($resourceClass, $property, $options)) {
×
UNCOV
78
            $propertyMetadata = $propertyMetadata->withWritable($writable);
×
79
        }
80

81
        /* @phpstan-ignore-next-line */
UNCOV
82
        if (null === $propertyMetadata->isInitializable() && null !== $initializable = $this->propertyInfo->isInitializable($resourceClass, $property, $options)) {
×
UNCOV
83
            $propertyMetadata = $propertyMetadata->withInitializable($initializable);
×
84
        }
85

UNCOV
86
        return $propertyMetadata;
×
87
    }
88
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc