1 | <?php namespace nyx\notify\transports\slack\message\attachment; |
||
20 | class Field implements core\interfaces\Serializable |
||
21 | { |
||
22 | /** |
||
23 | * The traits of a Field. |
||
24 | */ |
||
25 | use core\traits\Serializable; |
||
26 | |||
27 | /** |
||
28 | * @var string Required. The title of the Field. |
||
29 | */ |
||
30 | protected $title; |
||
31 | |||
32 | /** |
||
33 | * @var string Required. The value of the Field. |
||
34 | */ |
||
35 | protected $value; |
||
36 | |||
37 | /** |
||
38 | * @var bool Whether the value of the Field is short enough to fit side by side other Fields. |
||
39 | */ |
||
40 | protected $isShort = true; |
||
41 | |||
42 | /** |
||
43 | * Creates a new Field instance. |
||
44 | * |
||
45 | * @param array $attributes |
||
46 | */ |
||
47 | public function __construct(array $attributes) |
||
53 | |||
54 | /** |
||
55 | * Sets the attributes of this Field. |
||
56 | * |
||
57 | * @param array $attributes |
||
58 | * @return $this |
||
59 | */ |
||
60 | public function setAttributes(array $attributes) : Field |
||
76 | |||
77 | /** |
||
78 | * Returns the title of the Field. |
||
79 | * |
||
80 | * @return string |
||
81 | */ |
||
82 | public function getTitle() |
||
86 | |||
87 | /** |
||
88 | * Sets the title of the Field. |
||
89 | * |
||
90 | * @param string $title |
||
91 | * @return $this |
||
92 | */ |
||
93 | public function setTitle(string $title) : Field |
||
99 | |||
100 | /** |
||
101 | * Returns the value of the Field. |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | public function getValue() |
||
109 | |||
110 | /** |
||
111 | * Sets the value of the Field. |
||
112 | * |
||
113 | * @param string $value |
||
114 | * @return $this |
||
115 | */ |
||
116 | public function setValue(string $value) : Field |
||
122 | |||
123 | /** |
||
124 | * Returns whether the value of the Field is short enough to fit side by side other Fields. |
||
125 | * |
||
126 | * @return bool |
||
127 | */ |
||
128 | public function isShort() : bool |
||
132 | |||
133 | /** |
||
134 | * Sets whether the value of the Field is short enough to fit side by side other Fields. |
||
135 | * |
||
136 | * @param string $value |
||
137 | * @return $this |
||
138 | */ |
||
139 | public function setIsShort(bool $value) : Field |
||
145 | |||
146 | /** |
||
147 | * {@inheritDoc} |
||
148 | */ |
||
149 | public function unserialize($data) |
||
153 | |||
154 | /** |
||
155 | * {@inheritDoc} |
||
156 | */ |
||
157 | public function toArray() : array |
||
165 | } |
||
166 |
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.