Test Failed
Push — master ( c747db...f5bd3a )
by Dominik
05:26
created

src/Denormalizer/DenormalizerContext.php (1 issue)

Upgrade to new PHP Analysis Engine

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(
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
49 1
                'resetMissingFields is broken by design, please do this your self by model or repository',
50 1
                E_USER_DEPRECATED
51
            );
52
        }
53
54 3
        $this->resetMissingFields = $resetMissingFields;
55 3
    }
56
57
    /**
58
     * @return array|null
59
     */
60 2
    public function getAllowedAdditionalFields()
61
    {
62 2
        return $this->allowedAdditionalFields;
63
    }
64
65
    /**
66
     * @return string[]
67
     */
68 2
    public function getGroups(): array
69
    {
70 2
        return $this->groups;
71
    }
72
73
    /**
74
     * @return ServerRequestInterface|null
75
     */
76 2
    public function getRequest()
77
    {
78 2
        return $this->request;
79
    }
80
81
    /**
82
     * @deprecated
83
     *
84
     * @return bool
85
     */
86 3
    public function isResetMissingFields(): bool
87
    {
88 3
        return $this->resetMissingFields;
89
    }
90
}
91