Total Complexity | 12 |
Total Lines | 74 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | class Line |
||
6 | { |
||
7 | /** |
||
8 | * method |
||
9 | * @see https://tools.ietf.org/html/rfc7231#section-4 |
||
10 | * |
||
11 | * @var string |
||
12 | */ |
||
13 | protected $method; |
||
14 | |||
15 | /** |
||
16 | * request-target |
||
17 | * @see https://tools.ietf.org/html/rfc7230#section-5.3 |
||
18 | * |
||
19 | * @var \Raptor\Request\Components\Target |
||
20 | */ |
||
21 | protected $target; |
||
22 | |||
23 | /** |
||
24 | * HTTP-version |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $version; |
||
29 | |||
30 | /** |
||
31 | * Class constructor |
||
32 | */ |
||
33 | public function __construct() |
||
34 | { |
||
35 | $this->target = new Target; |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * Get the method. |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | public function method() |
||
44 | { |
||
45 | if ($this->method !== null) { |
||
46 | return $this->method; |
||
47 | } |
||
48 | $this->method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : false; |
||
|
|||
49 | if ($this->method === 'POST' && !empty($_SERVER['X-HTTP-METHOD-OVERRIDE'])) { |
||
50 | return $this->method = strtoupper($_SERVER['X-HTTP-METHOD-OVERRIDE']); |
||
51 | } |
||
52 | if ($this->method === 'POST' && !empty($_POST['_method'])) { |
||
53 | return $this->method = strtoupper($_POST['_method']); |
||
54 | } |
||
55 | return $this->method; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Get the request-target. |
||
60 | * |
||
61 | * @return \Raptor\Request\Components\Target |
||
62 | */ |
||
63 | public function target() |
||
64 | { |
||
65 | return $this->target; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Get the HTTP-version. |
||
70 | * |
||
71 | * @return string |
||
72 | */ |
||
73 | public function version() |
||
79 | } |
||
80 | } |
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 mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.