11<?php
22
3+ declare (strict_types=1 );
4+
35/**
46 * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
57 * SPDX-FileCopyrightText: 2017-2019 Cooperativa EITA <eita.org.br>
@@ -48,7 +50,7 @@ public function __construct(
4850 * @return int bitwise-or'ed actions
4951 */
5052 #[\Override]
51- public function respondToActions () {
53+ public function respondToActions (): int {
5254 $ setPassword = $ this ->canSetPassword () && !$ this ->ldapConnect ->hasPasswordPolicy ()
5355 ? Backend::SET_PASSWORD
5456 : 0 ;
@@ -63,12 +65,11 @@ public function respondToActions() {
6365 *
6466 * @param string $uid user ID of the user
6567 * @param string $displayName new user's display name
66- * @return string
6768 * @throws HintException
6869 * @throws ServerNotAvailableException
6970 */
7071 #[\Override]
71- public function setDisplayName ($ uid , $ displayName ) {
72+ public function setDisplayName ($ uid , $ displayName ): string {
7273 $ userDN = $ this ->getUserDN ($ uid );
7374
7475 $ connection = $ this ->ldapProvider ->getLDAPConnection ($ uid );
@@ -106,10 +107,9 @@ public function setDisplayName($uid, $displayName) {
106107 * checks whether the user is allowed to change his avatar in Nextcloud
107108 *
108109 * @param string $uid the Nextcloud user name
109- * @return bool either the user can or cannot
110110 */
111111 #[\Override]
112- public function canChangeAvatar ($ uid ) {
112+ public function canChangeAvatar ($ uid ): bool {
113113 return $ this ->configuration ->hasAvatarPermission ();
114114 }
115115
@@ -158,11 +158,10 @@ public function changeEmail(IUser $user, string $newEmail): void {
158158 *
159159 * @param string $uid The username of the user to create
160160 * @param string $password The password of the new user
161- * @return bool|string the created user of false
162161 * @throws Exception
163162 */
164163 #[\Override]
165- public function createUser ($ uid , $ password ) {
164+ public function createUser ($ uid , $ password ): string | false {
166165 $ adminUser = $ this ->userSession ->getUser ();
167166 $ requireActorFromLDAP = $ this ->configuration ->isLdapActorRequired ();
168167 if ($ requireActorFromLDAP && !$ adminUser instanceof IUser) {
@@ -230,7 +229,7 @@ public function ensureAttribute(array &$ldif, string $attribute, string $fallbac
230229 }
231230 }
232231
233- public function buildNewEntry ($ username , $ password , $ base ): array {
232+ private function buildNewEntry (string $ username , string $ password , string $ base ): array {
234233 // Make sure the parameters don't fool the following algorithm
235234 if (str_contains ($ username , PHP_EOL )) {
236235 throw new Exception ('Username contains a new line ' );
@@ -268,10 +267,6 @@ public function buildNewEntry($username, $password, $base): array {
268267 return [$ dn , $ entry ];
269268 }
270269
271- /**
272- * @param $uid
273- * @return bool
274- */
275270 public function deleteUser ($ uid ): bool {
276271 $ connection = $ this ->ldapProvider ->getLDAPConnection ($ uid );
277272 $ userDN = $ this ->getUserDN ($ uid );
@@ -318,12 +313,11 @@ public function canSetPassword(): bool {
318313 *
319314 * @param string $uid The username
320315 * @param string $password The new password
321- * @return bool
322316 *
323317 * Change the password of a user
324318 */
325319 #[\Override]
326- public function setPassword ($ uid , $ password ) {
320+ public function setPassword ($ uid , $ password ): bool {
327321 $ connection = $ this ->ldapProvider ->getLDAPConnection ($ uid );
328322 $ userDN = $ this ->getUserDN ($ uid );
329323
@@ -334,10 +328,9 @@ public function setPassword($uid, $password) {
334328 * get the user's home directory
335329 *
336330 * @param string $uid the username
337- * @return bool
338331 */
339332 #[\Override]
340- public function getHome ($ uid ) {
333+ public function getHome ($ uid ): bool {
341334 // Not implemented
342335 return false ;
343336 }
@@ -346,21 +339,18 @@ public function getHome($uid) {
346339 * get display name of the user
347340 *
348341 * @param string $uid user ID of the user
349- * @return string display name
350342 */
351343 #[\Override]
352- public function getDisplayName ($ uid ) {
344+ public function getDisplayName ($ uid ): string {
353345 // Not implemented
354346 return $ uid ;
355347 }
356348
357349 /**
358350 * Count the number of users
359- *
360- * @return int|bool
361351 */
362352 #[\Override]
363- public function countUsers () {
353+ public function countUsers (): false {
364354 // Not implemented
365355 return false ;
366356 }
@@ -398,7 +388,7 @@ public function changeUserHook(IUser $user, string $feature, $attr1, $attr2): vo
398388 }
399389 }
400390
401- private function getUserDN ($ uid ): string {
391+ private function getUserDN (string $ uid ): string {
402392 return $ this ->ldapProvider ->getUserDN ($ uid );
403393 }
404394
0 commit comments