These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Chubbyphp\Deserialization\Denormalizer; |
||
6 | |||
7 | use Psr\Http\Message\ServerRequestInterface; |
||
8 | |||
9 | final class DenormalizerContext implements DenormalizerContextInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var array|null |
||
13 | */ |
||
14 | private $allowedAdditionalFields; |
||
15 | |||
16 | /** |
||
17 | * @var string[] |
||
18 | */ |
||
19 | private $groups = []; |
||
20 | |||
21 | /** |
||
22 | * @var ServerRequestInterface|null |
||
23 | */ |
||
24 | private $request; |
||
25 | |||
26 | /** |
||
27 | * @var bool |
||
28 | */ |
||
29 | private $resetMissingFields; |
||
30 | |||
31 | /** |
||
32 | * @param array|null $allowedAdditionalFields |
||
33 | * @param string[] $groups |
||
34 | * @param ServerRequestInterface|null $request |
||
35 | * @param bool $resetMissingFields |
||
36 | */ |
||
37 | 3 | public function __construct( |
|
38 | array $allowedAdditionalFields = null, |
||
39 | array $groups = [], |
||
40 | ServerRequestInterface $request = null, |
||
41 | bool $resetMissingFields = false |
||
42 | ) { |
||
43 | 3 | $this->allowedAdditionalFields = $allowedAdditionalFields; |
|
44 | 3 | $this->groups = $groups; |
|
45 | 3 | $this->request = $request; |
|
46 | |||
47 | 3 | if ($resetMissingFields) { |
|
48 | 1 | @trigger_error('resetMissingFields is broken by design, better solution is in progress', E_USER_DEPRECATED); |
|
0 ignored issues
–
show
|
|||
49 | } |
||
50 | |||
51 | 3 | $this->resetMissingFields = $resetMissingFields; |
|
52 | 3 | } |
|
53 | |||
54 | /** |
||
55 | * @return array|null |
||
56 | */ |
||
57 | 2 | public function getAllowedAdditionalFields() |
|
58 | { |
||
59 | 2 | return $this->allowedAdditionalFields; |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return string[] |
||
64 | */ |
||
65 | 2 | public function getGroups(): array |
|
66 | { |
||
67 | 2 | return $this->groups; |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * @return ServerRequestInterface|null |
||
72 | */ |
||
73 | 2 | public function getRequest() |
|
74 | { |
||
75 | 2 | return $this->request; |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * @deprecated |
||
80 | * |
||
81 | * @return bool |
||
82 | */ |
||
83 | 3 | public function isResetMissingFields(): bool |
|
84 | { |
||
85 | 3 | return $this->resetMissingFields; |
|
86 | } |
||
87 | } |
||
88 |
If you suppress an error, we recommend checking for the error condition explicitly: