1 | <?php |
||
28 | class UserInfo implements UserInfoInterface |
||
29 | { |
||
30 | use ImmutablePropertyTrait; |
||
31 | |||
32 | /** |
||
33 | * User Component |
||
34 | * |
||
35 | * @var User |
||
36 | */ |
||
37 | protected $user; |
||
38 | |||
39 | /** |
||
40 | * Pass Component |
||
41 | * |
||
42 | * @var Pass |
||
43 | */ |
||
44 | protected $pass; |
||
45 | |||
46 | /** |
||
47 | * Create a new instance of UserInfo |
||
48 | * |
||
49 | * @param UserInterface|string $user |
||
50 | * @param PassInterface|string $pass |
||
51 | */ |
||
52 | 655 | public function __construct($user = null, $pass = null) |
|
53 | { |
||
54 | 655 | $this->user = !$user instanceof UserInterface ? new User($user) : $user; |
|
|
|||
55 | 655 | $this->pass = !$pass instanceof PassInterface ? new Pass($pass) : $pass; |
|
56 | 655 | $this->assertValidObject(); |
|
57 | 655 | } |
|
58 | |||
59 | /** |
||
60 | * Retrieve the user component of the URI User Info part |
||
61 | * |
||
62 | * @return string |
||
63 | */ |
||
64 | 27 | public function getUser() |
|
68 | |||
69 | /** |
||
70 | * Retrieve the pass component of the URI User Info part |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | 24 | public function getPass() |
|
78 | |||
79 | /** |
||
80 | * @inheritdoc |
||
81 | */ |
||
82 | 2 | public function __debugInfo() |
|
86 | |||
87 | /** |
||
88 | * @inheritdoc |
||
89 | */ |
||
90 | 12 | public static function __set_state(array $properties) |
|
94 | |||
95 | /** |
||
96 | * Returns the component literal value. |
||
97 | * |
||
98 | * @return null|string |
||
99 | */ |
||
100 | 649 | public function getContent() |
|
114 | |||
115 | /** |
||
116 | * Returns the instance string representation; If the |
||
117 | * instance is not defined an empty string is returned |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | 649 | public function __toString() |
|
125 | |||
126 | /** |
||
127 | * Returns the instance string representation |
||
128 | * with its optional URI delimiters |
||
129 | * |
||
130 | * @return string |
||
131 | */ |
||
132 | 629 | public function getUriComponent() |
|
141 | |||
142 | /** |
||
143 | * Returns whether two UriPart objects represent the same value |
||
144 | * The comparison is based on the getUriComponent method |
||
145 | * |
||
146 | * @param UriPart $component |
||
147 | * |
||
148 | * @return bool |
||
149 | */ |
||
150 | 12 | public function sameValueAs(UriPart $component) |
|
154 | |||
155 | /** |
||
156 | * Return an instance with the specified user. |
||
157 | * |
||
158 | * This method MUST retain the state of the current instance, and return |
||
159 | * an instance that contains the specified user. |
||
160 | * |
||
161 | * An empty user is equivalent to removing the user information. |
||
162 | * |
||
163 | * @param string $user The user to use with the new instance. |
||
164 | * |
||
165 | * @throws \InvalidArgumentException for invalid user. |
||
166 | * |
||
167 | * @return static |
||
168 | */ |
||
169 | 9 | public function withUser($user) |
|
173 | |||
174 | /** |
||
175 | * Return an instance with the specified password. |
||
176 | * |
||
177 | * This method MUST retain the state of the current instance, and return |
||
178 | * an instance that contains the specified password. |
||
179 | * |
||
180 | * An empty password is equivalent to removing the password. |
||
181 | * |
||
182 | * @param string $pass The password to use with the new instance. |
||
183 | * |
||
184 | * @throws \InvalidArgumentException for invalid password. |
||
185 | * |
||
186 | * @return static |
||
187 | */ |
||
188 | 9 | public function withPass($pass) |
|
192 | |||
193 | /** |
||
194 | * @inheritdoc |
||
195 | */ |
||
196 | 655 | protected function assertValidObject() |
|
199 | } |
||
200 |
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 given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.