1 | <?php |
||
14 | trait UserTrait |
||
15 | { |
||
16 | /** |
||
17 | * @var string |
||
18 | * |
||
19 | * @ORM\Column(type="string", length=255, nullable=false, unique=true) |
||
20 | * |
||
21 | * @Assert\NotBlank |
||
22 | * @Assert\Email |
||
23 | */ |
||
24 | private $email; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | * |
||
29 | * @ORM\Column(name="password", type="string", length=100, nullable=false) |
||
30 | */ |
||
31 | private $password; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | private $plainPassword; |
||
37 | |||
38 | /** |
||
39 | * @var string |
||
40 | * |
||
41 | * @ORM\Column(type="string", length=255, nullable=true) |
||
42 | */ |
||
43 | protected $firstName; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | * |
||
48 | * @ORM\Column(type="string", length=255, nullable=true) |
||
49 | */ |
||
50 | protected $lastName; |
||
51 | |||
52 | /** |
||
53 | * @var array |
||
54 | * |
||
55 | * @ORM\Column(type="json_array") |
||
56 | */ |
||
57 | private $roles; |
||
58 | |||
59 | /** |
||
60 | * @return string |
||
61 | */ |
||
62 | public function __toString() |
||
70 | |||
71 | /** |
||
72 | * On list we want to be able to sort by Lastname |
||
73 | * @return string |
||
74 | */ |
||
75 | public function getListDisplay() |
||
83 | |||
84 | /** |
||
85 | * @return int |
||
86 | */ |
||
87 | public function getId() |
||
91 | |||
92 | /** |
||
93 | * @inheritdoc |
||
94 | */ |
||
95 | public function getUsername() |
||
99 | |||
100 | /** |
||
101 | * @inheritdoc |
||
102 | */ |
||
103 | public function getEmail() |
||
107 | |||
108 | /** |
||
109 | * @param string $email |
||
110 | * |
||
111 | * @return $this |
||
112 | */ |
||
113 | public function setEmail($email) |
||
119 | |||
120 | /** |
||
121 | * @inheritdoc |
||
122 | */ |
||
123 | public function getPassword() |
||
127 | |||
128 | /** |
||
129 | * @param string $password |
||
130 | * |
||
131 | * @return $this |
||
132 | */ |
||
133 | public function setPassword($password) |
||
139 | |||
140 | /** |
||
141 | * @inheritdoc |
||
142 | */ |
||
143 | public function getSalt() |
||
147 | |||
148 | /** |
||
149 | * @return string |
||
150 | */ |
||
151 | public function getPlainPassword() |
||
155 | |||
156 | /** |
||
157 | * @param string $plainPassword |
||
158 | * |
||
159 | * @return $this |
||
160 | */ |
||
161 | public function setPlainPassword($plainPassword) |
||
167 | |||
168 | /** |
||
169 | * @inheritdoc |
||
170 | */ |
||
171 | public function eraseCredentials() |
||
177 | |||
178 | /** |
||
179 | * @inheritdoc |
||
180 | */ |
||
181 | public function getRoles() |
||
185 | |||
186 | /** |
||
187 | * @param array $roles |
||
188 | * |
||
189 | * @return $this |
||
190 | */ |
||
191 | public function setRoles(array $roles = []) |
||
197 | |||
198 | /** |
||
199 | * @return string |
||
200 | */ |
||
201 | public function getFirstName() |
||
205 | |||
206 | /** |
||
207 | * @param string $firstName |
||
208 | * |
||
209 | * @return $this |
||
210 | */ |
||
211 | public function setFirstName($firstName) |
||
217 | |||
218 | /** |
||
219 | * @return string |
||
220 | */ |
||
221 | public function getLastName() |
||
225 | |||
226 | /** |
||
227 | * @param string $lastName |
||
228 | * |
||
229 | * @return $this |
||
230 | */ |
||
231 | public function setLastName($lastName) |
||
237 | |||
238 | /** |
||
239 | * @return string |
||
240 | */ |
||
241 | public function getFullName() |
||
245 | |||
246 | /** |
||
247 | * @return string |
||
248 | */ |
||
249 | public function getListFullName() |
||
253 | |||
254 | /** |
||
255 | * @return string |
||
256 | */ |
||
257 | public function getFullNameAndEmail() |
||
265 | |||
266 | /** |
||
267 | * @see \Serializable::serialize() |
||
268 | */ |
||
269 | public function serialize() |
||
277 | |||
278 | /** |
||
279 | * @see \Serializable::unserialize() |
||
280 | */ |
||
281 | public function unserialize($serialized) |
||
291 | } |
||
292 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: