Skip to content
Snippets Groups Projects
Commit 35f220c3 authored by Alexander Schnitzler's avatar Alexander Schnitzler Committed by Andreas Fernandez
Browse files

[TASK] Fix phpstan checkFunctionArgumentTypes errors in ext:felogin

This patch fixes incompatible type usage in function arguments
and is preparatory work for introducing native type hints and
strict mode in all core files.

Resolves: #92165
Releases: master, 10.4
Change-Id: I1d6cfbbeb233922d1021a853087261ff91abb8be
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65913


Tested-by: default avatarDaniel Goerz <daniel.goerz@posteo.de>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: default avatarDaniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: default avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 51bce1cb
Branches
Tags
No related merge requests found
...@@ -108,6 +108,7 @@ class PasswordRecoveryController extends AbstractLoginFormController ...@@ -108,6 +108,7 @@ class PasswordRecoveryController extends AbstractLoginFormController
protected function validateIfHashHasExpired(): void protected function validateIfHashHasExpired(): void
{ {
$hash = $this->request->hasArgument('hash') ? $this->request->getArgument('hash') : ''; $hash = $this->request->hasArgument('hash') ? $this->request->getArgument('hash') : '';
$hash = is_string($hash) ? $hash : '';
if (!$this->hasValidHash($hash)) { if (!$this->hasValidHash($hash)) {
$this->redirect('recovery', 'PasswordRecovery', 'felogin'); $this->redirect('recovery', 'PasswordRecovery', 'felogin');
...@@ -288,7 +289,7 @@ class PasswordRecoveryController extends AbstractLoginFormController ...@@ -288,7 +289,7 @@ class PasswordRecoveryController extends AbstractLoginFormController
$hashedPassword = $event->getHashedPassword(); $hashedPassword = $event->getHashedPassword();
if ($event->isPropagationStopped()) { if ($event->isPropagationStopped()) {
$requestResult = $this->request->getOriginalRequestMappingResults(); $requestResult = $this->request->getOriginalRequestMappingResults();
$requestResult->addError(new Error($event->getErrorMessage(), 1562846833)); $requestResult->addError(new Error($event->getErrorMessage() ?? '', 1562846833));
$this->request->setOriginalRequestMappingResults($requestResult); $this->request->setOriginalRequestMappingResults($requestResult);
$this->forward( $this->forward(
......
...@@ -158,7 +158,9 @@ class RedirectHandler ...@@ -158,7 +158,9 @@ class RedirectHandler
} }
// Remove empty values, but keep "0" as value (that's why "strlen" is used as second parameter) // Remove empty values, but keep "0" as value (that's why "strlen" is used as second parameter)
$redirectUrlList = array_filter($redirectUrlList, 'strlen'); $redirectUrlList = array_filter($redirectUrlList, static function (string $value): bool {
return strlen($value) > 0;
});
return $redirectFirstMethod return $redirectFirstMethod
? array_shift($redirectUrlList) ? array_shift($redirectUrlList)
......
...@@ -82,8 +82,8 @@ class RedirectUrlValidator implements LoggerAwareInterface ...@@ -82,8 +82,8 @@ class RedirectUrlValidator implements LoggerAwareInterface
*/ */
protected function isInCurrentDomain(string $url): bool protected function isInCurrentDomain(string $url): bool
{ {
$urlWithoutSchema = preg_replace('#^https?://#', '', $url); $urlWithoutSchema = preg_replace('#^https?://#', '', $url) ?? '';
$siteUrlWithoutSchema = preg_replace('#^https?://#', '', GeneralUtility::getIndpEnv('TYPO3_SITE_URL')); $siteUrlWithoutSchema = preg_replace('#^https?://#', '', GeneralUtility::getIndpEnv('TYPO3_SITE_URL')) ?? '';
return strpos($urlWithoutSchema . '/', GeneralUtility::getIndpEnv('HTTP_HOST') . '/') === 0 return strpos($urlWithoutSchema . '/', GeneralUtility::getIndpEnv('HTTP_HOST') . '/') === 0
&& strpos($urlWithoutSchema, $siteUrlWithoutSchema) === 0; && strpos($urlWithoutSchema, $siteUrlWithoutSchema) === 0;
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment