Commit 94dd6f06 authored by crell's avatar crell Committed by Nikita Hovratov
Browse files

[TASK] Resolve more dead code paths

More code paths identified as dead by PHPStan, or
that PHPStan isn't understanding correctly.

Used command:

> Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #97649
Releases: main, 11.5
Change-Id: I8ff67b7ebda5d64624d4e42a9775e4709bff3f08
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74677


Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarJoey Bouten <joey.bouten@beech.it>
Reviewed-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
parent 8a25db00
......@@ -100,11 +100,6 @@ parameters:
count: 1
path: ../../typo3/sysext/backend/Classes/Form/Wizard/SuggestWizardDefaultReceiver.php
-
message: "#^Left side of && is always true\\.$#"
count: 1
path: ../../typo3/sysext/backend/Classes/Middleware/BackendUserAuthenticator.php
-
message: "#^Method TYPO3\\\\CMS\\\\Backend\\\\Routing\\\\PreviewUriBuilder\\:\\:create\\(\\) should return static\\(TYPO3\\\\CMS\\\\Backend\\\\Routing\\\\PreviewUriBuilder\\) but returns object\\.$#"
count: 1
......@@ -195,11 +190,6 @@ parameters:
count: 1
path: ../../typo3/sysext/backend/Classes/View/BackendLayout/ContentFetcher.php
-
message: "#^Left side of && is always true\\.$#"
count: 1
path: ../../typo3/sysext/backend/Classes/View/PageLayoutView.php
-
message: "#^Variable \\$localizationButtons in empty\\(\\) always exists and is not falsy\\.$#"
count: 1
......@@ -885,11 +875,6 @@ parameters:
count: 1
path: ../../typo3/sysext/core/Classes/LinkHandling/LinkService.php
-
message: "#^Left side of && is always true\\.$#"
count: 1
path: ../../typo3/sysext/core/Classes/LinkHandling/LinkService.php
-
message: "#^Result of \\|\\| is always true\\.$#"
count: 1
......@@ -3475,11 +3460,6 @@ parameters:
count: 1
path: ../../typo3/sysext/frontend/Classes/ContentObject/LoadRegisterContentObject.php
-
message: "#^Left side of && is always true\\.$#"
count: 1
path: ../../typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
-
message: "#^Negated boolean expression is always false\\.$#"
count: 1
......
......@@ -241,7 +241,7 @@ class BackendUserAuthenticator extends \TYPO3\CMS\Core\Middleware\BackendUserAut
}
$loginRateLimiter = $this->rateLimiterFactory->createLoginRateLimiter($user, $request);
$limit = $loginRateLimiter->consume();
if ($limit && !$limit->isAccepted()) {
if (!$limit->isAccepted()) {
$this->logger->debug('Login request has been rate limited for IP address {ipAddress}', ['ipAddress' => $request->getAttribute('normalizedParams')->getRemoteAddress()]);
$dateformat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
$lockedUntil = $limit->getRetryAfter()->getTimestamp() > 0 ?
......
......@@ -1017,7 +1017,7 @@ class PageLayoutView implements LoggerAwareInterface
. ' data-button-close-text="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:cancel')) . '"'
. ' title="' . htmlspecialchars($this->getLanguageService()->getLL('deleteItem')) . '">'
. $this->iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render() . '</a>';
if ($out && $this->hasContentModificationAndAccessPermissions()) {
if ($this->hasContentModificationAndAccessPermissions()) {
$out = '<div class="btn-group btn-group-sm" role="group">' . $out . '</div>';
} else {
$out = '';
......
......@@ -128,13 +128,13 @@ class LinkService implements SingletonInterface
if ($fragment) {
$result['fragment'] = $fragment;
}
} elseif ($this->handlers[self::TYPE_URL] && PathUtility::hasProtocolAndScheme($urn)) {
} elseif (($this->handlers[self::TYPE_URL] ?? false) && PathUtility::hasProtocolAndScheme($urn)) {
$result = $this->handlers[self::TYPE_URL]->resolveHandlerData(['url' => $urn]);
$result['type'] = self::TYPE_URL;
} elseif (($this->handlers[self::TYPE_EMAIL] ?? false) && str_starts_with(strtolower($urn), 'mailto:')) {
$result = $this->handlers[self::TYPE_EMAIL]->resolveHandlerData(['email' => $urn]);
$result['type'] = self::TYPE_EMAIL;
} elseif (($this->handlers[self::TYPE_TELEPHONE] ?? false) && str_starts_with(strtolower($urn), 'tel:')) {
} elseif (($this->handlers[self::TYPE_TELEPHONE] ?? false) && str_starts_with(strtolower($urn), 'tel:')) {
$result = $this->handlers[self::TYPE_TELEPHONE]->resolveHandlerData(['telephone' => $urn]);
$result['type'] = self::TYPE_TELEPHONE;
} else {
......
......@@ -784,7 +784,7 @@ abstract class AbstractMenuContentObject
$pageRecords = $this->sys_page->getMenuForPages($pageIds, '*', $sortingField ?: $sortField . ' DESC', $extraWhere);
foreach ($pageRecords as $row) {
// Build a custom LIMIT clause as "getMenuForPages()" does not support this
if ($limit && ++$i > $limit) {
if (++$i > $limit) {
continue;
}
$menuItems[$row['uid']] = $row;
......
Supports Markdown
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