Commit dc620aea authored by Benni Mack's avatar Benni Mack Committed by Georg Ringer
Browse files

[TASK] Reduce invalid arguments mentioned by PHPStan

Resolves: #94571
Releases: master
Change-Id: Ic84bf7ba69ef5b020f91661ff5387ef4b62f34f2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69905


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Daniel Goerz's avatarDaniel Goerz <daniel.goerz@posteo.de>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Daniel Goerz's avatarDaniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
parent d418d600
......@@ -134,34 +134,6 @@ parameters:
path: typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
# Ignored errors for level 5
-
message: "#^Parameter \\#2 \\$suffix of method TYPO3\\\\CMS\\\\Core\\\\Database\\\\QueryGenerator\\:\\:cleanInputVal\\(\\) expects string, int given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Database/QueryGenerator.php
-
message: "#^Parameter \\#3 \\$draw of method TYPO3\\\\CMS\\\\Core\\\\Database\\\\QueryGenerator\\:\\:mkOperatorSelect\\(\\) expects bool, int given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Database/QueryGenerator.php
-
message: "#^Parameter \\#2 \\$first of method TYPO3\\\\CMS\\\\Core\\\\Database\\\\QueryGenerator\\:\\:getQuerySingle\\(\\) expects bool, int given\\.$#"
count: 2
path: typo3/sysext/core/Classes/Database/QueryGenerator.php
-
message: "#^Parameter \\#2 \\$item of static method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\GeneralUtility\\:\\:inList\\(\\) expects string, \\(float\\|int\\) given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Database/QueryGenerator.php
-
message: "#^Parameter \\#2 \\$first of method TYPO3\\\\CMS\\\\Core\\\\Database\\\\QueryGenerator\\:\\:getUserDefQuery\\(\\) expects bool, int given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Database/QueryGenerator.php
-
message: "#^Parameter \\#2 \\$replace of function str_replace expects array\\|string, int given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Database/QueryGenerator.php
-
message: "#^Parameter \\#2 \\$storeIndex of method TYPO3\\\\CMS\\\\Core\\\\Database\\\\QueryView\\:\\:loadStoreQueryConfigs\\(\\) expects int, string given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Database/QueryView.php
-
message: "#^Parameter \\#1 \\$constraint of static method TYPO3\\\\CMS\\\\Core\\\\Database\\\\Query\\\\QueryHelper\\:\\:stripLogicalOperatorPrefix\\(\\) expects string, string\\|null given\\.$#"
count: 1
......@@ -250,10 +222,6 @@ parameters:
message: "#^Parameter \\#1 \\$node of method TYPO3\\\\CMS\\\\Backend\\\\Tree\\\\Renderer\\\\UnorderedListTreeRenderer\\:\\:renderNode\\(\\) expects TYPO3\\\\CMS\\\\Backend\\\\Tree\\\\TreeRepresentationNode, TYPO3\\\\CMS\\\\Backend\\\\Tree\\\\TreeNode given\\.$#"
count: 1
path: typo3/sysext/backend/Classes/Tree/Renderer/UnorderedListTreeRenderer.php
-
message: "#^Parameter \\#1 \\$result of method TYPO3\\\\CMS\\\\Backend\\\\Controller\\\\File\\\\FileController\\:\\:flattenResultDataValue\\(\\) expects bool\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Folder, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ProcessedFile given\\.$#"
count: 1
path: typo3/sysext/backend/Classes/Controller/File/FileController.php
-
# Obsolete in v12, when either entire Request or __construct() are declared final
message: "#^Unsafe usage of new static\\(\\)\\.$#"
......
......@@ -300,7 +300,7 @@ class FileController
*
* The value can be a File, Folder or boolean
*
* @param bool|File|Folder $result
* @param bool|File|Folder|ProcessedFile $result
*
* @return bool|string|array
*/
......
......@@ -588,7 +588,7 @@ class QueryGenerator
}
$queryConfig[$key]['comparison'] = $this->verifyComparison($conf['comparison'], $conf['negate'] ? 1 : 0);
$queryConfig[$key]['inputValue'] = $this->cleanInputVal($queryConfig[$key]);
$queryConfig[$key]['inputValue1'] = $this->cleanInputVal($queryConfig[$key], 1);
$queryConfig[$key]['inputValue1'] = $this->cleanInputVal($queryConfig[$key], '1');
}
}
return $queryConfig;
......@@ -615,7 +615,7 @@ class QueryGenerator
$fieldName = '';
$subscript = $parent . '[' . $key . ']';
$lineHTML = [];
$lineHTML[] = $this->mkOperatorSelect($this->name . $subscript, $conf['operator'], $c, $conf['type'] !== 'FIELD_');
$lineHTML[] = $this->mkOperatorSelect($this->name . $subscript, $conf['operator'], $c > 0, $conf['type'] !== 'FIELD_');
if (strpos($conf['type'], 'FIELD_') === 0) {
$fieldName = substr($conf['type'], 6);
$this->fieldName = $fieldName;
......@@ -732,7 +732,7 @@ class QueryGenerator
}
$lineHTML[] = '</div>';
$codeArr[$arrCount]['html'] = implode(LF, $lineHTML);
$codeArr[$arrCount]['query'] = $this->getQuerySingle($conf, $c > 0 ? 0 : 1);
$codeArr[$arrCount]['query'] = $this->getQuerySingle($conf, $c === 0);
$arrCount++;
$c++;
}
......@@ -779,22 +779,23 @@ class QueryGenerator
$languageService = $this->getLanguageService();
if ($fieldSetup['type'] === 'multiple') {
$optGroupOpen = false;
foreach ($fieldSetup['items'] as $key => $val) {
foreach ($fieldSetup['items'] as $val) {
if (strpos($val[0], 'LLL:') === 0) {
$value = $languageService->sL($val[0]);
} else {
$value = $val[0];
}
if ($val[1] === '--div--') {
$itemVal = (string)($val[1] ?? '');
if ($itemVal === '--div--') {
if ($optGroupOpen) {
$out[] = '</optgroup>';
}
$optGroupOpen = true;
$out[] = '<optgroup label="' . htmlspecialchars($value) . '">';
} elseif (GeneralUtility::inList($conf['inputValue'], $val[1])) {
$out[] = '<option value="' . htmlspecialchars($val[1]) . '" selected>' . htmlspecialchars($value) . '</option>';
} elseif (GeneralUtility::inList($conf['inputValue'], $itemVal)) {
$out[] = '<option value="' . htmlspecialchars($itemVal) . '" selected>' . htmlspecialchars($value) . '</option>';
} else {
$out[] = '<option value="' . htmlspecialchars($val[1]) . '">' . htmlspecialchars($value) . '</option>';
$out[] = '<option value="' . htmlspecialchars($itemVal) . '">' . htmlspecialchars($value) . '</option>';
}
}
if ($optGroupOpen) {
......@@ -808,10 +809,11 @@ class QueryGenerator
} else {
$value = $val[0];
}
if (GeneralUtility::inList($conf['inputValue'], 2 ** $key)) {
$out[] = '<option value="' . 2 ** $key . '" selected>' . htmlspecialchars($value) . '</option>';
$itemVal = (string)(2 ** $key);
if (GeneralUtility::inList($conf['inputValue'], $itemVal)) {
$out[] = '<option value="' . $itemVal . '" selected>' . htmlspecialchars($value) . '</option>';
} else {
$out[] = '<option value="' . 2 ** $key . '">' . htmlspecialchars($value) . '</option>';
$out[] = '<option value="' . $itemVal . '">' . htmlspecialchars($value) . '</option>';
}
}
}
......@@ -819,16 +821,17 @@ class QueryGenerator
$useTablePrefix = 0;
$dontPrefixFirstTable = 0;
if ($fieldSetup['items']) {
foreach ($fieldSetup['items'] as $key => $val) {
foreach ($fieldSetup['items'] as $val) {
if (strpos($val[0], 'LLL:') === 0) {
$value = $languageService->sL($val[0]);
} else {
$value = $val[0];
}
if (GeneralUtility::inList($conf['inputValue'], $val[1])) {
$out[] = '<option value="' . htmlspecialchars($val[1]) . '" selected>' . htmlspecialchars($value) . '</option>';
$outputValue = (string)($val[1] ?? '');
if ($outputValue && GeneralUtility::inList($conf['inputValue'], $outputValue)) {
$out[] = '<option value="' . htmlspecialchars($outputValue) . '" selected>' . htmlspecialchars($value) . '</option>';
} else {
$out[] = '<option value="' . htmlspecialchars($val[1]) . '">' . htmlspecialchars($value) . '</option>';
$out[] = '<option value="' . htmlspecialchars($outputValue) . '">' . htmlspecialchars($value) . '</option>';
}
}
}
......@@ -976,6 +979,7 @@ class QueryGenerator
}
}
foreach ($outArray as $key2 => $val2) {
$key2 = (string)$key2;
if (GeneralUtility::inList($conf['inputValue'], $key2)) {
$out[] = '<option value="' . htmlspecialchars($key2) . '" selected>[' . htmlspecialchars($key2) . '] ' . htmlspecialchars($val2) . '</option>';
} else {
......@@ -1245,7 +1249,7 @@ class QueryGenerator
$qs = '';
// Since we don't traverse the array using numeric keys in the upcoming whileloop make sure it's fresh and clean
ksort($queryConfig);
$first = 1;
$first = true;
foreach ($queryConfig as $key => $conf) {
$conf = $this->convertIso8601DatetimeStringToUnixTimestamp($conf);
switch ($conf['type']) {
......@@ -1261,7 +1265,7 @@ class QueryGenerator
default:
$qs .= LF . $pad . $this->getQuerySingle($conf, $first);
}
$first = 0;
$first = false;
}
return $qs;
}
......@@ -1335,7 +1339,7 @@ class QueryGenerator
foreach ($inputValArray as $fileName) {
$inputVal += (int)$fileName;
}
$qsTmp = str_replace('#VALUE#', $inputVal, $qsTmp);
$qsTmp = str_replace('#VALUE#', (string)$inputVal, $qsTmp);
} else {
if (is_array($inputVal)) {
$inputVal = $inputVal[0];
......
......@@ -331,7 +331,7 @@ class QueryView
if (is_array($dA['qC'])) {
$dbSC[0] = $dA['qC'];
}
$writeArray = $this->loadStoreQueryConfigs($dbSC, '0', $writeArray);
$writeArray = $this->loadStoreQueryConfigs($dbSC, 0, $writeArray);
$saveStoreArray = 1;
$flashMessage = GeneralUtility::makeInstance(
FlashMessage::class,
......
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