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

api-platform / core / 15955912273

29 Jun 2025 01:51PM UTC coverage: 22.057% (-0.03%) from 22.082%
15955912273

Pull #7249

github

web-flow
Merge d9904d788 into a42034dc3
Pull Request #7249: chore: solve some phpstan issues

0 of 9 new or added lines in 8 files covered. (0.0%)

11540 existing lines in 372 files now uncovered.

11522 of 52237 relevant lines covered (22.06%)

11.08 hits per line

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

93.33
/src/Serializer/OperationContextTrait.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\Serializer;
15

16
use ApiPlatform\Metadata\ApiProperty;
17

18
/**
19
 * @internal
20
 */
21
trait OperationContextTrait
22
{
23
    /**
24
     * This context is created when working on a relation context or items of a collection. It cleans the previously given
25
     * context as the operation changes.
26
     */
27
    protected function createOperationContext(array $context, ?string $resourceClass = null, ?ApiProperty $propertyMetadata = null): array
28
    {
UNCOV
29
        if (isset($context['operation']) && !isset($context['root_operation'])) {
169✔
UNCOV
30
            $context['root_operation'] = $context['operation'];
154✔
31
        }
32

UNCOV
33
        if (isset($context['operation_name']) || isset($context['graphql_operation_name'])) {
169✔
UNCOV
34
            $context['root_operation_name'] = $context['operation_name'] ?? $context['graphql_operation_name'];
159✔
35
        }
36

UNCOV
37
        unset($context['iri'], $context['uri_variables'], $context['item_uri_template'], $context['force_resource_class']);
169✔
38

39
        // At some point we should merge the jsonld context here, there's a TODO to simplify this somewhere else
UNCOV
40
        if ($propertyMetadata) {
169✔
UNCOV
41
            $context['output'] ??= [];
90✔
UNCOV
42
            $context['output']['gen_id'] = $propertyMetadata->getGenId() ?? true;
90✔
43
        }
44

UNCOV
45
        if (!$resourceClass) {
169✔
46
            return $context;
×
47
        }
48

UNCOV
49
        if (($operation = $context['operation'] ?? null) && method_exists($operation, 'getItemUriTemplate')) {
169✔
UNCOV
50
            $context['item_uri_template'] = $operation->getItemUriTemplate();
131✔
51
        }
52

UNCOV
53
        unset($context['operation'], $context['operation_name']);
169✔
UNCOV
54
        $context['resource_class'] = $resourceClass;
169✔
55

UNCOV
56
        return $context;
169✔
57
    }
58
}
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