Total Complexity | 9 |
Total Lines | 76 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 2 | ||
Bugs | 0 | Features | 2 |
1 | <?php |
||
12 | trait RequestAwareTrait |
||
13 | { |
||
14 | /** |
||
15 | * @var Request|null |
||
16 | */ |
||
17 | protected $request = null; |
||
18 | |||
19 | /** |
||
20 | * @var boolean |
||
21 | */ |
||
22 | protected $autoInitRequest = false; |
||
23 | |||
24 | /** |
||
25 | * Get the Request. |
||
26 | * |
||
27 | * @param bool $autoInit |
||
28 | * @return Request |
||
29 | */ |
||
30 | public function getRequest($autoInit = false) |
||
31 | { |
||
32 | $this->setAutoInitRequest($autoInit); |
||
33 | if ($this->request == null && $this->isAutoInitRequest()) { |
||
34 | $this->initRequest(); |
||
35 | } |
||
36 | |||
37 | return $this->request; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Set a container. |
||
42 | * |
||
43 | * @param Request|RequestInterface $request |
||
44 | * @return $this |
||
45 | */ |
||
46 | public function setRequest(RequestInterface $request) |
||
47 | { |
||
48 | $this->request = $request; |
||
|
|||
49 | |||
50 | return $this; |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @return bool |
||
55 | */ |
||
56 | public function hasRequest() |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * @return bool |
||
63 | */ |
||
64 | public function isAutoInitRequest(): bool |
||
65 | { |
||
66 | return $this->autoInitRequest; |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @param bool $autoInitRequest |
||
71 | */ |
||
72 | public function setAutoInitRequest(bool $autoInitRequest) |
||
75 | } |
||
76 | |||
77 | public function initRequest() |
||
78 | { |
||
79 | $this->request = $this->newRequest(); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @return Request |
||
84 | */ |
||
85 | public function newRequest() |
||
88 | } |
||
89 | } |
||
90 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.