Skip to content

Commit

Permalink
[TASK] Remove unnecessary conditionals
Browse files Browse the repository at this point in the history
PHPStan says all of these are unnecessary. On visual
inspection, it appears to be correct.

Used command:

> ./Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #98001
Releases: main, 11.5
Change-Id: Ic18ce25997357c786b17bc5be02cfdb3617c6eef
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75286
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
  • Loading branch information
Crell authored and sbuerk committed Jul 25, 2022
1 parent 9be8cb6 commit 006ca4b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 48 deletions.
17 changes: 1 addition & 16 deletions Build/phpstan/phpstan-baseline.neon
Expand Up @@ -40,11 +40,6 @@ parameters:
count: 1
path: ../../typo3/sysext/backend/Classes/Controller/EditDocumentController.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: ../../typo3/sysext/backend/Classes/Controller/File/FileController.php

-
message: "#^Parameter \\#1 \\.\\.\\.\\$expressions of method TYPO3\\\\CMS\\\\Core\\\\Database\\\\Query\\\\Expression\\\\ExpressionBuilder\\:\\:orX\\(\\) expects string, TYPO3\\\\CMS\\\\Core\\\\Database\\\\Query\\\\Expression\\\\CompositeExpression given\\.$#"
count: 1
Expand Down Expand Up @@ -4685,11 +4680,6 @@ parameters:
count: 1
path: ../../typo3/sysext/indexed_search/Classes/Domain/Repository/AdministrationRepository.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: ../../typo3/sysext/indexed_search/Classes/Domain/Repository/IndexSearchRepository.php

-
message: "#^Else branch is unreachable because previous condition is always true\\.$#"
count: 2
Expand Down Expand Up @@ -4925,14 +4915,9 @@ parameters:
count: 2
path: ../../typo3/sysext/linkvalidator/Classes/LinkAnalyzer.php

-
message: "#^If condition is always true\\.$#"
count: 1
path: ../../typo3/sysext/linkvalidator/Classes/QueryRestrictions/EditableRestriction.php

-
message: "#^Parameter \\#1 \\.\\.\\.\\$expressions of method TYPO3\\\\CMS\\\\Core\\\\Database\\\\Query\\\\Expression\\\\ExpressionBuilder\\:\\:orX\\(\\) expects string, TYPO3\\\\CMS\\\\Core\\\\Database\\\\Query\\\\Expression\\\\CompositeExpression given\\.$#"
count: 4
count: 3
path: ../../typo3/sysext/linkvalidator/Classes/QueryRestrictions/EditableRestriction.php

-
Expand Down
10 changes: 3 additions & 7 deletions typo3/sysext/backend/Classes/Controller/File/FileController.php
Expand Up @@ -294,13 +294,9 @@ protected function getFileEditRedirect(File $file): ?string

protected function flattenFileResultDataValue(File $result): array
{
$thumbUrl = '';
if ($result->isImage()) {
$processedFile = $result->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, []);
if ($processedFile) {
$thumbUrl = $processedFile->getPublicUrl() ?? '';
}
}
$thumbUrl = $result->isImage()
? ($result->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, [])->getPublicUrl() ?? '')
: '';
$path = '';
if (is_callable([$result->getParentFolder(), 'getReadablePath'])) {
$path = $result->getParentFolder()->getReadablePath();
Expand Down
Expand Up @@ -623,29 +623,27 @@ protected function getPhashList($searchWords)
$res = $this->searchDistinct($sWord);
}
// If there was a query to do, then select all phash-integers which resulted from this.
if ($res) {
// Get phash list by searching for it:
$phashList = [];
while ($row = $res->fetchAssociative()) {
$phashList[] = $row['phash'];
}
// Here the phash list are merged with the existing result based on whether we are dealing with OR, NOT or AND operations.
if ($c) {
switch ($v['oper']) {
case 'OR':
$totalHashList = array_unique(array_merge($phashList, $totalHashList));
break;
case 'AND NOT':
$totalHashList = array_diff($totalHashList, $phashList);
break;
default:
// AND...
$totalHashList = array_intersect($totalHashList, $phashList);
}
} else {
// First search
$totalHashList = $phashList;
// Get phash list by searching for it:
$phashList = [];
while ($row = $res->fetchAssociative()) {
$phashList[] = $row['phash'];
}
// Here the phash list are merged with the existing result based on whether we are dealing with OR, NOT or AND operations.
if ($c) {
switch ($v['oper']) {
case 'OR':
$totalHashList = array_unique(array_merge($phashList, $totalHashList));
break;
case 'AND NOT':
$totalHashList = array_diff($totalHashList, $phashList);
break;
default:
// AND...
$totalHashList = array_intersect($totalHashList, $phashList);
}
} else {
// First search
$totalHashList = $phashList;
}
$this->getTimeTracker()->pull();
$c++;
Expand Down
Expand Up @@ -229,9 +229,7 @@ public function buildExpression(array $queriedTables, ExpressionBuilder $express
'tx_linkvalidator_link.table_name',
$this->queryBuilder->quote($table)
);
if ($additionalWhere) {
$constraints[] = $expressionBuilder->orX(...$additionalWhere);
}
$constraints[] = $expressionBuilder->or(...$additionalWhere);
}

if ($this->allowedLanguages) {
Expand Down

0 comments on commit 006ca4b

Please sign in to comment.