• 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

39.13
/src/State/Processor/ObjectMapperProcessor.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\Processor;
15

16
use ApiPlatform\Metadata\Operation;
17
use ApiPlatform\State\ProcessorInterface;
18
use Symfony\Component\HttpFoundation\Response;
19
use Symfony\Component\ObjectMapper\ObjectMapperInterface;
20

21
/**
22
 * @implements ProcessorInterface<mixed,mixed>
23
 */
24
final class ObjectMapperProcessor implements ProcessorInterface
25
{
26
    /**
27
     * @param ProcessorInterface<mixed,mixed> $decorated
28
     */
29
    public function __construct(
30
        private readonly ?ObjectMapperInterface $objectMapper,
31
        private readonly ProcessorInterface $decorated,
32
    ) {
UNCOV
33
    }
692✔
34

35
    public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): object|array|null
36
    {
UNCOV
37
        $class = $operation->getInput()['class'] ?? $operation->getClass();
180✔
38

39
        if (
UNCOV
40
            $data instanceof Response
180✔
UNCOV
41
            || !$this->objectMapper
180✔
UNCOV
42
            || !$operation->canWrite()
180✔
UNCOV
43
            || null === $data
180✔
UNCOV
44
            || !is_a($data, $class, true)
180✔
UNCOV
45
            || !$operation->canMap()
180✔
46
        ) {
UNCOV
47
            return $this->decorated->process($data, $operation, $uriVariables, $context);
180✔
48
        }
49

UNCOV
50
        $request = $context['request'] ?? null;
×
UNCOV
51
        $persisted = $this->decorated->process(
×
52
            // maps the Resource to an Entity
UNCOV
53
            $this->objectMapper->map($data, $request?->attributes->get('mapped_data')),
×
UNCOV
54
            $operation,
×
UNCOV
55
            $uriVariables,
×
UNCOV
56
            $context,
×
UNCOV
57
        );
×
58

59
        // in some cases (delete operation), the decoration may return a null object
UNCOV
60
        if (null === $persisted) {
×
UNCOV
61
            return $persisted;
×
62
        }
63

UNCOV
64
        $request?->attributes->set('persisted_data', $persisted);
×
65

66
        // return the Resource representation of the persisted entity
UNCOV
67
        return $this->objectMapper->map(
×
68
            // persist the entity
UNCOV
69
            $persisted,
×
UNCOV
70
            $operation->getClass()
×
UNCOV
71
        );
×
72
    }
73
}
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