Skip to content

Commit

Permalink
[TASK] Prevent type errors
Browse files Browse the repository at this point in the history
Prevent type errors by ensuring the right types is used.
  • Loading branch information
dkd-friedrich authored and dkd-kaehm committed Apr 21, 2022
1 parent ec66f49 commit 061ef24
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Classes/FrontendEnvironment/TypoScript.php
Expand Up @@ -123,8 +123,8 @@ public function ext_getSetup(array $theSetup, string $theKey): array
{
$parts = explode('.', $theKey, 2);
if ((string)$parts[0] !== '' && is_array($theSetup[$parts[0] . '.'])) {
if (trim($parts[1]) !== '') {
return $this->ext_getSetup($theSetup[$parts[0] . '.'], trim($parts[1]));
if (trim($parts[1] ?? '') !== '') {
return $this->ext_getSetup($theSetup[$parts[0] . '.'], trim($parts[1] ?? ''));
}
return [$theSetup[$parts[0] . '.'], $theSetup[$parts[0]]];
}
Expand Down
7 changes: 4 additions & 3 deletions Classes/ViewHelpers/SearchFormViewHelper.php
Expand Up @@ -104,6 +104,7 @@ public function render()
if ($pageUid === null && !empty($this->getTypoScriptConfiguration()->getSearchTargetPage())) {
$pageUid = $this->getTypoScriptConfiguration()->getSearchTargetPage();
}
$pageUid = (int)$pageUid;

$uri = $this->buildUriFromPageUidAndArguments($pageUid);

Expand Down Expand Up @@ -190,10 +191,10 @@ protected function translateSearchParametersToInputTagAttributes(
* When no speaking urls are active (e.g. with TYPO3 8 and no realurl) this information is passed as query parameter
* and would get lost when it is only part of the query arguments in the action parameter of the form.
*
* @param $pageId
* @param int $pageId
* @return bool
*/
protected function getIsSiteManagedSite($pageId): bool
protected function getIsSiteManagedSite(int $pageId): bool
{
return SiteUtility::getIsSiteManagedSite($pageId);
}
Expand Down Expand Up @@ -248,7 +249,7 @@ protected function buildUriFromPageUidAndArguments($pageUid): string
$uriBuilder = $this->getControllerContext()->getUriBuilder();
return $uriBuilder
->reset()
->setTargetPageUid($pageUid)
->setTargetPageUid((int)$pageUid)
->setTargetPageType($this->arguments['pageType'] ?? 0)
->setNoCache($this->arguments['noCache'] ?? false)
->setArguments($this->arguments['additionalParams'] ?? [])
Expand Down
Expand Up @@ -41,7 +41,7 @@ public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('url', 'string', 'The context searchResultSet', true);
$this->registerArgument('searchWords', 'string', 'The document to highlight', true);
$this->registerArgument('searchWords', 'string', 'The document to highlight', true, '');
$this->registerArgument('addNoCache', 'boolean', 'Should no_cache=1 be added or not', false, true);
$this->registerArgument('keepCHash', 'boolean', 'Should cHash be kept or not', false, false);
}
Expand All @@ -67,7 +67,7 @@ public static function renderStatic(
return $url;
}

$searchWords = $arguments['searchWords'];
$searchWords = $arguments['searchWords'] ?? '';
$addNoCache = $arguments['addNoCache'];
$keepCHash = $arguments['keepCHash'];

Expand Down

0 comments on commit 061ef24

Please sign in to comment.