Skip to content

Commit

Permalink
[TASK] Clean up PHPDoc comments in ext:felogin
Browse files Browse the repository at this point in the history
Since ext:felogin already uses strict type declarations
for function arguments and return types, various
parameter- and return-type declarations in PHPDoc
comments can safely be removed.

With this patch the following changes are applied:

* removed superfluous @param type declarations
* removed superfluous @return declarations
* removed non-thrown @throws annotations
* added missing function type declarations in tests

Used command:

> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #98139
Releases: main, 11.5
Change-Id: I47749a748e808f6801928951397ed0bff8d6a115
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75446
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
  • Loading branch information
derhansen authored and sbuerk committed Aug 17, 2022
1 parent 807ae96 commit ecf97e1
Show file tree
Hide file tree
Showing 21 changed files with 10 additions and 231 deletions.
10 changes: 0 additions & 10 deletions Build/phpstan/phpstan-baseline.neon
Expand Up @@ -3395,21 +3395,11 @@ parameters:
count: 2
path: ../../typo3/sysext/extensionmanager/Tests/Unit/Utility/EmConfUtilityTest.php

-
message: "#^Method TYPO3\\\\CMS\\\\FrontendLogin\\\\Configuration\\\\RedirectConfiguration\\:\\:fromSettings\\(\\) should return static\\(TYPO3\\\\CMS\\\\FrontendLogin\\\\Configuration\\\\RedirectConfiguration\\) but returns TYPO3\\\\CMS\\\\FrontendLogin\\\\Configuration\\\\RedirectConfiguration\\.$#"
count: 1
path: ../../typo3/sysext/felogin/Classes/Configuration/RedirectConfiguration.php

-
message: "#^Method TYPO3\\\\CMS\\\\FrontendLogin\\\\Controller\\\\PasswordRecoveryController\\:\\:changePasswordAction\\(\\) should return Psr\\\\Http\\\\Message\\\\ResponseInterface\\|string\\|null but return statement is missing\\.$#"
count: 1
path: ../../typo3/sysext/felogin/Classes/Controller/PasswordRecoveryController.php

-
message: "#^PHPDoc tag @param references unknown parameter\\: \\$settings$#"
count: 1
path: ../../typo3/sysext/felogin/Tests/Unit/Redirect/RedirectHandlerTest.php

