Commit f11dbece authored by Oliver Klee's avatar Oliver Klee Committed by Stefan Bürk
Browse files

[TASK] Make the return type of GeneralUtility::tempnam more specific

Also adapt the callers accordingly. This resolves a few PHPStan warnings
and allows simplifying some code.

Used command:

> ./Build/Scripts/runTests.sh -s phpstanGenerateBaseline

Resolves: #97703
Releases: main, 11.5
Change-Id: I29b7278960a519dd7c5e0d3e2966b75933941a38
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74779


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Simon Schaufelberger's avatarSimon Schaufelberger <simonschaufi+typo3@gmail.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Simon Schaufelberger's avatarSimon Schaufelberger <simonschaufi+typo3@gmail.com>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
parent e24d05f4
......@@ -1830,16 +1830,6 @@ parameters:
count: 1
path: ../../typo3/sysext/core/Tests/Unit/Http/UriTest.php
-
message: "#^Property TYPO3\\\\TestingFramework\\\\Core\\\\Unit\\\\UnitTestCase\\:\\:\\$testFilesToDelete \\(array\\<non\\-empty\\-string\\>\\) does not accept non\\-empty\\-array\\<string\\>\\.$#"
count: 2
path: ../../typo3/sysext/core/Tests/Unit/Imaging/IconProvider/SvgIconProviderTest.php
-
message: "#^Property TYPO3\\\\TestingFramework\\\\Core\\\\Unit\\\\UnitTestCase\\:\\:\\$testFilesToDelete \\(array\\<non\\-empty\\-string\\>\\) does not accept non\\-empty\\-array\\<string\\>\\.$#"
count: 2
path: ../../typo3/sysext/core/Tests/Unit/Imaging/IconProvider/SvgSpriteIconProviderTest.php
-
message: "#^Parameter \\#1 \\$data of method TYPO3\\\\CMS\\\\Core\\\\LinkHandling\\\\EmailLinkHandler\\:\\:resolveHandlerData\\(\\) expects array, string given\\.$#"
count: 1
......@@ -2060,11 +2050,6 @@ parameters:
count: 1
path: ../../typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
-
message: "#^Property TYPO3\\\\TestingFramework\\\\Core\\\\Unit\\\\UnitTestCase\\:\\:\\$testFilesToDelete \\(array\\<non\\-empty\\-string\\>\\) does not accept non\\-empty\\-array\\<string\\>\\.$#"
count: 3
path: ../../typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
-
message: "#^Static method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\GeneralUtility\\:\\:callUserFunction\\(\\) invoked with 4 parameters, 2\\-3 required\\.$#"
count: 1
......
......@@ -128,7 +128,7 @@ abstract class AbstractDriver implements DriverInterface
* Returns a temporary path for a given file, including the file extension.
*
* @param string $fileIdentifier
* @return string
* @return non-empty-string
*/
protected function getTemporaryPathForFile($fileIdentifier)
{
......
......@@ -109,7 +109,7 @@ class LocalPreviewHelper
* Returns the path to a temporary file for processing
*
* @param TaskInterface $task
* @return string
* @return non-empty-string
*/
protected function getTemporaryFilePath(TaskInterface $task)
{
......
......@@ -2802,7 +2802,7 @@ class GeneralUtility
*
* @param string $filePrefix Prefix for temporary file
* @param string $fileSuffix Suffix for temporary file, for example a special file extension
* @return string result from PHP function tempnam() with the temp/var folder prefixed.
* @return non-empty-string result from PHP function `tempnam()` with the temp/var folder prefixed.
* @see unlink_tempfile()
* @see upload_to_tempfile()
*/
......
......@@ -658,13 +658,11 @@ class Indexer
if ((string)$content !== '') {
// Create temporary file:
$tmpFile = GeneralUtility::tempnam('EXTERNAL_URL');
if ($tmpFile) {
GeneralUtility::writeFile($tmpFile, $content);
// Index that file:
$this->indexRegularDocument($externalUrl, true, $tmpFile, 'html');
// Using "TRUE" for second parameter to force indexing of external URLs (mtime doesn't make sense, does it?)
unlink($tmpFile);
}
GeneralUtility::writeFile($tmpFile, $content);
// Index that file:
$this->indexRegularDocument($externalUrl, true, $tmpFile, 'html');
// Using "TRUE" for second parameter to force indexing of external URLs (mtime doesn't make sense, does it?)
unlink($tmpFile);
}
}
}
......
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