Completed
Pull Request — master (#72)
by Nate
03:35
created

HeaderMapAnnotHandler   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 1
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
7
declare(strict_types=1);
8
9
namespace Tebru\Retrofit\Internal\AnnotationHandler;
10
11
use Tebru\AnnotationReader\AbstractAnnotation;
12
use Tebru\Retrofit\AnnotationHandler;
13
use Tebru\Retrofit\Converter;
14
use Tebru\Retrofit\Internal\ParameterHandler\HeaderMapParamHandler;
15
use Tebru\Retrofit\ServiceMethodBuilder;
16
use Tebru\Retrofit\StringConverter;
17
18
/**
19
 * Class HeaderMapAnnotHandler
20
 *
21
 * @author Nate Brunette <[email protected]>
22
 */
23
final class HeaderMapAnnotHandler implements AnnotationHandler
24
{
25
    /**
26
     * Adds header map param handler
27
     *
28
     * @param AbstractAnnotation $annotation The annotation to handle
29
     * @param ServiceMethodBuilder $serviceMethodBuilder Used to construct a [@see ServiceMethod]
30
     * @param null|Converter|StringConverter $converter Converter used to convert types before sending to service method
31
     * @param int|null $index The position of the parameter or null if annotation does not reference parameter
32
     * @return void
33
     */
34
    public function handle(
35
        AbstractAnnotation $annotation,
36
        ServiceMethodBuilder $serviceMethodBuilder,
37
        ?Converter $converter,
38
        ?int $index
39
    ): void {
40
        $serviceMethodBuilder->addParameterHandler($index, new HeaderMapParamHandler($converter));
0 ignored issues
show
Documentation introduced by
$converter is of type null|object<Tebru\Retrofit\Converter>, but the function expects a object<Tebru\Retrofit\StringConverter>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
41
    }
42
}
43