Skip to content

Commit

Permalink
[TASK] Fix phpstan checkFunctionArgumentTypes errors in ext:recordlist
Browse files Browse the repository at this point in the history
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: #92172
Releases: master, 10.4
Change-Id: I9c01e01e6d085acc5e9399ba307b082436bb34b5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65905
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
  • Loading branch information
alexanderschnitzler authored and andreaskienast committed Sep 27, 2020
1 parent 323a63d commit 5155186
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ protected function setBodyTagParameters()
}

/**
* @return string[] Array of body-tag attributes
* @return array<string, string> Array of body-tag attributes
*/
abstract protected function getBodyTagAttributes();

/**
* Splits parts of $this->bparams and returns needed data attributes for the Javascript
*
* @return string[] Data attributes for Javascript
* @return array<string, string> Data attributes for Javascript
*/
protected function getBParamDataAttributes()
{
Expand Down
4 changes: 2 additions & 2 deletions typo3/sysext/recordlist/Classes/Browser/FileBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ public function renderFilesInFolder(Folder $folder, array $extensionList = [], $
'fileIcon' => $icon
];
if ($this->fileIsSelectableInFileList($fileObject, $imgInfo)) {
$ATag = '<a href="#" class="btn btn-default" title="' . htmlspecialchars($fileObject->getName()) . '" data-file-index="' . htmlspecialchars($filesIndex) . '" data-close="0">';
$ATag = '<a href="#" class="btn btn-default" title="' . htmlspecialchars($fileObject->getName()) . '" data-file-index="' . $filesIndex . '" data-close="0">';
$ATag .= '<span title="' . htmlspecialchars($lang->getLL('addToList')) . '">' . $this->iconFactory->getIcon('actions-add', Icon::SIZE_SMALL)->render() . '</span>';
$ATag_alt = '<a href="#" title="' . htmlspecialchars($fileObject->getName()) . $size . '" data-file-index="' . htmlspecialchars($filesIndex) . '" data-close="1">';
$ATag_alt = '<a href="#" title="' . htmlspecialchars($fileObject->getName()) . $size . '" data-file-index="' . $filesIndex . '" data-close="1">';
$ATag_e = '</a>';
$bulkCheckBox = '<label class="btn btn-default btn-checkbox"><input type="checkbox" class="typo3-bulk-item" name="file_' . $filesIndex . '" value="0" /><span class="t3-icon fa"></span></label>';
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ protected function loadLinkHandlers()
/**
* Reads the configured link handlers from page TSconfig
*
* @return array
* @return array<string, array<mixed>>
*/
protected function getLinkHandlers()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public function mainAction(ServerRequestInterface $request): ResponseInterface
if (!empty($items)) {
$cmd = [];
foreach ($items as $iK => $value) {
$iKParts = explode('|', $iK);
$iKParts = explode('|', (string)$iK);
$cmd[$iKParts[0]][$iKParts[1]]['delete'] = 1;
}
$tce = GeneralUtility::makeInstance(DataHandler::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ protected function renderItem(ResourceInterface $fileOrFolderObject)
}
// Get size and icon:
$size = GeneralUtility::formatSize(
$fileOrFolderObject->getSize(),
(int)$fileOrFolderObject->getSize(),
$this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:byteSizeUnits')
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1563,7 +1563,7 @@ protected function getPointerForPage($page, int $iLimit)
*/
protected function renderListNavigation($renderPart, int $totalItems, int $iLimit, string $table)
{
$totalPages = ceil($totalItems / $iLimit);
$totalPages = (int)ceil($totalItems / $iLimit);
// Show page selector if not all records fit into one page
if ($totalPages <= 1) {
return '';
Expand All @@ -1572,7 +1572,7 @@ protected function renderListNavigation($renderPart, int $totalItems, int $iLimi
$listURL = $this->listURL('', $this->table, 'firstElementNumber');
// 1 = first page
// 0 = first element
$currentPage = floor($this->firstElementNumber / $iLimit) + 1;
$currentPage = (int)floor($this->firstElementNumber / $iLimit) + 1;
// Compile first, previous, next, last and refresh buttons
if ($currentPage > 1) {
$labelFirst = htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_common.xlf:first'));
Expand Down Expand Up @@ -1913,7 +1913,7 @@ public function makeControl($table, $row)
$table,
$row['uid'],
' ' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.referencesToRecord'),
$this->getReferenceCount($table, $row['uid'])
(string)$this->getReferenceCount($table, $row['uid'])
) . BackendUtility::translationCount(
$table,
$row['uid'],
Expand Down Expand Up @@ -2426,6 +2426,7 @@ public function showNewRecLink($table)
protected function addHeaderRowToCSV()
{
$fieldArray = array_combine($this->fieldArray, $this->fieldArray);
$fieldArray = is_array($fieldArray) ? $fieldArray : [];
$hooks = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][__CLASS__]['customizeCsvHeader'] ?? [];
if (!empty($hooks)) {
$hookParameters = [
Expand Down Expand Up @@ -3117,7 +3118,7 @@ public function linkWrapItems($table, $uid, $code, $row)
// Output the label now:
if ($table === 'pages') {
$code = '<a href="' . htmlspecialchars(
$this->listURL($uid, '', 'firstElementNumber')
$this->listURL((string)$uid, '', 'firstElementNumber')
) . '" onclick="setHighlight(' . (int)$uid . ')">' . $code . '</a>';
} else {
$code = $this->linkUrlMail($code, $origCode);
Expand Down

0 comments on commit 5155186

Please sign in to comment.