Commit 37388f26 authored by Daniel Goerz's avatar Daniel Goerz Committed by Benni Mack
Browse files

[TASK] Enable phpstan parameter checkFunctionArgumentTypes

From now on, phpstan will validate arguments passed to methods
for type integrity. This patch also resolves all remaining
issues in the core up to PHP 7.4.

Running phpstan on PHP 8 is therefore disabled temporarily and
will be enabled again with another patch that resolves all
remaining PHP 8 issues regarding argument types.

Resolves: #93652
Releases: master
Change-Id: I2cbd15c5e83ae188a4d453c71b5841d424b2eef8
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68191

Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Richard Haeser's avatarRichard Haeser <richard@richardhaeser.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Richard Haeser's avatarRichard Haeser <richard@richardhaeser.com>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 82b6fab4
......@@ -97,14 +97,3 @@ phpstan php 7.4:
script:
- Build/Scripts/runTests.sh -s composerInstall -p 7.4
- Build/Scripts/runTests.sh -s phpstan -p 7.4
phpstan php 8.0:
stage: integrity
only:
- schedules
cache:
key: master-composer-phpstan-80
paths:
- .cache
script:
- Build/Scripts/runTests.sh -s composerInstall -p 8.0
- Build/Scripts/runTests.sh -s phpstan -p 8.0
......@@ -98,16 +98,4 @@ phpstan php 7.4 pre-merge:
script:
- Build/Scripts/runTests.sh -s composerInstall -p 7.4
- Build/Scripts/runTests.sh -s phpstan -p 7.4
phpstan php 8.0 pre-merge:
stage: main
except:
refs:
- schedules
- master
cache:
key: master-composer-phpstan-80
paths:
- .cache
script:
- Build/Scripts/runTests.sh -s composerInstall -p 8.0
- Build/Scripts/runTests.sh -s phpstan -p 8.0
......@@ -5,8 +5,8 @@ conditionalTags:
PHPStan\Rules\Functions\RandomIntParametersRule:
phpstan.rules.rule: %featureToggles.randomIntParameters%
#parameters:
# checkFunctionArgumentTypes: true
parameters:
checkFunctionArgumentTypes: true
# checkArgumentsPassedByReference: true
services:
......
......@@ -37,6 +37,7 @@ parameters:
ignoreErrors:
# PHP8 compatibility, as phpstan cannot detect this yet.
- "#Class GdImage not found.#"
- "#^Parameter \\#1 \\$disable of function libxml_disable_entity_loader expects bool, bool\\|null given\\.$#"
# ignored errors for level 0
- '#Variable \$_EXTKEY might not be defined\.#'
......@@ -261,3 +262,318 @@ parameters:
message: "#^Parameter \\#1 \\$constraint of static method TYPO3\\\\CMS\\\\Core\\\\Database\\\\Query\\\\QueryHelper\\:\\:stripLogicalOperatorPrefix\\(\\) expects string, string\\|null given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Database/QueryView.php
-
message: "#^Parameter \\#1 \\$im of function imagesavealpha expects resource, resource\\|false given\\.$#"
count: 3
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#1 \\$im of function imagecolorallocatealpha expects resource, resource\\|false given\\.$#"
count: 2
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#1 \\$im of function imagefill expects resource, resource\\|false given\\.$#"
count: 2
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#4 \\$col of function imagefill expects int, int\\|false given\\.$#"
count: 2
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#1 \\$im of function imagecolorallocate expects resource, resource\\|false given\\.$#"
count: 11
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#1 \\$im of function imagefilledrectangle expects resource, resource\\|false given\\.$#"
count: 11
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#6 \\$col of function imagefilledrectangle expects int, int\\|false given\\.$#"
count: 12
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#1 \\$dst_im of function imagecopyresized expects resource, resource\\|false given\\.$#"
count: 2
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#6 \\$Fcolor of method TYPO3\\\\CMS\\\\Core\\\\Imaging\\\\GraphicalFunctions\\:\\:SpacedImageTTFText\\(\\) expects int, int\\|false given\\.$#"
count: 2
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#6 \\$color of method TYPO3\\\\CMS\\\\Core\\\\Imaging\\\\GraphicalFunctions\\:\\:renderTTFText\\(\\) expects int, int\\|false given\\.$#"
count: 2
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#1 \\$destImg of method TYPO3\\\\CMS\\\\Core\\\\Imaging\\\\GraphicalFunctions\\:\\:ImageWrite\\(\\) expects resource, resource\\|false given\\.$#"
count: 2
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#1 \\$im of function imagedestroy expects resource, resource\\|false given\\.$#"
count: 3
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#6 \\$col of function imagettftext expects int, int\\|false given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#6 \\$color of function imagefilledellipse expects int, int\\|false given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#4 \\$green of function imagecolorset expects int, float given\\.$#"
count: 2
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#5 \\$blue of function imagecolorset expects int, float given\\.$#"
count: 2
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#1 \\$im of function imagegif expects resource, resource\\|false given\\.$#"
count: 2
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#1 \\$im of function imagestring expects resource, resource\\|false given\\.$#"
count: 3
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#6 \\$col of function imagestring expects int, int\\|false given\\.$#"
count: 3
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#1 \\$im of function imagepng expects resource, resource\\|false given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
-
message: "#^Parameter \\#2 \\$id of method TYPO3\\\\CMS\\\\Core\\\\DataHandling\\\\DataHandler\\:\\:getRecordProperties\\(\\) expects int, int\\|string given\\.$#"
count: 2
path: typo3/sysext/core/Classes/DataHandling/DataHandler.php
-
message: "#^Parameter \\#5 \\$id of method TYPO3\\\\CMS\\\\Core\\\\DataHandling\\\\DataHandler\\:\\:checkValue_SW\\(\\) expects int, int\\|string given\\.$#"
count: 1
path: typo3/sysext/core/Classes/DataHandling/DataHandler.php
-
message: "#^Parameter \\#1 \\$function of function call_user_func_array expects callable\\(\\)\\: mixed, array\\(\\$this\\(TYPO3\\\\CMS\\\\Core\\\\DataHandling\\\\DataHandler\\), mixed\\) given\\.$#"
count: 1
path: typo3/sysext/core/Classes/DataHandling/DataHandler.php
-
message: "#^Parameter \\#1 \\$im of function imagecolorallocate expects resource, resource\\|false given\\.$#"
count: 6
path: typo3/sysext/install/Classes/Controller/EnvironmentController.php
-
message: "#^Parameter \\#1 \\$im of function imagettftext expects resource, resource\\|false given\\.$#"
count: 1
path: typo3/sysext/install/Classes/Controller/EnvironmentController.php
-
message: "#^Parameter \\#6 \\$col of function imagettftext expects int, int\\|false given\\.$#"
count: 1
path: typo3/sysext/install/Classes/Controller/EnvironmentController.php
-
message: "#^Parameter \\#1 \\$im of function imagegif expects resource, resource\\|false given\\.$#"
count: 1
path: typo3/sysext/install/Classes/Controller/EnvironmentController.php
-
message: "#^Parameter \\#1 \\$im of function imagefilledrectangle expects resource, resource\\|false given\\.$#"
count: 4
path: typo3/sysext/install/Classes/Controller/EnvironmentController.php
-
message: "#^Parameter \\#6 \\$col of function imagefilledrectangle expects int, int\\|false given\\.$#"
count: 4
path: typo3/sysext/install/Classes/Controller/EnvironmentController.php
-
message: "#^Parameter \\#1 \\$im of function imagedestroy expects resource, resource\\|false given\\.$#"
count: 3
path: typo3/sysext/install/Classes/SystemEnvironment/Check.php
-
message: "#^Parameter \\#1 \\$stageRecord of method TYPO3\\\\CMS\\\\Workspaces\\\\Controller\\\\Remote\\\\ActionHandler\\:\\:getRecipientsOfStage\\(\\) expects int\\|TYPO3\\\\CMS\\\\Workspaces\\\\Domain\\\\Record\\\\StageRecord, TYPO3\\\\CMS\\\\Workspaces\\\\Domain\\\\Record\\\\StageRecord\\|null given\\.$#"
count: 1
path: typo3/sysext/workspaces/Classes/Controller/Remote/ActionHandler.php
-
message: "#^Parameter \\#2 \\$now of function strtotime expects int, int\\|false given\\.$#"
count: 1
path: typo3/sysext/scheduler/Classes/CronCommand/NormalizeCommand.php
-
message: "#^Parameter \\#1 \\$name of function setcookie expects string, string\\|false given\\.$#"
count: 1
path: typo3/sysext/install/Classes/Service/SessionService.php
-
message: "#^Unable to resolve the template type T in call to method static method Doctrine\\\\DBAL\\\\DriverManager\\:\\:getConnection\\(\\)$#"
count: 4
path: typo3/sysext/install/Classes/Controller/InstallerController.php
-
message: "#^Parameter \\#1 \\$params of static method Doctrine\\\\DBAL\\\\DriverManager\\:\\:getConnection\\(\\) expects array\\(\\?'wrapperClass' \\=\\> class\\-string\\<Doctrine\\\\DBAL\\\\Connection\\>\\), array\\<string, string\\>&nonEmpty given\\.$#"
count: 1
path: typo3/sysext/install/Classes/Controller/InstallerController.php
-
message: "#^Parameter \\#4 \\$col of function imagefill expects int, int\\|false given\\.$#"
count: 1
path: typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
-
message: "#^Parameter \\#6 \\$col of function imagefilledrectangle expects int, int\\|false given\\.$#"
count: 1
path: typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
-
message: "#^Parameter \\#2 \\$col of function imagecolortransparent expects int, int\\|false given\\.$#"
count: 1
path: typo3/sysext/frontend/Classes/Imaging/GifBuilder.php
-
message: "#^Parameter \\#1 \\$node of function dom_import_simplexml expects SimpleXMLElement, SimpleXMLElement\\|false given\\.$#"
count: 1
path: typo3/sysext/frontend/Classes/ContentObject/ScalableVectorGraphicsContentObject.php
-
message: "#^Parameter \\#1 \\$array_arg of function current expects array, object given\\.$#"
count: 1
path: typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
-
message: "#^Parameter \\#1 \\$array_arg of function key expects array, object given\\.$#"
count: 1
path: typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
-
message: "#^Parameter \\#1 \\$array_arg of function next expects array, object given\\.$#"
count: 1
path: typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
-
message: "#^Parameter \\#1 \\$array of function reset expects array, object given\\.$#"
count: 1
path: typo3/sysext/extbase/Classes/Persistence/Generic/LazyLoadingProxy.php
-
message: "#^Parameter \\#1 \\$currentRequest of static method TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\Dispatcher\\:\\:buildRequestFromCurrentRequestAndForwardResponse\\(\\) expects TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\Request, TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\RequestInterface given\\.$#"
count: 1
path: typo3/sysext/extbase/Classes/Mvc/Dispatcher.php
-
message: "#^Parameter \\#1 \\$node of method TYPO3\\\\CMS\\\\Core\\\\Tree\\\\TableConfiguration\\\\ArrayTreeRenderer\\:\\:renderNode\\(\\) expects TYPO3\\\\CMS\\\\Backend\\\\Tree\\\\TreeRepresentationNode, TYPO3\\\\CMS\\\\Backend\\\\Tree\\\\TreeNode given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Tree/TableConfiguration/ArrayTreeRenderer.php
-
message: "#^Parameter \\#2 \\$folder of method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ResourceStorage\\:\\:checkFolderActionPermission\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Folder\\|null, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FolderInterface given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Resource/ResourceStorage.php
-
message: "#^Parameter \\#1 \\$file of class TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Event\\\\AfterFileAddedEvent constructor expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ProcessedFile\\|null given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Resource/ResourceStorage.php
-
message: "#^Parameter \\#1 \\$file of method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ResourceStorage\\:\\:replaceFile\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File\\|TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ProcessedFile\\|null given\\.$#"
count: 2
path: typo3/sysext/core/Classes/Resource/ResourceStorage.php
-
message: "#^Parameter \\#1 \\$folder of method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\ResourceStorage\\:\\:isWithinFolder\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\Folder, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FolderInterface given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Resource/ResourceStorage.php
-
message: "#^Parameter \\#1 \\$address of method TYPO3\\\\CMS\\\\Core\\\\Mail\\\\Rfc822AddressesParser\\:\\:_splitAddresses\\(\\) expects string, string\\|true given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Mail/Rfc822AddressesParser.php
-
message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|null given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Http/Stream.php
-
message: "#^Parameter \\#1 \\$exception_handler of function set_exception_handler expects \\(callable\\(Throwable\\)\\: void\\)\\|null, array\\(\\$this\\(TYPO3\\\\CMS\\\\Core\\\\Error\\\\ProductionExceptionHandler\\), 'handleException'\\) given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Error/ProductionExceptionHandler.php
-
message: "#^Parameter \\#1 \\$exception_handler of function set_exception_handler expects \\(callable\\(Throwable\\)\\: void\\)\\|null, array\\(\\$this\\(TYPO3\\\\CMS\\\\Core\\\\Error\\\\DebugExceptionHandler\\), 'handleException'\\) given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Error/DebugExceptionHandler.php
-
message: "#^Parameter \\#2 \\$package of method TYPO3\\\\CMS\\\\Core\\\\DependencyInjection\\\\ServiceProviderRegistry\\:\\:create\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Package\\\\Package\\|null, TYPO3\\\\CMS\\\\Core\\\\Package\\\\PackageInterface given\\.$#"
count: 1
path: typo3/sysext/core/Classes/DependencyInjection/ServiceProviderRegistry.php
-
message: "#^Parameter \\#1 \\$name of class ReflectionFunction constructor expects Closure\\|string, callable\\(\\)\\: mixed given\\.$#"
count: 1
path: typo3/sysext/core/Classes/DependencyInjection/ServiceProviderCompilationPass.php
-
message: "#^Unable to resolve the template type T in call to method static method Doctrine\\\\DBAL\\\\DriverManager\\:\\:getConnection\\(\\)$#"
count: 1
path: typo3/sysext/core/Classes/Database/ConnectionPool.php
-
message: "#^Parameter \\#2 \\$algo of function password_hash expects string\\|null, int\\|string\\|null given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Crypto/PasswordHashing/AbstractArgon2PasswordHash.php
-
message: "#^Parameter \\#2 \\$algo of function password_needs_rehash expects string\\|null, int\\|string\\|null given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Crypto/PasswordHashing/AbstractArgon2PasswordHash.php
-
message: "#^Parameter \\#1 \\$manifest of method TYPO3\\\\CMS\\\\Core\\\\Core\\\\ClassLoadingInformationGenerator\\:\\:getAutoloadSectionFromManifest\\(\\) expects stdClass, object given\\.$#"
count: 2
path: typo3/sysext/core/Classes/Core/ClassLoadingInformationGenerator.php
-
message: "#^Parameter \\#1 \\$file of method TYPO3\\\\CMS\\\\Core\\\\Controller\\\\FileDumpController\\:\\:isFileValid\\(\\) expects TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface, TYPO3\\\\CMS\\\\Core\\\\Resource\\\\File\\|null given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Controller/FileDumpController.php
-
message: "#^Parameter \\#2 \\$callback of function array_walk expects callable\\(\\)\\: mixed, array\\(\\$this\\(TYPO3\\\\CMS\\\\Core\\\\Cache\\\\Backend\\\\AbstractBackend\\), 'flushByTag'\\) given\\.$#"
count: 1
path: typo3/sysext/core/Classes/Cache/Backend/AbstractBackend.php
-
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
\ No newline at end of file
......@@ -311,7 +311,7 @@ class ElementInformationController
} else {
$rendererRegistry = GeneralUtility::makeInstance(RendererRegistry::class);
$fileRenderer = $rendererRegistry->getRenderer($this->fileObject);
$preview['url'] = PathUtility::getAbsoluteWebPath($this->fileObject->getPublicUrl());
$preview['url'] = PathUtility::getAbsoluteWebPath($this->fileObject->getPublicUrl() ?? '');
$width = '590m';
$height = '400m';
......
......@@ -2511,7 +2511,7 @@ class EditDocumentController
}
if ($action === 'edit') {
$record = BackendUtility::getRecord($table, $recordId);
$record = BackendUtility::getRecord($table, $recordId) ?? [];
$recordTitle = BackendUtility::getRecordTitle($table, $record) ?? '';
if ($table === 'pages') {
return sprintf($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editPage'), $tableTitle, $recordTitle);
......@@ -2523,7 +2523,7 @@ class EditDocumentController
if ($pageId === 0) {
return sprintf($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editRecordRootLevel'), $tableTitle, $recordTitle);
}
$pageRow = BackendUtility::getRecord('pages', $pageId);
$pageRow = BackendUtility::getRecord('pages', $pageId) ?? [];
$pageTitle = BackendUtility::getRecordTitle('pages', $pageRow);
if ($recordTitle !== '') {
return sprintf($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.editRecord'), $tableTitle, $recordTitle, $pageTitle);
......
......@@ -192,7 +192,12 @@ class FileController
$result = [];
if ($fileTargetObject->hasFile($processedFileName)) {
$result = $this->flattenResultDataValue($fileTargetObject->getStorage()->getFileInFolder($processedFileName, $fileTargetObject));
$fileInFolder = $fileTargetObject->getStorage()->getFileInFolder($processedFileName, $fileTargetObject);
if ($fileInFolder === null) {
$result = [];
} else {
$result = $this->flattenResultDataValue($fileInFolder);
}
}
return (new JsonResponse())->setPayload($result);
}
......@@ -306,7 +311,7 @@ class FileController
if ($result->isImage()) {
$processedFile = $result->process(ProcessedFile::CONTEXT_IMAGEPREVIEW, []);
if ($processedFile) {
$thumbUrl = PathUtility::getAbsoluteWebPath($processedFile->getPublicUrl());
$thumbUrl = PathUtility::getAbsoluteWebPath($processedFile->getPublicUrl() ?? '');
}
}
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
......
......@@ -54,7 +54,7 @@ class ImageProcessController implements LoggerAwareInterface
$processedFile = $this->imageProcessingService->process($processedFileId);
return new RedirectResponse(
GeneralUtility::locationHeaderUrl($processedFile->getPublicUrl(true))
GeneralUtility::locationHeaderUrl($processedFile->getPublicUrl(true) ?? '')
);
} catch (\Throwable $e) {
// Fatal error occurred, which will be responded as 404
......
......@@ -1114,7 +1114,7 @@ class PageLayoutController
return sprintf(
'%s: %s [%d]',
$this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_mod.xlf:mlang_labels_tablabel'),
BackendUtility::getRecordTitle('pages', $this->pageinfo),
BackendUtility::getRecordTitle('pages', (array)$this->pageinfo),
$this->id
);
}
......
......@@ -336,7 +336,7 @@ class TableController extends AbstractWizardController
GeneralUtility::implodeAttributes([
'id' => 'typo3-tablewizard',
'type' => $this->inputStyle ? 'input' : 'textarea',
'append-rows' => $this->numNewRows,
'append-rows' => (string)$this->numNewRows,
'table' => GeneralUtility::jsonEncodeForHtmlAttribute($configuration, false),
], true)
);
......
......@@ -388,7 +388,7 @@ class InlineRecordContainer extends AbstractContainer
$processedImage = $fileObject->process(ProcessedFile::CONTEXT_IMAGECROPSCALEMASK, $imageSetup);
// Only use a thumbnail if the processing process was successful by checking if image width is set
if ($processedImage->getProperty('width')) {
$imageUrl = $processedImage->getPublicUrl();
$imageUrl = $processedImage->getPublicUrl() ?? '';
$thumbnail = '<img src="' . PathUtility::getAbsoluteWebPath($imageUrl) . '" ' .
'width="' . $processedImage->getProperty('width') . '" ' .
'height="' . $processedImage->getProperty('height') . '" ' .
......
......@@ -89,7 +89,7 @@ class FileInfoElement extends AbstractFormElement
$content .= ' (' . htmlspecialchars(GeneralUtility::formatSize((int)$file->getSize())) . 'bytes)<br />';
$content .= BackendUtility::getProcessedValue('sys_file', 'type', (string)$file->getType()) . ' (' . $file->getMimeType() . ')<br />';
$content .= htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_misc.xlf:fileMetaDataLocation')) . ': ';
$content .= '<a href="' . htmlspecialchars(PathUtility::getAbsoluteWebPath($file->getPublicUrl())) . '" target="_blank" title="' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.view') . '">' . htmlspecialchars($file->getStorage()->getName()) . ' - ' . htmlspecialchars($file->getIdentifier()) . '</a><br />';
$content .= '<a href="' . htmlspecialchars(PathUtility::getAbsoluteWebPath($file->getPublicUrl() ?? '')) . '" target="_blank" title="' . $this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:cm.view') . '">' . htmlspecialchars($file->getStorage()->getName()) . ' - ' . htmlspecialchars($file->getIdentifier()) . '</a><br />';
$content .= '<br />';
} else {
$content = '<h2>' . htmlspecialchars($lang->sL('LLL:EXT:core/Resources/Private/Language/locallang_misc.xlf:fileMetaErrorInvalidRecord')) . '</h2>';
......
......@@ -88,7 +88,7 @@ class ButtonBar
*/
public function makeButton($button)
{
if (!in_array(ButtonInterface::class, class_implements($button), true)) {
if (!in_array(ButtonInterface::class, class_implements($button) ?: [], true)) {
throw new \InvalidArgumentException('A Button must implement ButtonInterface', 1441706378);
}
return GeneralUtility::makeInstance($button);
......
......@@ -326,7 +326,7 @@ class ShortcutButton implements ButtonInterface, PositionInterface
unset($arguments['returnUrl']);
// Encode arguments to be stored in the database
$arguments = json_encode($arguments);
$arguments = json_encode($arguments) ?: '';
if (GeneralUtility::makeInstance(ShortcutRepository::class)->shortcutExists($routeIdentifier, $arguments)) {
return '<a class="active btn btn-default btn-sm" title="">'
......
......@@ -1061,7 +1061,7 @@ class BackendUtility
}
$processedImage = $fileObject->process($taskType, $processingConfiguration);
$attributes = [
'src' => PathUtility::getAbsoluteWebPath($processedImage->getPublicUrl()),
'src' => PathUtility::getAbsoluteWebPath($processedImage->getPublicUrl() ?? ''),
'width' => $processedImage->getProperty('width'),
'height' => $processedImage->getProperty('height'),
'alt' => $fileReferenceObject->getName(),
......
......@@ -227,7 +227,7 @@ class BackendLogController extends ActionController
$targetStructure[$pid] = [];
}
// Get day timestamp of log entry and create sub array if needed
$timestampDay = strtotime(strftime('%d.%m.%Y', $entry->getTstamp()));
$timestampDay = strtotime(strftime('%d.%m.%Y', $entry->getTstamp()) ?: '');
if (!is_array($targetStructure[$pid][$timestampDay])) {
$targetStructure[$pid][$timestampDay] = [];
}
......
......@@ -823,7 +823,7 @@ abstract class AbstractUserAuthentication implements LoggerAwareInterface
return null;
}
// Fetch the user from the DB
$userRecord = $this->getRawUserByUid($this->userSession->getUserId());
$userRecord = $this->getRawUserByUid($this->userSession->getUserId() ?? 0);
if ($userRecord) {
// A user was found
$userRecord['is_online'] = $this->userSession->getLastUpdated();
......
......@@ -1891,7 +1891,7 @@ TCAdefaults.sys_note.email = ' . $this->user['email'];
$workspaceWebMounts = GeneralUtility::intExplode(',', $dbMountpoints);
$webMountsOfUser = GeneralUtility::intExplode(',', $this->groupData['webmounts']);
$webMountsOfUser = array_combine($webMountsOfUser, $webMountsOfUser);
$webMountsOfUser = array_combine($webMountsOfUser, $webMountsOfUser) ?: [];
$entryPointRootLineUids = [];
foreach ($webMountsOfUser as $webMountPageId) {
......
......@@ -178,7 +178,7 @@ class RecoveryCodesProvider implements MfaProviderInterface
$view->assignMultiple([
'recoveryCodes' => implode(PHP_EOL, $codes),
// Generate hmac of the recovery codes to prevent them from being changed in the setup from
'checksum' => GeneralUtility::hmac(json_encode($codes), 'recovery-codes-setup')
'checksum' => GeneralUtility::hmac(json_encode($codes) ?: '', 'recovery-codes-setup')
]);
break;
case MfaViewType::EDIT:
......@@ -220,7 +220,7 @@ class RecoveryCodesProvider implements MfaProviderInterface
$recoveryCodes = GeneralUtility::trimExplode(PHP_EOL, (string)($request->getParsedBody()['recoveryCodes'] ?? ''));
$checksum = (string)($request->getParsedBody()['checksum'] ?? '');
if ($recoveryCodes === []
|| !hash_equals(GeneralUtility::hmac(json_encode($recoveryCodes), 'recovery-codes-setup'), $checksum)
|| !hash_equals(GeneralUtility::hmac(json_encode($recoveryCodes) ?: '', 'recovery-codes-setup'), $checksum)
) {
// Return since the request does not contain the initially created recovery codes
return false;
......
......@@ -399,7 +399,7 @@ class CharsetConverter implements SingletonInterface
} else {
$int = $ord;
}
return $hex ? 'x' . dechex($int) : $int;
return $hex ? 'x' . dechex((int)$int) : $int;
}
/********************************************
......
Markdown is supported
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