Commit 903cacc9 authored by Alexander Schnitzler's avatar Alexander Schnitzler Committed by Benni Mack
Browse files

[TASK] Fix phpstan checkFunctionArgumentTypes errors in

ext:scheduler

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: #92159
Change-Id: I8e6a06a81cc12ff4c1bbdb69611d1d1bfd48d109
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65538


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarJörg Bösche <typo3@joergboesche.de>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: default avatarJörg Bösche <typo3@joergboesche.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 36491626
......@@ -693,7 +693,7 @@ class SchedulerModuleController
// Add each field to the display, if there are indeed any
if (is_array($fields)) {
foreach ($fields as $fieldID => $fieldInfo) {
$htmlClassName = strtolower(str_replace('\\', '-', $class));
$htmlClassName = strtolower(str_replace('\\', '-', (string)$class));
$field = [];
$field['htmlClassName'] = $htmlClassName;
$field['code'] = $fieldInfo['code'];
......
......@@ -155,9 +155,9 @@ class CronCommand
*/
protected function dayMatchesCronCommand($timestamp)
{
$dayOfMonth = date('j', $timestamp);
$month = date('n', $timestamp);
$dayOfWeek = date('N', $timestamp);
$dayOfMonth = (int)date('j', $timestamp);
$month = (int)date('n', $timestamp);
$dayOfWeek = (int)date('N', $timestamp);
$isInDayOfMonth = $this->isInCommandList($this->cronCommandSections[2], $dayOfMonth);
$isInMonth = $this->isInCommandList($this->cronCommandSections[3], $month);
$isInDayOfWeek = $this->isInCommandList($this->cronCommandSections[4], $dayOfWeek);
......@@ -190,7 +190,7 @@ class CronCommand
if ((string)$commandExpression === '*') {
$inList = true;
} else {
$inList = GeneralUtility::inList($commandExpression, $numberToMatch);
$inList = GeneralUtility::inList($commandExpression, (string)$numberToMatch);
}
return $inList;
}
......@@ -209,10 +209,10 @@ class CronCommand
*/
protected function numberOfSecondsInDay($timestamp)
{
$now = mktime(0, 0, 0, date('n', $timestamp), date('j', $timestamp), date('Y', $timestamp));
$now = mktime(0, 0, 0, (int)date('n', $timestamp), (int)date('j', $timestamp), (int)date('Y', $timestamp));
// Make sure to be in next day, even if day has 25 hours
$nextDay = $now + 60 * 60 * 25;
$nextDay = mktime(0, 0, 0, date('n', $nextDay), date('j', $nextDay), date('Y', $nextDay));
$nextDay = mktime(0, 0, 0, (int)date('n', $nextDay), (int)date('j', $nextDay), (int)date('Y', $nextDay));
return $nextDay - $now;
}
......@@ -224,6 +224,6 @@ class CronCommand
*/
protected function roundTimestamp($timestamp)
{
return mktime(date('H', $timestamp), date('i', $timestamp), 0, date('n', $timestamp), date('j', $timestamp), date('Y', $timestamp));
return mktime((int)date('H', $timestamp), (int)date('i', $timestamp), 0, (int)date('n', $timestamp), (int)date('j', $timestamp), (int)date('Y', $timestamp));
}
}
......@@ -93,7 +93,7 @@ class FileStorageExtractionAdditionalFieldProvider implements AdditionalFieldPro
{
$fieldName = 'tx_scheduler[scheduler_fileStorageIndexing_fileCount]';
$fieldId = 'scheduler_fileStorageIndexing_fileCount';
$fieldValue = $task !== null ? (int)$task->maxFileCount : 100;
$fieldValue = (string)($task !== null ? (int)$task->maxFileCount : 100);
$fieldHtml = '<input type="text" class="form-control" name="' . $fieldName . '" id="' . $fieldId . '" value="' . htmlspecialchars($fieldValue) . '">';
$fieldConfiguration = [
......
......@@ -31,7 +31,7 @@ class IpAnonymizationAdditionalFieldProvider extends AbstractAdditionalFieldProv
* Add additional fields
*
* @param array $taskInfo Reference to the array containing the info used in the add/edit form
* @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
* @param IpAnonymizationTask|null $task When editing, reference to the current task. NULL when adding.
* @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
* @return array Array containing all the information pertaining to the additional fields
*/
......
......@@ -59,7 +59,7 @@ class RecyclerGarbageCollectionAdditionalFieldProvider extends AbstractAdditiona
}
$fieldName = 'tx_scheduler[scheduler_recyclerGarbageCollection_numberOfDays]';
$fieldId = 'task_recyclerGarbageCollection_numberOfDays';
$fieldValue = (int)$taskInfo['scheduler_recyclerGarbageCollection_numberOfDays'];
$fieldValue = (string)(int)$taskInfo['scheduler_recyclerGarbageCollection_numberOfDays'];
$fieldHtml = '<input class="form-control" type="text" name="' . $fieldName . '" id="' . $fieldId . '" value="' . htmlspecialchars($fieldValue) . '">';
$additionalFields = [];
$additionalFields[$fieldId] = [
......
......@@ -36,7 +36,7 @@ class TableGarbageCollectionAdditionalFieldProvider extends AbstractAdditionalFi
* Add additional fields
*
* @param array $taskInfo Reference to the array containing the info used in the add/edit form
* @param AbstractTask|null $task When editing, reference to the current task. NULL when adding.
* @param TableGarbageCollectionTask|null $task When editing, reference to the current task. NULL when adding.
* @param SchedulerModuleController $schedulerModule Reference to the calling object (Scheduler's BE module)
* @return array Array containing all the information pertaining to the additional fields
*/
......
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