Commit 9dc24282 authored by Daniel Goerz's avatar Daniel Goerz Committed by Benni Mack
Browse files

[BUGFIX] Fix phpstan errors from ReturnTypeRule

EXT:impexp
EXT:indexed_search
EXT:info
EXT:install

Resolves: #94264
Releases: master
Change-Id: I0799fce1f3f316a4b6e0925f6813738a2c53f8a9
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69394


Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 3d1c9e25
......@@ -28,6 +28,7 @@ use TYPO3\CMS\Core\Messaging\FlashMessage;
use TYPO3\CMS\Core\Resource\DuplicationBehavior;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Resource\Filter\FileExtensionFilter;
use TYPO3\CMS\Core\Resource\ProcessedFile;
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Utility\File\ExtendedFileUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -309,9 +310,9 @@ class ImportController extends ImportExportController
* Gets a file by combined identifier.
*
* @param string $combinedIdentifier
* @return File|null
* @return File|ProcessedFile|null
*/
protected function getFile(string $combinedIdentifier): ?File
protected function getFile(string $combinedIdentifier)
{
try {
$file = GeneralUtility::makeInstance(ResourceFactory::class)->getFileObjectFromCombinedIdentifier($combinedIdentifier);
......
......@@ -441,9 +441,9 @@ class Export extends ImportExport
*
* @param int $pid Page ID to select from
* @param string $table Table to select from
* @return Statement Query statement
* @return \Doctrine\DBAL\Driver\ResultStatement|int Query statement
*/
protected function execListQueryPid(int $pid, string $table): Statement
protected function execListQueryPid(int $pid, string $table)
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($table);
......
......@@ -1167,12 +1167,12 @@ abstract class ImportExport
public function getOrCreateTemporaryFolderName(): string
{
if (empty($this->temporaryFolderName)) {
$this->createTemporaryFolderName();
$this->temporaryFolderName = $this->createTemporaryFolderName();
}
return $this->temporaryFolderName;
}
protected function createTemporaryFolderName(): void
protected function createTemporaryFolderName(): string
{
$temporaryPath = Environment::getVarPath() . '/transient';
do {
......@@ -1184,7 +1184,7 @@ abstract class ImportExport
);
} while (is_dir($temporaryFolderName));
GeneralUtility::mkdir($temporaryFolderName);
$this->temporaryFolderName = $temporaryFolderName;
return $temporaryFolderName;
}
public function removeTemporaryFolderName(): void
......
......@@ -335,7 +335,6 @@ class ImportTest extends AbstractImportExportTestCase
'ID' => '123456789',
];
$files = [$fileInfo];
$importMock->_call('createTemporaryFolderName');
$importMock->_set('dat', $dat);
$importMock->writeFilesToTemporaryFolder($files);
// End of simulation
......
......@@ -297,7 +297,7 @@ class IndexSearchRepository
*
* @param array $searchWords Search words
* @param int $freeIndexUid Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
* @return Statement
* @return \Doctrine\DBAL\Driver\ResultStatement|int|bool
*/
protected function getResultRows_SQLpointer($searchWords, $freeIndexUid = -1)
{
......@@ -322,7 +322,7 @@ class IndexSearchRepository
*
* @param array $searchWordsArray Search words
* @param int $freeIndexUid Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
* @return bool|\mysqli_result|object MySQLi result object / DBAL object
* @return \Doctrine\DBAL\Driver\ResultStatement|int|bool DBAL result statement
*/
protected function getResultRows_SQLpointerMysqlFulltext($searchWordsArray, $freeIndexUid = -1)
{
......@@ -433,7 +433,7 @@ class IndexSearchRepository
*
* @param array $searchData Array with search string, boolean indicator, and fulltext index reference
* @param int $freeIndexUid Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
* @return Statement
* @return \Doctrine\DBAL\Driver\ResultStatement|int
*/
protected function execFinalQuery_fulltext($searchData, $freeIndexUid = -1)
{
......@@ -652,7 +652,7 @@ class IndexSearchRepository
*
* @param string $wordSel WHERE clause selecting the word from phash
* @param string $additionalWhereClause Additional AND clause in the end of the query.
* @return Statement
* @return \Doctrine\DBAL\Driver\ResultStatement|int
*/
protected function execPHashListQuery($wordSel, $additionalWhereClause = '')
{
......@@ -678,7 +678,7 @@ class IndexSearchRepository
*
* @param string $sWord the search word
* @param int $wildcard Bit-field of Utility\LikeWildcard
* @return Statement
* @return \Doctrine\DBAL\Driver\ResultStatement|int
*/
protected function searchWord($sWord, $wildcard)
{
......@@ -696,7 +696,7 @@ class IndexSearchRepository
* Search for one distinct word
*
* @param string $sWord the search word
* @return Statement
* @return \Doctrine\DBAL\Driver\ResultStatement|int
*/
protected function searchDistinct($sWord)
{
......@@ -712,7 +712,7 @@ class IndexSearchRepository
* Search for a sentence
*
* @param string $sWord the search word
* @return Statement
* @return \Doctrine\DBAL\Driver\ResultStatement|int
*/
protected function searchSentence($sWord)
{
......@@ -741,7 +741,7 @@ class IndexSearchRepository
* Search for a metaphone word
*
* @param string $sWord the search word
* @return Statement
* @return \Doctrine\DBAL\Driver\ResultStatement|int
*/
protected function searchMetaphone($sWord)
{
......@@ -950,7 +950,7 @@ class IndexSearchRepository
*
* @param string $list List of phash integers which match the search.
* @param int $freeIndexUid Pointer to which indexing configuration you want to search in. -1 means no filtering. 0 means only regular indexed content.
* @return Statement
* @return \Doctrine\DBAL\Driver\ResultStatement|int
*/
protected function execFinalQuery($list, $freeIndexUid = -1)
{
......
......@@ -294,7 +294,7 @@ class FileContentParser
* Return title of entry in media type selector box.
*
* @param string $extension File extension
* @return string String with label value of entry in media type search selector box (frontend plugin).
* @return string|false String with label value of entry in media type search selector box (frontend plugin).
*/
public function searchTypeMediaTitle($extension)
{
......@@ -458,7 +458,7 @@ class FileContentParser
* @param string $ext File extension, eg. "pdf", "doc" etc.
* @param string $absFile Absolute filename of file (must exist and be validated OK before calling function)
* @param string $cPKey Pointer to section (zero for all other than PDF which will have an indication of pages into which the document should be split.)
* @return array Standard content array (title, description, keywords, body keys)
* @return array|false|null Standard content array (title, description, keywords, body keys), false if the extension is not supported or null if nothing found
*/
public function readFileContent($ext, $absFile, $cPKey)
{
......
......@@ -116,7 +116,7 @@ class Lexer
// Get next chars unicode number and find type:
$bc = 0;
$cp = $this->utf8_ord($theWord, $bc);
$cType = $this->charType($cp);
$cType = $this->charType((int)$cp);
// If string is a CJK sequence we follow this algorithm:
/*
DESCRIPTION OF (CJK) ALGORITHMContinuous letters and numbers make up words. Spaces and symbols
......@@ -238,7 +238,7 @@ class Lexer
$pos += $bc;
// Determine the type:
$cType_prev = $cType;
$cType = $this->charType($cp);
$cType = $this->charType((int)$cp);
if ($cType !== null) {
continue;
}
......@@ -282,7 +282,7 @@ class Lexer
* @param int $len The length of the character (reference, return value)
* @param int $pos Starting position in input string
* @param bool $hex If set, then a hex. number is returned
* @return int UNICODE codepoint
* @return int|string UNICODE codepoint
*/
public function utf8_ord(&$str, &$len, $pos = 0, $hex = false)
{
......
......@@ -819,15 +819,15 @@ class DoubleMetaPhoneUtility
public function StringAt($string, $start, $length, $list)
{
if ($start < 0 || $start >= strlen($string)) {
return 0;
return false;
}
$listCount = count($list);
for ($i = 0; $i < $listCount; $i++) {
if ($list[$i] == substr($string, $start, $length)) {
return 1;
return true;
}
}
return 0;
return false;
}
/**
......
......@@ -47,7 +47,7 @@ class IndexedSearchUtility
*/
public static function md5inthash($stringToHash)
{
return hexdec(substr(md5($stringToHash), 0, 7));
return (int)hexdec(substr(md5($stringToHash), 0, 7));
}
/**
......@@ -174,6 +174,6 @@ class IndexedSearchUtility
*/
public static function milliseconds()
{
return round(microtime(true) * 1000);
return (int)round(microtime(true) * 1000);
}
}
......@@ -501,7 +501,7 @@ class PageInformationController
$icon = '<span ' . $toolTip . '>' . $this->iconFactory->getIconForRecord('pages', $row, Icon::SIZE_SMALL)->render() . '</span>';
// The icon with link
if ($this->getBackendUser()->recordEditAccessInternals('pages', $row)) {
$icon = BackendUtility::wrapClickMenuOnIcon($icon, 'pages', $row['uid']);
$icon = (string)BackendUtility::wrapClickMenuOnIcon($icon, 'pages', $row['uid']);
}
return $icon;
}
......
......@@ -90,7 +90,7 @@ class CodeStatistics extends NodeVisitorAbstract
* True if a @extensionScannerIgnoreFile has been found.
* Called externally *after* traversing
*
* @return int
* @return bool
*/
public function isFileIgnored()
{
......
......@@ -61,11 +61,12 @@ class ConstructorArgumentMatcher extends AbstractCoreMatcher
* Test for "->deprecated()" (weak match)
*
* @param Node $node
* @return void|null
*/
public function enterNode(Node $node)
{
if ($this->isFileIgnored($node) || $this->isLineIgnored($node)) {
return;
return null;
}
$resolvedNode = $node->getAttribute(self::NODE_RESOLVED_AS, null) ?? $node;
if (!$resolvedNode instanceof New_
......@@ -73,13 +74,13 @@ class ConstructorArgumentMatcher extends AbstractCoreMatcher
|| is_object($node->class) && !method_exists($node->class, '__toString')
|| !array_key_exists((string)$resolvedNode->class, $this->matcherDefinitions)
) {
return;
return null;
}
// A method call is considered a match if it is not called with argument unpacking
// and number of used arguments is lower than numberOfMandatoryArguments
if ($this->isArgumentUnpackingUsed($resolvedNode->args)) {
return;
return null;
}
// $node reflects invocation, e.g. `GeneralUtility::makeInstance(MyClass::class, 123)`
......
......@@ -64,7 +64,7 @@ abstract class AbstractNode
*/
protected function getTargetPermission()
{
return $this->targetPermission;
return $this->targetPermission ?? '';
}
/**
......
......@@ -199,7 +199,7 @@ class LinkNode extends AbstractNode implements NodeInterface
$result = true;
} else {
$actualTarget = $this->getCurrentTarget();
if ($expectedTarget === rtrim($actualTarget, '/')) {
if ($expectedTarget === rtrim((string)$actualTarget, '/')) {
$result = true;
}
}
......@@ -209,7 +209,7 @@ class LinkNode extends AbstractNode implements NodeInterface
/**
* Return current target of link
*
* @return string target
* @return false|string target
*/
protected function getCurrentTarget()
{
......
......@@ -68,6 +68,7 @@ class CoreVersionService
}
/**
* @todo docblock
* @return array{community: string[], elts: string[]}
*/
public function getSupportedMajorReleases(): array
......
......@@ -233,7 +233,7 @@ class FileSessionHandler implements \SessionHandlerInterface
/**
* Returns the session ID of the running session.
*
* @return string the session ID
* @return string|false the session ID
*/
public function getSessionId()
{
......
......@@ -101,7 +101,7 @@ class SessionService implements SingletonInterface
/**
* Starts a new session
*
* @return string The session ID
* @return string|false The session ID
*/
public function startSession()
{
......@@ -150,7 +150,7 @@ class SessionService implements SingletonInterface
/**
* Generates a new session ID and sends it to the client.
*
* @return string the new session ID
* @return string|false the new session ID
*/
private function renewSession()
{
......
......@@ -178,7 +178,7 @@ class WebServerConfigurationFileService
string $newRewriteRule,
string $configurationFileContent
): string {
return preg_replace_callback(
return (string)preg_replace_callback(
$pattern,
static function ($matches) use ($newRewriteRule) {
return str_replace($matches[2], '', ($matches[1] . $newRewriteRule)) . $matches[3];
......
......@@ -62,8 +62,7 @@ class PhpInfoViewHelper extends AbstractViewHelper
{
ob_start();
phpinfo();
return ob_get_clean();
return (string)ob_get_clean();
}
/**
......
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