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

api-platform / core / 20832557808

08 Jan 2026 09:35PM UTC coverage: 18.991% (-9.9%) from 28.875%
20832557808

Pull #7658

github

web-flow
Merge c8402145f into 39c55837e
Pull Request #7658: fix(openapi): properly document list parameters

0 of 3 new or added lines in 1 file covered. (0.0%)

14885 existing lines in 487 files now uncovered.

10912 of 57460 relevant lines covered (18.99%)

21.79 hits per line

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

18.52
/src/State/Provider/ObjectMapperProvider.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\State\Provider;
15

16
use ApiPlatform\Metadata\Operation;
17
use ApiPlatform\Metadata\Util\CloneTrait;
18
use ApiPlatform\State\Pagination\MappedObjectPaginator;
19
use ApiPlatform\State\Pagination\PaginatorInterface;
20
use ApiPlatform\State\ProviderInterface;
21
use Symfony\Component\ObjectMapper\ObjectMapperInterface;
22

23
/**
24
 * @implements ProviderInterface<object>
25
 */
26
final class ObjectMapperProvider implements ProviderInterface
27
{
28
    use CloneTrait;
29

30
    /**
31
     * @param ProviderInterface<object> $decorated
32
     */
33
    public function __construct(
34
        private readonly ?ObjectMapperInterface $objectMapper,
35
        private readonly ProviderInterface $decorated,
36
    ) {
UNCOV
37
    }
692✔
38

39
    public function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
40
    {
UNCOV
41
        $data = $this->decorated->provide($operation, $uriVariables, $context);
554✔
UNCOV
42
        $class = $operation->getOutput()['class'] ?? $operation->getClass();
554✔
43

UNCOV
44
        if (!$this->objectMapper || !$operation->canMap()) {
554✔
UNCOV
45
            return $data;
554✔
46
        }
47

UNCOV
48
        if (!\is_object($data) && !\is_array($data)) {
×
UNCOV
49
            return $data;
×
50
        }
51

UNCOV
52
        $request = $context['request'] ?? null;
×
UNCOV
53
        $request?->attributes->set('mapped_data', $data);
×
54

UNCOV
55
        if ($data instanceof PaginatorInterface) {
×
UNCOV
56
            $data = new MappedObjectPaginator(
×
UNCOV
57
                iterator_to_array($data),
×
UNCOV
58
                $this->objectMapper,
×
UNCOV
59
                $class,
×
UNCOV
60
                $data->getTotalItems(),
×
UNCOV
61
                $data->getCurrentPage(),
×
UNCOV
62
                $data->getLastPage(),
×
UNCOV
63
                $data->getItemsPerPage(),
×
UNCOV
64
            );
×
UNCOV
65
        } elseif (\is_array($data)) {
×
UNCOV
66
            foreach ($data as &$v) {
×
UNCOV
67
                if (\is_object($v)) {
×
UNCOV
68
                    $v = $this->objectMapper->map($v, $class);
×
69
                }
70
            }
71
        } else {
UNCOV
72
            $data = $this->objectMapper->map($data, $class);
×
73
        }
74

UNCOV
75
        $request?->attributes->set('data', $data);
×
UNCOV
76
        $request?->attributes->set('previous_data', $this->clone($data));
×
77

UNCOV
78
        return $data;
×
79
    }
80
}
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

© 2026 Coveralls, Inc