1 | <?php |
||
25 | class User extends BasicEntity implements UserInterface, \Serializable |
||
26 | { |
||
27 | /** |
||
28 | * Username of the user. |
||
29 | * |
||
30 | * @ORM\Column(type="string", length=64, unique=true) |
||
31 | * @Assert\NotNull |
||
32 | * @Assert\NotBlank |
||
33 | */ |
||
34 | private $username; |
||
35 | |||
36 | /** |
||
37 | * Password of the user. |
||
38 | * |
||
39 | * @ORM\Column(type="string", length=64, nullable=true) |
||
40 | */ |
||
41 | private $password; |
||
42 | |||
43 | /** |
||
44 | * Password Reset Token of the agent. |
||
45 | * |
||
46 | * @ORM\Column(type="string", length=64, nullable=true) |
||
47 | */ |
||
48 | private $passwordResetToken; |
||
49 | |||
50 | /** |
||
51 | * Password Reset Expiration of the agent. |
||
52 | * @ORM\Column(name="passwordResetExpiration", type="datetime", nullable=true) |
||
53 | */ |
||
54 | private $passwordResetExpiration; |
||
55 | |||
56 | /** |
||
57 | * Email of the user. |
||
58 | * |
||
59 | * @ORM\Column(type="string", length=60, unique=true) |
||
60 | * @Assert\NotNull |
||
61 | * @Assert\NotBlank |
||
62 | */ |
||
63 | private $email; |
||
64 | |||
65 | /** |
||
66 | * User's roles. |
||
67 | * |
||
68 | * @ORM\ManyToMany(targetEntity="Role") |
||
69 | */ |
||
70 | private $roles; |
||
71 | |||
72 | /** |
||
73 | * Tells whether user account is active or not. |
||
74 | * |
||
75 | * @ORM\Column(name="is_active", type="boolean", nullable=true) |
||
76 | */ |
||
77 | private $isActive; |
||
78 | |||
79 | /** |
||
80 | 49 | * @ORM\OneToMany(targetEntity="Setting", mappedBy="user", cascade={"persist"}) |
|
81 | */ |
||
82 | 49 | private $settings; |
|
83 | 49 | ||
84 | 49 | /** |
|
85 | * Class constructor. |
||
86 | 49 | */ |
|
87 | public function __construct() |
||
113 | |||
114 | 40 | /** |
|
115 | * Get username. |
||
116 | * |
||
117 | * @inheritDoc |
||
118 | */ |
||
119 | public function getUsername() |
||
123 | |||
124 | /** |
||
125 | * Get salt. |
||
126 | 49 | * |
|
127 | * @inheritDoc |
||
128 | */ |
||
129 | public function getSalt() |
||
135 | |||
136 | 39 | /** |
|
137 | * Get password. |
||
138 | * |
||
139 | * @inheritDoc |
||
140 | */ |
||
141 | public function getPassword() |
||
145 | |||
146 | 39 | /** |
|
147 | * Get all roles. |
||
148 | * |
||
149 | * @inheritDoc |
||
150 | */ |
||
151 | public function getRoles() |
||
155 | |||
156 | 39 | /** |
|
157 | * Not implemented. |
||
158 | * |
||
159 | * @inheritDoc |
||
160 | */ |
||
161 | public function eraseCredentials() |
||
164 | |||
165 | 39 | /** |
|
166 | 39 | * Serialize object into array. |
|
167 | 39 | * |
|
168 | 39 | * @see \Serializable::serialize() |
|
169 | 39 | */ |
|
170 | 39 | public function serialize() |
|
182 | |||
183 | 39 | /** |
|
184 | * Unserialize array into object. |
||
185 | * |
||
186 | 39 | * @param $serialized |
|
187 | 39 | * |
|
188 | 39 | * @see \Serializable::unserialize() |
|
189 | 39 | */ |
|
190 | 39 | public function unserialize($serialized) |
|
203 | |||
204 | 7 | /** |
|
205 | * Gets the value of email. |
||
206 | * |
||
207 | * @return mixed |
||
208 | */ |
||
209 | public function getEmail() |
||
213 | |||
214 | 49 | /** |
|
215 | * Sets the value of email. |
||
216 | 49 | * |
|
217 | * @param string $email the email |
||
218 | 49 | * |
|
219 | * @return self |
||
220 | */ |
||
221 | public function setEmail($email) |
||
227 | |||
228 | 7 | /** |
|
229 | * Gets the value of isActive. |
||
230 | * |
||
231 | * @return mixed |
||
232 | */ |
||
233 | public function getIsActive() |
||
237 | |||
238 | 6 | /** |
|
239 | * Sets the value of isActive. |
||
240 | 6 | * |
|
241 | * @param mixed $isActive the is active |
||
242 | 6 | * |
|
243 | * @return self |
||
244 | */ |
||
245 | public function setIsActive($isActive) |
||
251 | |||
252 | 49 | /** |
|
253 | * Sets the value of username. |
||
254 | 49 | * |
|
255 | * @param string $username the username |
||
256 | 49 | * |
|
257 | * @return self |
||
258 | */ |
||
259 | public function setUsername($username) |
||
265 | |||
266 | 49 | /** |
|
267 | * Sets the value of password. |
||
268 | 49 | * |
|
269 | * @param mixed $password the password |
||
270 | 49 | * |
|
271 | * @return self |
||
272 | */ |
||
273 | public function setPassword($password) |
||
279 | |||
280 | 49 | /** |
|
281 | 49 | * Add role to the user. |
|
282 | * |
||
283 | 49 | * @param Role $role [description] |
|
284 | */ |
||
285 | public function addRole(Role $role) |
||
291 | |||
292 | 1 | /** |
|
293 | 1 | * Remove role. |
|
294 | * |
||
295 | 1 | * @param Role $role |
|
296 | */ |
||
297 | public function removeRole(Role $role) |
||
303 | 5 | ||
304 | 5 | /** |
|
305 | * Remove all roles. |
||
306 | * |
||
307 | */ |
||
308 | public function removeRoles() |
||
312 | |||
313 | 1 | /** |
|
314 | * Gets the value of settings. |
||
315 | * |
||
316 | * @return ArrayCollection |
||
317 | */ |
||
318 | public function getSettings() |
||
322 | |||
323 | public function getSettingsByName($name) |
||
331 | |||
332 | 5 | /** |
|
333 | * Get passwordResetToken. |
||
334 | * |
||
335 | * @inheritDoc |
||
336 | */ |
||
337 | public function getPasswordResetToken() |
||
341 | |||
342 | 6 | /** |
|
343 | * Sets the value of password reset token. |
||
344 | 6 | * |
|
345 | * @param null|string $passwordResetToken the passwordResetToken |
||
346 | 6 | * |
|
347 | * @return self |
||
348 | */ |
||
349 | public function setPasswordResetToken($passwordResetToken) |
||
355 | |||
356 | 3 | /** |
|
357 | * Get passwordResetExpiration. |
||
358 | * |
||
359 | * @inheritDoc |
||
360 | */ |
||
361 | public function getPasswordResetExpiration() |
||
365 | |||
366 | 6 | /** |
|
367 | * Sets the value of password reset token. |
||
368 | 6 | * |
|
369 | * @param null|\DateTime $passwordResetExpiration the passwordResetExpiration |
||
370 | 6 | * |
|
371 | * @return self |
||
372 | */ |
||
373 | public function setPasswordResetExpiration($passwordResetExpiration) |
||
379 | } |
||
380 |
Let?s assume that you have the following
foreach
statement:$itemValue
is assigned by reference. This is possible because the expression (in the example$array
) can be used as a reference target.However, if we were to replace
$array
with something different like the result of a function call as inthen assigning by reference is not possible anymore as there is no target that could be modified.
Available Fixes
1. Do not assign by reference
2. Assign to a local variable first
3. Return a reference