1 | <?php |
||
15 | final class User extends Singleton |
||
16 | { |
||
17 | /** |
||
18 | * Update User Data without overwriting Session. |
||
19 | * |
||
20 | * @param array $parameters |
||
21 | * |
||
22 | * @return UserModel |
||
23 | */ |
||
24 | public function updateSession(array $parameters) |
||
28 | |||
29 | /** |
||
30 | * Set User Data on Session. |
||
31 | * |
||
32 | * @param UserModel $user |
||
33 | * |
||
34 | * @return UserModel |
||
35 | */ |
||
36 | public function setSession(UserModel $user) |
||
40 | |||
41 | /** |
||
42 | * Update User Data by User Model. |
||
43 | * |
||
44 | * @param UserModel $user |
||
45 | * @param array $parameters |
||
46 | * |
||
47 | * @return UserModel |
||
48 | */ |
||
49 | public function updateUser($user, array $parameters) |
||
55 | |||
56 | /** |
||
57 | * Get User Data from Session |
||
58 | * If User Session doesn't exists, return null. |
||
59 | * |
||
60 | * @return UserModel|null |
||
61 | */ |
||
62 | public function getUser() |
||
66 | |||
67 | /** |
||
68 | * Retrieve Non Banned Users (If all Users are Banned, return the Banned user Also). |
||
69 | * |
||
70 | * @param Request $request |
||
71 | * @param ChocolateyId $chocolateyId |
||
72 | * |
||
73 | * @return UserModel |
||
74 | */ |
||
75 | private function checkForBanAlternative(Request $request, ChocolateyId $chocolateyId) |
||
87 | |||
88 | /** |
||
89 | * Get Users. |
||
90 | * |
||
91 | * @param Request $request |
||
92 | * @param ChocolateyId $chocolateyId |
||
93 | * |
||
94 | * @return UserModel |
||
95 | */ |
||
96 | private function retrieveUser(Request $request, ChocolateyId $chocolateyId) |
||
116 | |||
117 | /** |
||
118 | * Set Session From Login Credentials. |
||
119 | * |
||
120 | * @param Request $request |
||
121 | * |
||
122 | * @return UserModel |
||
123 | */ |
||
124 | public function loginUser(Request $request) |
||
139 | |||
140 | /** |
||
141 | * Return if USer Session Exists. |
||
142 | * |
||
143 | * @return bool |
||
144 | */ |
||
145 | public function hasSession() |
||
149 | |||
150 | /** |
||
151 | * Erase User Session. |
||
152 | */ |
||
153 | public function eraseSession() |
||
157 | } |
||
158 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: