Skip to content

Commit

Permalink
[TASK] Raise phpstan level to 2
Browse files Browse the repository at this point in the history
Fix error in module controller, there is no findall method in the file repository.
  • Loading branch information
linawolf committed May 4, 2024
1 parent c80ba3d commit 2b7a817
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
5 changes: 5 additions & 0 deletions Build/phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
parameters:
ignoreErrors:
-
message: "#^Attribute class TYPO3\\\\CMS\\\\Core\\\\Attribute\\\\AsEventListener does not exist\\.$#"
count: 1
path: ../../Classes/EventListener/LinkValidator/CheckExternalLinksToLocalPagesEventListener.php

-
message: "#^Access to an undefined property T3docs\\\\Examples\\\\Xclass\\\\NewRecordController\\:\\:\\$content\\.$#"
count: 1
Expand Down
2 changes: 1 addition & 1 deletion Build/phpstan/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ includes:

parameters:
phpVersion: 80200
level: 1
level: 2

bootstrapFiles:
- phpstan-typo3-constants.php
Expand Down
18 changes: 10 additions & 8 deletions Classes/Controller/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function treeAction(): ResponseInterface
);

// Create and initialize the tree object
/** @var $tree PageTreeView */
/** @var PageTreeView $tree */
$tree = GeneralUtility::makeInstance(PageTreeView::class);
$tree->init('AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1));
$html = '';
Expand Down Expand Up @@ -248,7 +248,7 @@ public function clipboardAction(
*/
protected function getClipboard(string $identifier): array
{
/** @var $clipboard Clipboard */
/** @var Clipboard $clipboard */
$clipboard = GeneralUtility::makeInstance(Clipboard::class);
// Read the clipboard content from the user session
$clipboard->initializeClipboard();
Expand All @@ -266,7 +266,7 @@ protected function getClipboard(string $identifier): array
*/
protected function getCurrentClipboard(): array
{
/** @var $clipboard Clipboard */
/** @var Clipboard $clipboard */
$clipboard = GeneralUtility::makeInstance(Clipboard::class);
// Read the clipboard content from the user session
$clipboard->initializeClipboard();
Expand All @@ -283,7 +283,7 @@ protected function getCurrentClipboard(): array
*/
protected function debugClipboard()
{
/** @var $clipboard Clipboard */
/** @var Clipboard $clipboard */
$clipboard = GeneralUtility::makeInstance(Clipboard::class);
// Read the clipboard content from the user session
$clipboard->initializeClipboard();
Expand Down Expand Up @@ -368,7 +368,7 @@ public function linksAction(): ResponseInterface
*
* @param int $element Uid of the just processed content element (see fileReferenceCreateAction)
*/
public function fileReferenceAction($element = 0): ResponseInterface
public function fileReferenceAction(int $element = 0): ResponseInterface
{
// Get all non-deleted content elements (this should normally be put away in a nice, clean
// repository class; don't do this at home).
Expand All @@ -385,18 +385,20 @@ public function fileReferenceAction($element = 0): ResponseInterface
} catch (\Exception) {
$contentElements = [];
}
$files = [];
// If we just handled a content element, get related data to display as a confirmation
if ((int)$element > 0) {
if ($element > 0) {
$contentElement = BackendUtility::getRecord(
'tt_content',
(int)$element,
$element,
);
try {
$fileObjects = $this->fileRepository->findByRelation(
'tt_content',
'image',
$element,
);
$files = $this->fileRepository->findByRelation('tt_content', 'image', $element);
} catch (\Exception) {
$fileObjects = [];
}
Expand All @@ -407,7 +409,7 @@ public function fileReferenceAction($element = 0): ResponseInterface
$view = $this->initializeModuleTemplate($this->request);
$view->assignMultiple(
[
'files' => $this->fileRepository->findAll(),
'files' => $files,
'elements' => $contentElements,
'content' => $contentElement,
'references' => $fileObjects,
Expand Down

0 comments on commit 2b7a817

Please sign in to comment.