Resolve PHPStan findings

This commit is contained in:
Daniel Siepmann 2022-09-21 13:45:59 +02:00
parent 38d465f034
commit 7f76b5b1b2
7 changed files with 24 additions and 16 deletions

View file

@ -53,8 +53,8 @@ class CategoriesCounts implements DataProcessorInterface
}
$processedData[$as] = $this->getCategoriesCount(
$parent,
$orderBy
(int) $parent,
(string) $orderBy
);
return $processedData;

View file

@ -42,7 +42,14 @@ class NaturalSortingProcessor implements DataProcessorInterface
array $processedData
) {
$variablePath = $cObj->stdWrapValue('variablePath', $processorConfiguration, '');
if (is_string($variablePath) === false) {
throw new \Exception('Variable path needs to be string.', 1663760889);
}
$variableSubPath = $cObj->stdWrapValue('variableSubPath', $processorConfiguration, '');
if (is_string($variableSubPath) === false) {
throw new \Exception('Variable Sub Path needs to be string.', 1663760908);
}
if ($variablePath === '' || $variableSubPath === '') {
throw new \Exception('Provide variablePath as well as variableSubPath.', 1638373263);

View file

@ -41,7 +41,7 @@ class XmlSitemapRenderer extends Typo3XmlSitemapRenderer
return parent::render($_, $typoScriptConfiguration, $request);
}
protected function initialize(array $fullConfiguration)
protected function initialize(array $fullConfiguration): void
{
parent::initialize($fullConfiguration);
$this->view->assign('settings', $this->getSettings());
@ -51,7 +51,7 @@ class XmlSitemapRenderer extends Typo3XmlSitemapRenderer
{
$settings = [];
foreach (array_keys($this->typoScriptConfiguration['userFunc.']['variables.'] ?? []) as $variableName) {
if (substr($variableName, -1) === '.') {
if (!is_string($variableName) || substr($variableName, -1) === '.') {
continue;
}
$settings[$variableName] = $this->cObj->cObjGetSingle(

View file

@ -31,14 +31,15 @@ class PageLayoutHeader
/**
* @var array
*/
private $pageinfo;
private $pageinfo = [];
public function render(
array $params,
PageLayoutController $pageLayoutController
): string {
// @extensionScannerIgnoreLine At least in v10 this is a false positive
if (is_array($pageLayoutController->pageinfo)) {
$this->pageinfo = $pageLayoutController->pageinfo;
}
// TODO: Check whether two levels up is uid 2, which holds all blog posts
// To prevent rendering on non blog posts
@ -50,25 +51,25 @@ class PageLayoutHeader
'metaInfo' => [
[
'label' => 'meta-description',
'value' => $this->pageinfo['description'],
'value' => $this->pageinfo['description'] ?? '',
'field' => 'description',
'type' => 'string',
],
[
'label' => 'introduction',
'value' => $this->pageinfo['abstract'],
'value' => $this->pageinfo['abstract'] ?? '',
'field' => 'abstract',
'type' => 'string',
],
[
'label' => 'published',
'value' => $this->pageinfo['lastUpdated'],
'value' => $this->pageinfo['lastUpdated'] ?? '',
'field' => 'lastUpdated',
'type' => 'date',
],
[
'label' => 'updated',
'value' => $this->pageinfo['SYS_LASTCHANGED'],
'value' => $this->pageinfo['SYS_LASTCHANGED'] ?? '',
'type' => 'date',
],
[
@ -91,7 +92,7 @@ class PageLayoutHeader
private function resolvePageMedia(): array
{
$page = ['uid' => $this->pageinfo['uid']];
$page = ['uid' => $this->pageinfo['uid'] ?? ''];
$files = new FileCollector();
$files->addFilesFromRelation('pages', 'media', $page);

View file

@ -46,7 +46,7 @@ class CodeHighlighting
// Highlight some code.
$highlighted = $highlighter->highlightAuto($code);
$content = '<pre><code>' . $highlighted->value . '</code></pre>';
} catch (DomainException $e) {
} catch (\DomainException $e) {
$content = '<pre><code>' . $code . '</code></pre>';
}

View file

@ -35,7 +35,7 @@ class IdViewHelper extends AbstractViewHelper
{
use CompileWithContentArgumentAndRenderStatic;
public function initializeArguments()
public function initializeArguments(): void
{
$this->registerArgument('value', 'string', 'string to format');
}
@ -51,7 +51,7 @@ class IdViewHelper extends AbstractViewHelper
}
$value = (string)$value;
$value = str_replace(' ', '_', $value);
$value = preg_replace('#\W#', '', $value);
$value = preg_replace('#\W#', '', $value) ?? '';
$value = GeneralUtility::underscoredToUpperCamelCase($value);
$value = lcfirst($value);
return $value;

View file

@ -40,7 +40,7 @@
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
$tableName,
'rel',
\TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_LINK,
(string) \TYPO3\CMS\Core\Domain\Repository\PageRepository::DOKTYPE_LINK,
'after:url'
);