-
message: "#^Negated boolean expression is always false\\.$#"
count: 1
Expand Down
Expand Up @@ -92,8 +92,6 @@ public function __construct(

/**
* Returns the forgot hash.
*
* @return string
*/
public function getForgotHash(): string
{
Expand All @@ -103,8 +101,6 @@ public function getForgotHash(): string
/**
* Returns an instance of TemplatePaths with paths configured in felogin TypoScript and
* paths configured in $GLOBALS['TYPO3_CONF_VARS']['MAIL'].
*
* @return TemplatePaths
*/
public function getMailTemplatePaths(): TemplatePaths
{
Expand All @@ -126,8 +122,6 @@ public function getMailTemplatePaths(): TemplatePaths

/**
* Returns email template name configured in TypoScript
*
* @return string
*/
public function getMailTemplateName(): string
{
Expand All @@ -136,8 +130,6 @@ public function getMailTemplateName(): string

/**
* Returns TTL timestamp of the forgot hash
*
* @return int
*/
public function getLifeTimeTimestamp(): int
{
Expand All @@ -152,8 +144,6 @@ public function getLifeTimeTimestamp(): int

/**
* Returns reply-to address if configured otherwise null.
*
* @return Address|null
*/
public function getReplyTo(): ?Address
{
Expand All @@ -162,8 +152,6 @@ public function getReplyTo(): ?Address

/**
* Returns the sender. Normally the current typo3 installation.
*
* @return Address
*/
public function getSender(): Address
{
Expand Down
Expand Up @@ -98,9 +98,6 @@ public function getPageOnLogout(): int

/**
* Factory when creating a configuration out of Extbase / plugin settings.
*
* @param array $settings
* @return static
*/
public static function fromSettings(array $settings): self
{
Expand Down
Expand Up @@ -24,8 +24,6 @@ abstract class AbstractLoginFormController extends ActionController
{
/**
* Returns the parsed storagePid list including recursions
*
* @return array
*/
protected function getStorageFolders(): array
{
Expand Down
13 changes: 0 additions & 13 deletions typo3/sysext/felogin/Classes/Controller/LoginController.php
Expand Up @@ -170,9 +170,6 @@ public function loginAction(): ResponseInterface

/**
* User overview for logged in users
*
* @param bool $showLoginMessage
* @return ResponseInterface
*/
public function overviewAction(bool $showLoginMessage = false): ResponseInterface
{
Expand All @@ -196,8 +193,6 @@ public function overviewAction(bool $showLoginMessage = false): ResponseInterfac

/**
* Show logout form
* @param int $redirectPageLogout
* @return ResponseInterface
*/
public function logoutAction(int $redirectPageLogout = 0): ResponseInterface
{
Expand Down Expand Up @@ -246,8 +241,6 @@ protected function handleLoginForwards(): ?ResponseInterface
/**
* The permanent login checkbox should only be shown if permalogin is not deactivated (-1),
* not forced to be always active (2) and lifetime is greater than 0
*
* @return int
*/
protected function getPermaloginStatus(): int
{
Expand All @@ -265,8 +258,6 @@ protected function isPermaloginDisabled(int $permaLogin): bool

/**
* Redirect to overview on login successful and setting showLogoutFormAfterLogin disabled
*
* @return bool
*/
protected function shouldRedirectToOverview(): bool
{
Expand All @@ -277,8 +268,6 @@ protected function shouldRedirectToOverview(): bool

/**
* Return message key based on user login status
*
* @return string
*/
protected function getStatusMessageKey(): string
{
Expand All @@ -299,8 +288,6 @@ protected function isLoginOrLogoutInProgress(): bool

/**
* Is redirect disabled by setting or noredirect parameter
*
* @return bool
*/
public function isRedirectDisabled(): bool
{
Expand Down
Expand Up @@ -135,9 +135,6 @@ protected function validateIfHashHasExpired()

/**
* Show the change password form if a valid hash is available.
*
* @param string $hash
* @return ResponseInterface
*/
public function showChangePasswordAction(string $hash = ''): ResponseInterface
{
Expand Down Expand Up @@ -238,8 +235,6 @@ public function changePasswordAction(string $newPass, string $hash)
}

/**
* @param Result $originalResult
*
* @throws NoSuchArgumentException
*/
protected function validateNewPassword(Result $originalResult): void
Expand Down Expand Up @@ -267,10 +262,6 @@ protected function validateNewPassword(Result $originalResult): void

/**
* Wrapper to mock LocalizationUtility::translate
*
* @param string $key
*
* @return string
*/
protected function getTranslation(string $key): string
{
Expand Down Expand Up @@ -328,8 +319,7 @@ protected function notifyPasswordChange(string $newPassword, string $hashedPassw
}

/**
* @param string|null $email
* @return bool
* Returns whether the `exposeNonexistentUserInForgotPasswordDialog` setting is active or not
*/
protected function exposeNoneExistentUser(?string $email): bool
{
Expand Down
Expand Up @@ -48,10 +48,6 @@ public function getTable(): string
return $this->table;
}

/**
* @param int $groupId
* @return int|null
*/
public function findRedirectPageIdByGroupId(int $groupId): ?int
{
$queryBuilder = $this->connection->createQueryBuilder();
Expand Down
Expand Up @@ -60,8 +60,6 @@ public function getTable(): string
/**
* Change the password for a user based on forgot password hash.
*
* @param string $forgotPasswordHash The hash of the feUser that should be resolved.
* @param string $hashedPassword The new password.
* @throws \TYPO3\CMS\Core\Context\Exception\AspectNotFoundException
*/
public function updatePasswordAndInvalidateHash(string $forgotPasswordHash, string $hashedPassword): void
Expand All @@ -83,9 +81,6 @@ public function updatePasswordAndInvalidateHash(string $forgotPasswordHash, stri

/**
* Returns true if an user exists with hash as `felogin_forgothash`, otherwise false.
*
* @param string $hash The hash of the feUser that should be check for existence.
* @return bool Either true or false based on the existence of the user.
*/
public function existsUserWithHash(string $hash): bool
{
Expand All @@ -107,9 +102,6 @@ public function existsUserWithHash(string $hash): bool

/**
* Sets forgot hash for passed email address.
*
* @param string $emailAddress
* @param string $hash
*/
public function updateForgotHashForUserByEmail(string $emailAddress, string $hash): void
{
Expand All @@ -130,9 +122,6 @@ public function updateForgotHashForUserByEmail(string $emailAddress, string $has
/**
* Fetches array containing uid, username, email, first_name, middle_name & last_name by email
* or empty array if user was not found.
*
* @param string $emailAddress
* @return array
*/
public function fetchUserInformationByEmail(string $emailAddress): array
{
Expand All @@ -155,11 +144,6 @@ public function fetchUserInformationByEmail(string $emailAddress): array
return $result;
}

/**
* @param string $usernameOrEmail
* @param array $pages
* @return string|null
*/
public function findEmailByUsernameOrEmailOnPages(string $usernameOrEmail, array $pages = []): ?string
{
if ($usernameOrEmail === '') {
Expand Down Expand Up @@ -187,10 +171,6 @@ public function findEmailByUsernameOrEmailOnPages(string $usernameOrEmail, array
return $column === false || $column === '' ? null : (string)$column;
}

/**
* @param string $hash
* @return array|null
*/
public function findOneByForgotPasswordHash(string $hash): ?array
{
if ($hash === '') {
Expand All @@ -214,10 +194,6 @@ public function findOneByForgotPasswordHash(string $hash): ?array
return is_array($row) ? $row : null;
}

/**
* @param int $uid
* @return int|null
*/
public function findRedirectIdPageByUserId(int $uid): ?int
{
$queryBuilder = $this->connection->createQueryBuilder();
Expand Down
46 changes: 1 addition & 45 deletions typo3/sysext/felogin/Classes/Redirect/RedirectHandler.php
Expand Up @@ -54,13 +54,7 @@ public function __construct(
}

/**
* Process redirect modes. The function searches for a redirect url using all configured modes.
*
* @param string $loginType
* @param RedirectConfiguration $configuration
* @param string $redirectModeReferrer
* @return string Redirect URL
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
* Process redirect modes. This method searches for a redirect url using all configured modes and returns it.
*/
public function processRedirect(string $loginType, RedirectConfiguration $configuration, string $redirectModeReferrer): string
{
Expand Down Expand Up @@ -88,10 +82,6 @@ public function processRedirect(string $loginType, RedirectConfiguration $config

/**
* Get alternative logout form redirect url if logout and page not accessible
*
* @param array $redirectModes
* @param int $redirectPageLogout
* @return string
*/
protected function getLogoutRedirectUrl(array $redirectModes, int $redirectPageLogout = 0): string
{
Expand All @@ -103,9 +93,6 @@ protected function getLogoutRedirectUrl(array $redirectModes, int $redirectPageL

/**
* Is used for alternative redirect urls on redirect mode "getpost"
*
* @param array $redirectModes
* @return string
*/
protected function getGetpostRedirectUrl(array $redirectModes): string
{
Expand All @@ -116,10 +103,6 @@ protected function getGetpostRedirectUrl(array $redirectModes): string

/**
* Handle redirect mode logout
*
* @param string $redirectMode
* @param int $redirectPageLogout
* @return string
*/
protected function handleSuccessfulLogout(string $redirectMode, int $redirectPageLogout): string
{
Expand All @@ -131,10 +114,6 @@ protected function handleSuccessfulLogout(string $redirectMode, int $redirectPag

/**
* Base on setting redirectFirstMethod get first or last entry from redirect url list.
*
* @param array $redirectUrlList
* @param string $redirectFirstMethod
* @return string
*/
protected function fetchReturnUrlFromList(array $redirectUrlList, $redirectFirstMethod): string
{
Expand All @@ -154,13 +133,6 @@ protected function fetchReturnUrlFromList(array $redirectUrlList, $redirectFirst

/**
* Generate redirect_url for case that the user was successfully logged in
*
* @param string $redirectMode
* @param int $redirectPageLogin
* @param string $domains
* @param string $redirectModeReferrer
* @return string
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
*/
protected function handleSuccessfulLogin(string $redirectMode, int $redirectPageLogin = 0, string $domains = '', string $redirectModeReferrer = ''): string
{
Expand Down Expand Up @@ -202,24 +174,13 @@ protected function isUserLoginFailedAndLoginErrorActive(array $redirectModes, st
&& $this->isRedirectModeActive($redirectModes, RedirectMode::LOGIN_ERROR);
}

/**
* Checks if the give mode is active or not
*
* @param string $mode
* @param array $redirectModes
* @return bool
*/
protected function isRedirectModeActive(array $redirectModes, string $mode): bool
{
return in_array($mode, $redirectModes, true);
}

/**
* Returns the redirect Url that should be used in login form template for GET/POST redirect mode
*
* @param RedirectConfiguration $configuration
* @param bool $redirectDisabled
* @return string
*/
public function getLoginFormRedirectUrl(RedirectConfiguration $configuration, bool $redirectDisabled): string
{
Expand All @@ -231,11 +192,6 @@ public function getLoginFormRedirectUrl(RedirectConfiguration $configuration, bo

/**
* Returns the redirect Url that should be used in logout form
*
* @param RedirectConfiguration $configuration
* @param int $redirectPageLogout
* @param bool $redirectDisabled
* @return string
*/
public function getLogoutFormRedirectUrl(RedirectConfiguration $configuration, int $redirectPageLogout, bool $redirectDisabled): string
{
Expand Down

0 comments on commit ecf97e1

Please sign in to comment.