Skip to content

Commit

Permalink
Fix errors detected by PHPStan
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrycze-volk committed Oct 18, 2023
1 parent cc95ac9 commit 8c955cf
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Classes/Controller/SingleCollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository)
/**
* initializeAction
*
* @return
* @return void
*/
protected function initializeAction()
{
Expand Down
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/CalcViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

Expand Down Expand Up @@ -66,6 +65,7 @@ public static function renderStatic(
$val1 = $arguments['val1'];
$val2 = $arguments['val2'];
$operator = $arguments['operator'];
$result = '';

switch ($operator) {
case '+': $result = (int)$val1 + (int)$val2;
Expand Down
10 changes: 2 additions & 8 deletions Classes/ViewHelpers/ExtractFulltextViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

Expand Down Expand Up @@ -62,13 +61,9 @@ public static function renderStatic(
RenderingContextInterface $renderingContext
) {
$file= $arguments['file'];

$rawText = '';
$altoXml = @simplexml_load_file($file);
if($altoXml === FALSE)
{
// fulltext not accessible
$rawText = '';
} else {
if($altoXml !== FALSE) {
$altoXml->registerXPathNamespace('alto', 'http://www.loc.gov/standards/alto/ns-v2#');
// Get all (presumed) words of the text.
$words = $altoXml->xpath('./alto:Layout/alto:Page/alto:PrintSpace//alto:TextBlock/alto:TextLine/alto:String/@CONTENT');
Expand All @@ -77,7 +72,6 @@ public static function renderStatic(
}
}
return $rawText;

}

}
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/PageInfoViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static function renderStatic(
) {
$pageUid = $arguments['uid'];
$field = $arguments['field'];
if (0 === $uid) {
if (0 === $pageUid) {
$pageUid = $GLOBALS['TSFE']->id;
}
$pageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class);
Expand Down
25 changes: 14 additions & 11 deletions Classes/ViewHelpers/XpathViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,25 @@ public static function renderStatic(
$result = $document->getDoc()->mets->xpath($xpath);

if (is_array($result)) {
foreach ($result as $row) {
if (!$returnArray) {
$output = '';
}
foreach ($result as $row) {
if ($returnArray) {
$output[] = $htmlspecialchars ? htmlspecialchars(trim($row)) : trim($row);
} else {
$output .= $htmlspecialchars ? htmlspecialchars(trim($row)) : trim($row) . ' ';

Check failure on line 124 in Classes/ViewHelpers/XpathViewHelper.php

View workflow job for this annotation

GitHub Actions / phpstan

Variable $output might not be defined.
}
}
} else {
if ($returnArray) {
$output[] = $htmlspecialchars ? htmlspecialchars(trim($row)) : trim($row);
$output[] = $htmlspecialchars ? htmlspecialchars(trim($result)) : trim($result);

Check failure on line 129 in Classes/ViewHelpers/XpathViewHelper.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $string of function trim expects string, false|null given.

Check failure on line 129 in Classes/ViewHelpers/XpathViewHelper.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $string of function trim expects string, false|null given.
} else {
$output .= $htmlspecialchars ? htmlspecialchars(trim($row)) : trim($row) . ' ';
$output = $htmlspecialchars ? htmlspecialchars(trim($result)) : trim($result);

Check failure on line 131 in Classes/ViewHelpers/XpathViewHelper.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $string of function trim expects string, false|null given.

Check failure on line 131 in Classes/ViewHelpers/XpathViewHelper.php

View workflow job for this annotation

GitHub Actions / phpstan

Parameter #1 $string of function trim expects string, false|null given.
}
}
} else {
if ($returnArray) {
$output[] = $htmlspecialchars ? htmlspecialchars(trim($row)) : trim($row);
} else {
$output = $htmlspecialchars ? htmlspecialchars(trim($row)) : trim($row);
}
}

if (! $returnArray) {
if (!$returnArray) {
return trim($output);

Check failure on line 136 in Classes/ViewHelpers/XpathViewHelper.php

View workflow job for this annotation

GitHub Actions / phpstan

Variable $output might not be defined.
} else {
return $output;

Check failure on line 138 in Classes/ViewHelpers/XpathViewHelper.php

View workflow job for this annotation

GitHub Actions / phpstan

Variable $output might not be defined.
Expand Down

0 comments on commit 8c955cf

Please sign in to comment.