1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace Mikemirten\Component\JsonApi\Mapper; |
5
|
|
|
|
6
|
|
|
use Mikemirten\Component\JsonApi\Mapper\Definition\Definition; |
7
|
|
|
use Mikemirten\Component\JsonApi\Mapper\Handler\IdentifierHandler\IdentifierHandlerInterface; |
8
|
|
|
use Mikemirten\Component\JsonApi\Mapper\Handler\TypeHandler\TypeHandlerInterface; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Context of mapping |
12
|
|
|
* |
13
|
|
|
* @package Mikemirten\Component\JsonApi\Mapper |
14
|
|
|
*/ |
15
|
|
|
class MappingContext |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Object mapper |
19
|
|
|
* |
20
|
|
|
* @var ObjectMapper |
21
|
|
|
*/ |
22
|
|
|
protected $mapper; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Mapping definition |
26
|
|
|
* |
27
|
|
|
* @var Definition |
28
|
|
|
*/ |
29
|
|
|
protected $definition; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Identifier handler |
33
|
|
|
* |
34
|
|
|
* @var IdentifierHandlerInterface |
35
|
|
|
*/ |
36
|
|
|
protected $identifierHandler; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Type handler |
40
|
|
|
* |
41
|
|
|
* @var TypeHandlerInterface |
42
|
|
|
*/ |
43
|
|
|
protected $typeHandler; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* MappingContext constructor. |
47
|
|
|
* |
48
|
|
|
* @param ObjectMapper $mapper |
49
|
|
|
* @param Definition $definition |
50
|
|
|
* @param IdentifierHandlerInterface $identifierHandler, |
|
|
|
|
51
|
|
|
* @param TypeHandlerInterface $typeHandler |
52
|
|
|
*/ |
53
|
3 |
|
public function __construct( |
54
|
|
|
ObjectMapper $mapper, |
55
|
|
|
Definition $definition, |
56
|
|
|
IdentifierHandlerInterface $identifierHandler, |
57
|
|
|
TypeHandlerInterface $typeHandler |
58
|
|
|
) { |
59
|
3 |
|
$this->mapper = $mapper; |
60
|
3 |
|
$this->definition = $definition; |
61
|
3 |
|
$this->identifierHandler = $identifierHandler; |
62
|
3 |
|
$this->typeHandler = $typeHandler; |
63
|
3 |
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Get object mapper |
67
|
|
|
* |
68
|
|
|
* @return ObjectMapper |
69
|
|
|
*/ |
70
|
1 |
|
public function getMapper(): ObjectMapper |
71
|
|
|
{ |
72
|
1 |
|
return $this->mapper; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Get mapping configuration |
77
|
|
|
* |
78
|
|
|
* @return Definition |
79
|
|
|
*/ |
80
|
1 |
|
public function getDefinition(): Definition |
81
|
|
|
{ |
82
|
1 |
|
return $this->definition; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Get identifier handler |
87
|
|
|
* |
88
|
|
|
* @return IdentifierHandlerInterface |
89
|
|
|
*/ |
90
|
1 |
|
public function getIdentifierHandler(): IdentifierHandlerInterface |
91
|
|
|
{ |
92
|
1 |
|
return $this->identifierHandler; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Get type handler |
97
|
|
|
* |
98
|
|
|
* @return TypeHandlerInterface |
99
|
|
|
*/ |
100
|
1 |
|
public function getTypeHandler(): TypeHandlerInterface |
101
|
|
|
{ |
102
|
1 |
|
return $this->typeHandler; |
103
|
|
|
} |
104
|
|
|
} |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.