Skip to content

Commit

Permalink
[TASK] Fix phpstan checkFunctionArgumentTypes errors in several exten…
Browse files Browse the repository at this point in the history
…sions

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.

Releases: master, 10.4
Resolves: #92161
Resolves: #92164
Resolves: #92175
Resolves: #92176
Resolves: #92177
Resolves: #92178
Change-Id: I420ea01ba1d277f9a9147d076bc58a13175c8afb
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65540
Tested-by: Oliver Bartsch <bo@cedev.de>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Oliver Bartsch <bo@cedev.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
  • Loading branch information
ervaude authored and andreaskienast committed Sep 27, 2020
1 parent a8a6b58 commit ad99d66
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion typo3/sysext/adminpanel/Classes/Utility/MemoryUtility.php
Expand Up @@ -38,7 +38,7 @@ class MemoryUtility
*/
public static function isMemoryConsumptionTooHigh(): bool
{
$iniLimit = ini_get('memory_limit');
$iniLimit = (string)ini_get('memory_limit');
$memoryLimit = $iniLimit === '-1' ? -1 : GeneralUtility::getBytesFromSizeMeasurement($iniLimit);
$freeMemory = $memoryLimit - memory_get_usage(true);

Expand Down
Expand Up @@ -101,9 +101,9 @@ protected function calculateDataForLastDays(): void
$format = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] ?: 'Y-m-d';

for ($daysBefore = $this->days; $daysBefore >= 0; $daysBefore--) {
$this->labels[] = date($format, strtotime('-' . $daysBefore . ' day'));
$startPeriod = strtotime('-' . $daysBefore . ' day 0:00:00');
$endPeriod = strtotime('-' . $daysBefore . ' day 23:59:59');
$this->labels[] = date($format, (int)strtotime('-' . $daysBefore . ' day'));
$startPeriod = (int)strtotime('-' . $daysBefore . ' day 0:00:00');
$endPeriod = (int)strtotime('-' . $daysBefore . ' day 23:59:59');

$this->data[] = $this->getNumberOfErrorsInPeriod($startPeriod, $endPeriod);
}
Expand Down
2 changes: 1 addition & 1 deletion typo3/sysext/reports/Classes/Report/Status/Typo3Status.php
Expand Up @@ -64,7 +64,7 @@ protected function getRegisteredXclassStatus()
foreach ($xclassFoundArray as $originalClass => $xClassName) {
$messageDetail = sprintf(
$this->getLanguageService()->getLL('status_xclassUsageFound_message_detail'),
'<code>' . htmlspecialchars($originalClass) . '</code>',
'<code>' . htmlspecialchars((string)$originalClass) . '</code>',
'<code>' . htmlspecialchars($xClassName) . '</code>'
);
$message .= '<li>' . $messageDetail . '</li>';
Expand Down
Expand Up @@ -230,7 +230,7 @@ protected function renderLinkAttributeFields()
$selected = 'selected="selected"';
}
$classLabel = !empty($this->thisConfig['classes'][$class]['name'])
? $this->getPageConfigLabel($this->thisConfig['classes'][$class]['name'], 0)
? $this->getPageConfigLabel($this->thisConfig['classes'][$class]['name'], false)
: $class;
$classStyle = !empty($this->thisConfig['classes'][$class]['value'])
? $this->thisConfig['classes'][$class]['value']
Expand Down
Expand Up @@ -228,7 +228,7 @@ protected function getCkEditorRequireJsModuleCode(string $fieldId): string
$externalPlugins .= '\'\');';
}

$jsonConfiguration = json_encode($configuration);
$jsonConfiguration = (string)json_encode($configuration);

// Make a hash of the configuration and append it to CKEDITOR.timestamp
// This will mitigate browser caching issue when plugins are updated
Expand Down Expand Up @@ -428,8 +428,8 @@ protected function prepareConfigurationForEditor(): array
*/
protected function sanitizeFieldId(string $itemFormElementName): string
{
$fieldId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $itemFormElementName);
return htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $fieldId));
$fieldId = (string)preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $itemFormElementName);
return htmlspecialchars((string)preg_replace('/^[^a-zA-Z]/', 'x', $fieldId));
}

/**
Expand Down
Expand Up @@ -223,7 +223,7 @@ protected function getHTMLCodeForEditor(

if (!empty($hiddenfields)) {
foreach ($hiddenfields as $attributeName => $value) {
$code[] = '<input type="hidden" name="' . htmlspecialchars($attributeName) . '" value="' . htmlspecialchars((string)$value) . '" />';
$code[] = '<input type="hidden" name="' . htmlspecialchars((string)$attributeName) . '" value="' . htmlspecialchars((string)$value) . '" />';
}
}
return implode(LF, $code);
Expand Down
Expand Up @@ -194,6 +194,7 @@ public function mainAction(ServerRequestInterface $request): ResponseInterface
$this->request = $request;
$this->id = (int)($request->getParsedBody()['id'] ?? $request->getQueryParams()['id'] ?? 0);
$changedMenuSettings = $request->getParsedBody()['SET'] ?? $request->getQueryParams()['SET'] ?? [];
$changedMenuSettings = is_array($changedMenuSettings) ? $changedMenuSettings : [];
$this->menuConfig($changedMenuSettings);
// Loads $this->extClassConf with the configuration for the CURRENT function of the menu.
$this->extClassConf = $this->getExternalItemConfig('web_ts', 'function', $this->MOD_SETTINGS['function']);
Expand Down Expand Up @@ -630,7 +631,7 @@ protected function getHookObjectForAction($action)
* Then MOD_SETTINGS array is cleaned up (see \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData()) so it contains only valid values. It's also updated with any SET[] values submitted.
* Also loads the modTSconfig internal variable.
*
* @param array|string|null $changedSettings can be anything
* @param array $changedSettings can be anything
* @see mainAction()
* @see \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleData()
* @see mergeExternalItems()
Expand Down Expand Up @@ -699,7 +700,7 @@ protected function getExternalItemConfig($modName, $menuKey, $value = '')
* If an instance is created it is initiated with $this passed as value and $this->extClassConf as second argument. Further the $this->MOD_SETTING is cleaned up again after calling the init function.
*
* @see \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction()
* @param array|string|null $changedSettings
* @param array $changedSettings
* @param ServerRequestInterface $request
*/
protected function checkExtObj($changedSettings, ServerRequestInterface $request)
Expand Down
8 changes: 4 additions & 4 deletions typo3/sysext/tstemplate/ext_tables.php
Expand Up @@ -19,27 +19,27 @@
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
'web_ts',
\TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateConstantEditorModuleFunctionController::class,
null,
'',
'LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:constantEditor'
);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
'web_ts',
\TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateInformationModuleFunctionController::class,
null,
'',
'LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:infoModify'
);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
'web_ts',
\TYPO3\CMS\Tstemplate\Controller\TypoScriptTemplateObjectBrowserModuleFunctionController::class,
null,
'',
'LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:objectBrowser'
);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::insertModuleFunction(
'web_ts',
\TYPO3\CMS\Tstemplate\Controller\TemplateAnalyzerModuleFunctionController::class,
null,
'',
'LLL:EXT:tstemplate/Resources/Private/Language/locallang.xlf:templateAnalyzer'
);

0 comments on commit ad99d66

Please sign in to comment.