1 | <?php |
||
2 | |||
3 | /* |
||
4 | * @copyright 2014 Mautic Contributors. All rights reserved |
||
5 | * @author Mautic |
||
6 | * |
||
7 | * @link http://mautic.org |
||
8 | * |
||
9 | * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html |
||
10 | */ |
||
11 | |||
12 | namespace Mautic\EmailBundle\Swiftmailer\SendGrid\Callback; |
||
13 | |||
14 | use Mautic\EmailBundle\Swiftmailer\SendGrid\Exception\ResponseItemException; |
||
15 | |||
16 | class ResponseItem |
||
17 | { |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | private $email; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | private $reason; |
||
27 | |||
28 | /** |
||
29 | * @var int |
||
30 | */ |
||
31 | private $dncReason; |
||
32 | |||
33 | /** |
||
34 | * @throws ResponseItemException |
||
35 | */ |
||
36 | public function __construct(array $item) |
||
37 | { |
||
38 | if (empty($item['email'])) { |
||
39 | throw new ResponseItemException(); |
||
40 | } |
||
41 | $this->email = $item['email']; |
||
42 | $this->reason = !empty($item['reason']) ? $item['reason'] : null; |
||
43 | $this->dncReason = CallbackEnum::convertEventToDncReason($item['event']); |
||
0 ignored issues
–
show
|
|||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return string |
||
48 | */ |
||
49 | public function getEmail() |
||
50 | { |
||
51 | return $this->email; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return string |
||
56 | */ |
||
57 | public function getReason() |
||
58 | { |
||
59 | return $this->reason; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @return int |
||
64 | */ |
||
65 | public function getDncReason() |
||
66 | { |
||
67 | return $this->dncReason; |
||
68 | } |
||
69 | } |
||
70 |
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.