From ef3d4585eed041baed9ef1912537559d44f1e295 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Mon, 23 Oct 2023 13:34:17 +0200 Subject: [PATCH] [MAINTENANCE] Consistently use type declaration for parameters and return values - part 2 (#1045) Co-authored-by: Sebastian Meyer --- Classes/Controller/AbstractController.php | 36 +++++----- Classes/Controller/AudioPlayerController.php | 6 +- .../Backend/NewTenantController.php | 40 +++++------ Classes/Controller/BasketController.php | 60 ++++++++-------- Classes/Controller/CalendarController.php | 19 +++-- Classes/Controller/CollectionController.php | 14 ++-- Classes/Controller/FeedsController.php | 8 +-- Classes/Controller/ListViewController.php | 10 +-- Classes/Controller/MetadataController.php | 34 ++++----- Classes/Controller/NavigationController.php | 5 +- Classes/Controller/PageGridController.php | 6 +- Classes/Controller/PageViewController.php | 18 ++--- Classes/Controller/SearchController.php | 44 ++++++------ Classes/Controller/StatisticsController.php | 2 +- .../Controller/TableOfContentsController.php | 28 +++++--- Classes/Controller/ToolboxController.php | 72 ++++++++++--------- Classes/Controller/View3DController.php | 2 +- Classes/Domain/Model/Document.php | 4 +- Classes/Domain/Model/Metadata.php | 2 +- .../Repository/CollectionRepository.php | 20 +++--- Classes/Domain/Repository/MailRepository.php | 7 +- .../Domain/Repository/MetadataRepository.php | 4 +- Classes/Domain/Repository/TokenRepository.php | 2 +- 23 files changed, 226 insertions(+), 217 deletions(-) diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index 5ff09d569a..2d9d110587 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -43,7 +43,7 @@ abstract class AbstractController extends ActionController implements LoggerAwar * @access protected * @var DocumentRepository */ - protected $documentRepository; + protected DocumentRepository $documentRepository; /** * @access public @@ -52,7 +52,7 @@ abstract class AbstractController extends ActionController implements LoggerAwar * * @return void */ - public function injectDocumentRepository(DocumentRepository $documentRepository) + public function injectDocumentRepository(DocumentRepository $documentRepository): void { $this->documentRepository = $documentRepository; } @@ -61,25 +61,25 @@ public function injectDocumentRepository(DocumentRepository $documentRepository) * @access protected * @var Document This holds the current document */ - protected $document; + protected Document $document; /** * @access protected * @var array */ - protected $extConf; + protected array $extConf; /** * @access protected * @var array This holds the request parameter */ - protected $requestData; + protected array $requestData; /** * @access protected * @var array This holds some common data for the fluid view */ - protected $viewData; + protected array $viewData; /** * Initialize the plugin controller @@ -88,7 +88,7 @@ public function injectDocumentRepository(DocumentRepository $documentRepository) * * @return void */ - protected function initialize() + protected function initialize(): void { $this->requestData = GeneralUtility::_GPmerged('tx_dlf'); @@ -114,7 +114,7 @@ protected function initialize() * * @return void */ - protected function loadDocument(int $documentId = 0) + protected function loadDocument(int $documentId = 0): void { // Get document ID from request data if not passed as parameter. if ($documentId === 0 && !empty($this->requestData['id'])) { @@ -189,7 +189,7 @@ protected function loadDocument(int $documentId = 0) * * @return void */ - protected function configureProxyUrl(&$url) { + protected function configureProxyUrl(string &$url): void { $this->uriBuilder->reset() ->setTargetPageUid($GLOBALS['TSFE']->id) ->setCreateAbsoluteUri(!empty($this->settings['forceAbsoluteUrl'])) @@ -206,9 +206,9 @@ protected function configureProxyUrl(&$url) { * * @access protected * - * @return boolean + * @return bool */ - protected function isDocMissingOrEmpty() + protected function isDocMissingOrEmpty(): bool { return $this->isDocMissing() || $this->document->getCurrentDocument()->numPages < 1; } @@ -218,9 +218,9 @@ protected function isDocMissingOrEmpty() * * @access protected * - * @return boolean + * @return bool */ - protected function isDocMissing() + protected function isDocMissing(): bool { return $this->document === null || $this->document->getCurrentDocument() === null; } @@ -246,7 +246,7 @@ protected function getLanguageService(): LanguageService * * @return null|string|array */ - protected function getParametersSafely($parameterName) + protected function getParametersSafely(string $parameterName) { if ($this->request->hasArgument($parameterName)) { return $this->request->getArgument($parameterName); @@ -261,7 +261,7 @@ protected function getParametersSafely($parameterName) * * @return void */ - protected function sanitizeRequestData() + protected function sanitizeRequestData(): void { // tx_dlf[id] may only be an UID or URI. if ( @@ -293,7 +293,7 @@ protected function sanitizeRequestData() * * @return void */ - protected function setPage() { + protected function setPage(): void { if (!empty($this->requestData['logicalPage'])) { $this->requestData['page'] = $this->document->getCurrentDocument()->getPhysicalPage($this->requestData['logicalPage']); // The logical page parameter should not appear again @@ -310,7 +310,7 @@ protected function setPage() { * * @return void */ - protected function setDefaultPage() { + protected function setDefaultPage(): void { // Set default values if not set. // $this->requestData['page'] may be integer or string (physical structure @ID) if ( @@ -344,7 +344,7 @@ public function __construct() * @param PaginatorInterface $paginator * @return array */ - protected function buildSimplePagination(PaginationInterface $pagination, PaginatorInterface $paginator) + protected function buildSimplePagination(PaginationInterface $pagination, PaginatorInterface $paginator): array { $firstPage = $pagination->getFirstPageNumber(); $lastPage = $pagination->getLastPageNumber(); diff --git a/Classes/Controller/AudioPlayerController.php b/Classes/Controller/AudioPlayerController.php index 49c4023e15..c546cd5b7f 100644 --- a/Classes/Controller/AudioPlayerController.php +++ b/Classes/Controller/AudioPlayerController.php @@ -32,7 +32,7 @@ class AudioplayerController extends AbstractController * @access protected * @var array Holds the current audio file's URL, MIME type and optional label */ - protected $audio = []; + protected array $audio = []; /** * Adds Player javascript @@ -41,7 +41,7 @@ class AudioplayerController extends AbstractController * * @return void */ - protected function addPlayerJS() + protected function addPlayerJS(): void { // Inline CSS. $inlineCSS = '#tx-dlf-audio { width: 100px; height: 100px; }'; @@ -73,7 +73,7 @@ protected function addPlayerJS() * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); diff --git a/Classes/Controller/Backend/NewTenantController.php b/Classes/Controller/Backend/NewTenantController.php index b6b13989eb..c85b941c55 100644 --- a/Classes/Controller/Backend/NewTenantController.php +++ b/Classes/Controller/Backend/NewTenantController.php @@ -47,25 +47,25 @@ class NewTenantController extends AbstractController * @access protected * @var int */ - protected $pid; + protected int $pid; /** * @access protected * @var array */ - protected $pageInfo; + protected array $pageInfo; /** * @access protected * @var array All configured site languages */ - protected $siteLanguages; + protected array $siteLanguages; /** * @access protected * @var LocalizationFactory Language factory to get language key/values by our own. */ - protected $languageFactory; + protected LocalizationFactory $languageFactory; /** * @access protected @@ -77,7 +77,7 @@ class NewTenantController extends AbstractController * @access protected * @var FormatRepository */ - protected $formatRepository; + protected FormatRepository $formatRepository; /** * @access public @@ -86,7 +86,7 @@ class NewTenantController extends AbstractController * * @return void */ - public function injectFormatRepository(FormatRepository $formatRepository) + public function injectFormatRepository(FormatRepository $formatRepository): void { $this->formatRepository = $formatRepository; } @@ -95,7 +95,7 @@ public function injectFormatRepository(FormatRepository $formatRepository) * @access protected * @var MetadataRepository */ - protected $metadataRepository; + protected MetadataRepository $metadataRepository; /** * @access public @@ -104,7 +104,7 @@ public function injectFormatRepository(FormatRepository $formatRepository) * * @return void */ - public function injectMetadataRepository(MetadataRepository $metadataRepository) + public function injectMetadataRepository(MetadataRepository $metadataRepository): void { $this->metadataRepository = $metadataRepository; } @@ -113,7 +113,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * @access protected * @var StructureRepository */ - protected $structureRepository; + protected StructureRepository $structureRepository; /** * @access public @@ -122,7 +122,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * * @return void */ - public function injectStructureRepository(StructureRepository $structureRepository) + public function injectStructureRepository(StructureRepository $structureRepository): void { $this->structureRepository = $structureRepository; } @@ -131,7 +131,7 @@ public function injectStructureRepository(StructureRepository $structureReposito * @access protected * @var SolrCoreRepository */ - protected $solrCoreRepository; + protected SolrCoreRepository $solrCoreRepository; /** * @access public @@ -140,7 +140,7 @@ public function injectStructureRepository(StructureRepository $structureReposito * * @return void */ - public function injectSolrCoreRepository(SolrCoreRepository $solrCoreRepository) + public function injectSolrCoreRepository(SolrCoreRepository $solrCoreRepository): void { $this->solrCoreRepository = $solrCoreRepository; } @@ -152,7 +152,7 @@ public function injectSolrCoreRepository(SolrCoreRepository $solrCoreRepository) * * @return void */ - protected function initializeAction() + protected function initializeAction(): void { $this->pid = (int) GeneralUtility::_GP('id'); @@ -178,7 +178,7 @@ protected function initializeAction() * * @return void */ - public function addFormatAction() + public function addFormatAction(): void { // Include formats definition file. $formatsDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/FormatDefaults.php'); @@ -220,7 +220,7 @@ public function addFormatAction() * * @return void */ - public function addMetadataAction() + public function addMetadataAction(): void { // Include metadata definition file. $metadataDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/MetadataDefaults.php'); @@ -299,7 +299,7 @@ public function addMetadataAction() * * @return void */ - public function addSolrCoreAction() + public function addSolrCoreAction(): void { $doPersist = false; @@ -335,7 +335,7 @@ public function addSolrCoreAction() * * @return void */ - public function addStructureAction() + public function addStructureAction(): void { // Include structure definition file. $structureDefaults = include(ExtensionManagementUtility::extPath('dlf') . 'Resources/Private/Data/StructureDefaults.php'); @@ -391,7 +391,7 @@ public function addStructureAction() * * @return void */ - protected function initializeView(ViewInterface $view) + protected function initializeView(ViewInterface $view): void { /** @var BackendTemplateView $view */ parent::initializeView($view); @@ -411,7 +411,7 @@ protected function initializeView(ViewInterface $view) * * @return void */ - public function indexAction() + public function indexAction(): void { $recordInfos = []; @@ -458,7 +458,7 @@ public function errorAction() * * @return string */ - protected function getLLL($index, $lang, $langArray) + protected function getLLL(string $index, string $lang, array $langArray): string { if (isset($langArray[$lang][$index][0]['target'])) { return $langArray[$lang][$index][0]['target']; diff --git a/Classes/Controller/BasketController.php b/Classes/Controller/BasketController.php index 94d4a45807..d5242e4397 100644 --- a/Classes/Controller/BasketController.php +++ b/Classes/Controller/BasketController.php @@ -39,7 +39,7 @@ class BasketController extends AbstractController * @access protected * @var BasketRepository */ - protected $basketRepository; + protected BasketRepository $basketRepository; /** * @access public @@ -48,7 +48,7 @@ class BasketController extends AbstractController * * @return void */ - public function injectBasketRepository(BasketRepository $basketRepository) + public function injectBasketRepository(BasketRepository $basketRepository): void { $this->basketRepository = $basketRepository; } @@ -57,7 +57,7 @@ public function injectBasketRepository(BasketRepository $basketRepository) * @access protected * @var MailRepository */ - protected $mailRepository; + protected MailRepository $mailRepository; /** * @access public @@ -66,7 +66,7 @@ public function injectBasketRepository(BasketRepository $basketRepository) * * @return void */ - public function injectMailRepository(MailRepository $mailRepository) + public function injectMailRepository(MailRepository $mailRepository): void { $this->mailRepository = $mailRepository; } @@ -75,7 +75,7 @@ public function injectMailRepository(MailRepository $mailRepository) * @access protected * @var PrinterRepository */ - protected $printerRepository; + protected PrinterRepository $printerRepository; /** * @access public @@ -84,7 +84,7 @@ public function injectMailRepository(MailRepository $mailRepository) * * @return void */ - public function injectPrinterRepository(PrinterRepository $printerRepository) + public function injectPrinterRepository(PrinterRepository $printerRepository): void { $this->printerRepository = $printerRepository; } @@ -93,7 +93,7 @@ public function injectPrinterRepository(PrinterRepository $printerRepository) * @access protected * @var ActionLogRepository */ - protected $actionLogRepository; + protected ActionLogRepository $actionLogRepository; /** * @access public @@ -102,7 +102,7 @@ public function injectPrinterRepository(PrinterRepository $printerRepository) * * @return void */ - public function injectActionLogRepository(ActionLogRepository $actionLogRepository) + public function injectActionLogRepository(ActionLogRepository $actionLogRepository): void { $this->actionLogRepository = $actionLogRepository; } @@ -114,7 +114,7 @@ public function injectActionLogRepository(ActionLogRepository $actionLogReposito * * @return void */ - public function basketAction() + public function basketAction(): void { $basket = $this->getBasketData(); @@ -132,7 +132,7 @@ public function basketAction() $pdfUrl = $this->settings['pdfgenerate']; foreach ($this->requestData['selected'] as $docValue) { if ($docValue['id']) { - $docData = $this->getDocumentData($docValue['id'], $docValue); + $docData = $this->getDocumentData((int) $docValue['id'], $docValue); $pdfUrl .= $docData['urlParams'] . $this->settings['pdfparamseparator']; $this->redirectToUri($pdfUrl); } @@ -143,7 +143,7 @@ public function basketAction() if ($this->requestData['print_action']) { // open selected documents if (isset($this->requestData['selected'])) { - $this->printDocument($basket); + $this->printDocument(); } } // action send mail @@ -163,7 +163,7 @@ public function basketAction() * * @return void */ - public function addAction() + public function addAction(): void { $basket = $this->getBasketData(); @@ -184,7 +184,7 @@ public function addAction() * * @return void */ - public function mainAction() + public function mainAction(): void { $basket = $this->getBasketData(); @@ -233,7 +233,7 @@ public function mainAction() * * @return Basket The found data from user session. */ - protected function getBasketData() + protected function getBasketData(): Basket { // get user session $userSession = $GLOBALS['TSFE']->fe_user->getSession(); @@ -270,9 +270,9 @@ protected function getBasketData() * * @param array $data DocumentData * - * @return string One basket entry + * @return array One basket entry */ - protected function getEntry($data) + protected function getEntry(array $data): array { if (is_object($data)) { $data = get_object_vars($data); @@ -286,7 +286,7 @@ protected function getEntry($data) $endY = $data['endY']; $rotation = $data['rotation']; - $docData = $this->getDocumentData($id, $data); + $docData = $this->getDocumentData((int) $id, $data); $entryArray['BASKETDATA'] = $docData; @@ -324,9 +324,9 @@ protected function getEntry($data) * @param int $id Document id * @param array $data DocumentData * - * @return string|false download url or false + * @return array|false download url or false */ - protected function getDocumentData($id, $data) + protected function getDocumentData(int $id, array $data) { // get document instance to load further information $this->loadDocument((int) $id); @@ -386,16 +386,16 @@ protected function getDocumentData($id, $data) } /** - * Adds documents to the basket + * Adds documents to the basket and includes JS * * @access protected * * @param array $piVars piVars * @param Basket $basket basket object * - * @return array Basket data and JavaScript output + * @return Basket|null Basket data */ - protected function addToBasket($piVars, $basket) + protected function addToBasket(array $piVars, Basket $basket): ?Basket { $output = ''; @@ -427,7 +427,7 @@ protected function addToBasket($piVars, $basket) $this->loadDocument((int) $documentItem['id']); if ($this->isDocMissing()) { // Quit without doing anything if required variables are not set. - return; + return null; } // set endpage for toc and subentry based on logid if (($piVars['addToBasket'] == 'subentry') or ($piVars['addToBasket'] == 'toc')) { @@ -500,7 +500,7 @@ protected function addToBasket($piVars, $basket) * * @return Basket basket */ - protected function removeFromBasket($piVars, $basket) + protected function removeFromBasket(array $piVars, Basket $basket): Basket { if (!empty($basket->getDocIds())) { $items = json_decode($basket->getDocIds()); @@ -539,7 +539,7 @@ protected function removeFromBasket($piVars, $basket) * * @return void */ - protected function sendMail() + protected function sendMail(): void { // send mail $mailId = $this->requestData['mail_action']; @@ -553,7 +553,7 @@ protected function sendMail() foreach ($this->requestData['selected'] as $docValue) { if ($docValue['id']) { $explodeId = explode("_", $docValue['id']); - $docData = $this->getDocumentData($explodeId[0], $docValue); + $docData = $this->getDocumentData((int) $explodeId[0], $docValue); $pdfUrl .= $docData['urlParams'] . $this->settings['pdfparamseparator']; $pages = (abs(intval($docValue['startpage']) - intval($docValue['endpage']))); if ($pages === 0) { @@ -614,17 +614,15 @@ protected function sendMail() * * @access protected * - * @param Basket basket object - * * @return void */ - protected function printDocument($basket) + protected function printDocument(): void { $pdfUrl = $this->settings['pdfprint']; $numberOfPages = 0; foreach ($this->requestData['selected'] as $docId => $docValue) { if ($docValue['id']) { - $docData = $this->getDocumentData($docValue['id'], $docValue); + $docData = $this->getDocumentData((int) $docValue['id'], $docValue); $pdfUrl .= $docData['urlParams'] . $this->settings['pdfparamseparator']; $numberOfPages += $docData['pageNums']; } @@ -642,7 +640,7 @@ protected function printDocument($basket) foreach ($this->requestData['selected'] as $docId => $docValue) { if ($docValue['id']) { $explodeId = explode("_", $docId); - $docData = $this->getDocumentData($explodeId[0], $docValue); + $docData = $this->getDocumentData((int) $explodeId[0], $docValue); $pdfUrl .= $docData['urlParams'] . $this->settings['pdfparamseparator']; $numberOfPages += $docData['pageNums']; } diff --git a/Classes/Controller/CalendarController.php b/Classes/Controller/CalendarController.php index 97900de8f8..c195960392 100644 --- a/Classes/Controller/CalendarController.php +++ b/Classes/Controller/CalendarController.php @@ -29,7 +29,7 @@ class CalendarController extends AbstractController * @access protected * @var StructureRepository */ - protected $structureRepository; + protected StructureRepository $structureRepository; /** * @access public @@ -38,7 +38,7 @@ class CalendarController extends AbstractController * * @return void */ - public function injectStructureRepository(StructureRepository $structureRepository) + public function injectStructureRepository(StructureRepository $structureRepository): void { $this->structureRepository = $structureRepository; } @@ -47,7 +47,7 @@ public function injectStructureRepository(StructureRepository $structureReposito * @access protected * @var array This holds all issues for the list view. */ - protected $allIssues = []; + protected array $allIssues = []; /** * The main method of the plugin @@ -56,7 +56,7 @@ public function injectStructureRepository(StructureRepository $structureReposito * * @return void */ - public function mainAction() + public function mainAction(): void { // Set initial document (anchor or year file) if configured. if (empty($this->requestData['id']) && !empty($this->settings['initialDocument'])) { @@ -97,12 +97,9 @@ public function mainAction() * * @access public * - * @param string $content The PlugIn content - * @param array $conf The PlugIn configuration - * * @return void */ - public function calendarAction() + public function calendarAction(): void { // access arguments passed by the mainAction() $mainRequestData = $this->request->getArguments(); @@ -231,7 +228,7 @@ public function calendarAction() * * @return void */ - public function yearsAction() + public function yearsAction(): void { // access arguments passed by the mainAction() $mainRequestData = $this->request->getArguments(); @@ -320,9 +317,9 @@ public function yearsAction() * @param int $firstMonth 1 for January, 2 for February, ... 12 for December * @param int $lastMonth 1 for January, 2 for February, ... 12 for December * - * @return string Content for template subpart + * @return void */ - protected function getCalendarYear(&$calendarData, $calendarIssuesByMonth, $year, $firstMonth = 1, $lastMonth = 12) + protected function getCalendarYear(array &$calendarData, array $calendarIssuesByMonth, int $year, int $firstMonth = 1, int $lastMonth = 12): void { for ($i = $firstMonth; $i <= $lastMonth; $i++) { $key = $year . '-' . $i; diff --git a/Classes/Controller/CollectionController.php b/Classes/Controller/CollectionController.php index d8e7174cd1..4d332d98f9 100644 --- a/Classes/Controller/CollectionController.php +++ b/Classes/Controller/CollectionController.php @@ -32,7 +32,7 @@ class CollectionController extends AbstractController * @access protected * @var CollectionRepository */ - protected $collectionRepository; + protected CollectionRepository $collectionRepository; /** * @access public @@ -41,7 +41,7 @@ class CollectionController extends AbstractController * * @return void */ - public function injectCollectionRepository(CollectionRepository $collectionRepository) + public function injectCollectionRepository(CollectionRepository $collectionRepository): void { $this->collectionRepository = $collectionRepository; } @@ -50,7 +50,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * @access protected * @var MetadataRepository */ - protected $metadataRepository; + protected MetadataRepository $metadataRepository; /** * @access public @@ -59,7 +59,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * * @return void */ - public function injectMetadataRepository(MetadataRepository $metadataRepository) + public function injectMetadataRepository(MetadataRepository $metadataRepository): void { $this->metadataRepository = $metadataRepository; } @@ -71,7 +71,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * * @return void */ - public function listAction() + public function listAction(): void { $solr = Solr::getInstance($this->settings['solrcore']); @@ -161,7 +161,7 @@ public function listAction() * * @return void */ - public function showAction(Collection $collection) + public function showAction(Collection $collection): void { $searchParams = $this->getParametersSafely('searchParameter'); @@ -214,7 +214,7 @@ public function showAction(Collection $collection) * * @return void */ - public function showSortedAction() + public function showSortedAction(): void { // if search was triggered, get search parameters from POST variables $searchParams = $this->getParametersSafely('searchParameter'); diff --git a/Classes/Controller/FeedsController.php b/Classes/Controller/FeedsController.php index 363cc123e1..4fc137f3fb 100644 --- a/Classes/Controller/FeedsController.php +++ b/Classes/Controller/FeedsController.php @@ -31,12 +31,12 @@ class FeedsController extends AbstractController * @access protected * @var LibraryRepository */ - protected $libraryRepository; + protected LibraryRepository $libraryRepository; /** * @param LibraryRepository $libraryRepository */ - public function injectLibraryRepository(LibraryRepository $libraryRepository) + public function injectLibraryRepository(LibraryRepository $libraryRepository): void { $this->libraryRepository = $libraryRepository; } @@ -48,7 +48,7 @@ public function injectLibraryRepository(LibraryRepository $libraryRepository) * * @return void */ - public function initializeAction() + public function initializeAction(): void { $this->request->setFormat('xml'); } @@ -60,7 +60,7 @@ public function initializeAction() * * @return void */ - public function mainAction() + public function mainAction(): void { // access to GET parameter tx_dlf_feeds['collection'] $requestData = $this->request->getArguments(); diff --git a/Classes/Controller/ListViewController.php b/Classes/Controller/ListViewController.php index 75d24d1aff..fc882db5e9 100644 --- a/Classes/Controller/ListViewController.php +++ b/Classes/Controller/ListViewController.php @@ -30,7 +30,7 @@ class ListViewController extends AbstractController * @access protected * @var CollectionRepository */ - protected $collectionRepository; + protected CollectionRepository $collectionRepository; /** * @access public @@ -39,7 +39,7 @@ class ListViewController extends AbstractController * * @return void */ - public function injectCollectionRepository(CollectionRepository $collectionRepository) + public function injectCollectionRepository(CollectionRepository $collectionRepository): void { $this->collectionRepository = $collectionRepository; } @@ -48,7 +48,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * @access protected * @var MetadataRepository */ - protected $metadataRepository; + protected MetadataRepository $metadataRepository; /** * @access public @@ -57,7 +57,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * * @return void */ - public function injectMetadataRepository(MetadataRepository $metadataRepository) + public function injectMetadataRepository(MetadataRepository $metadataRepository): void { $this->metadataRepository = $metadataRepository; } @@ -75,7 +75,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * * @return void */ - public function mainAction() + public function mainAction(): void { $this->searchParams = $this->getParametersSafely('searchParameter'); diff --git a/Classes/Controller/MetadataController.php b/Classes/Controller/MetadataController.php index cc8a03fc03..ec49faf998 100644 --- a/Classes/Controller/MetadataController.php +++ b/Classes/Controller/MetadataController.php @@ -39,7 +39,7 @@ class MetadataController extends AbstractController * @access protected * @var CollectionRepository */ - protected $collectionRepository; + protected CollectionRepository $collectionRepository; /** * @access public @@ -48,7 +48,7 @@ class MetadataController extends AbstractController * * @return void */ - public function injectCollectionRepository(CollectionRepository $collectionRepository) + public function injectCollectionRepository(CollectionRepository $collectionRepository): void { $this->collectionRepository = $collectionRepository; } @@ -57,7 +57,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * @access protected * @var MetadataRepository */ - protected $metadataRepository; + protected MetadataRepository $metadataRepository; /** * @access public @@ -66,7 +66,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * * @return void */ - public function injectMetadataRepository(MetadataRepository $metadataRepository) + public function injectMetadataRepository(MetadataRepository $metadataRepository): void { $this->metadataRepository = $metadataRepository; } @@ -75,7 +75,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * @access protected * @var StructureRepository */ - protected $structureRepository; + protected StructureRepository $structureRepository; /** * @access public @@ -84,7 +84,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * * @return void */ - public function injectStructureRepository(StructureRepository $structureRepository) + public function injectStructureRepository(StructureRepository $structureRepository): void { $this->structureRepository = $structureRepository; } @@ -94,7 +94,7 @@ public function injectStructureRepository(StructureRepository $structureReposito * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); @@ -138,9 +138,9 @@ public function mainAction() * @param array $metadata The metadata array * @param bool $useOriginalIiifManifestMetadata Output IIIF metadata as simple key/value pairs? * - * @return string The metadata array ready for output + * @return void */ - protected function printMetadata(array $metadata, $useOriginalIiifManifestMetadata = false) + protected function printMetadata(array $metadata, bool $useOriginalIiifManifestMetadata = false): void { if ($useOriginalIiifManifestMetadata) { $iiifData = $this->buildIiifData($metadata); @@ -254,7 +254,7 @@ private function buildIiifDataGroup(string $label, string $value): array * * @return array The raw metadata array ready for output */ - private function buildMetaCObjData(array $metadata) + private function buildMetaCObjData(array $metadata): array { $metaCObjData = []; @@ -280,7 +280,7 @@ private function buildMetaCObjData(array $metadata) * * @return array URLs */ - private function buildUrlFromMetadata(array $metadata) + private function buildUrlFromMetadata(array $metadata): array { $buildUrl = []; @@ -307,7 +307,7 @@ private function buildUrlFromMetadata(array $metadata) * * @return array external URLs */ - private function buildExternalUrlFromMetadata(array $metadata) + private function buildExternalUrlFromMetadata(array $metadata): array { $externalUrl = []; @@ -339,7 +339,8 @@ private function buildExternalUrlFromMetadata(array $metadata) * * @return void */ - private function parseMetadata(int $i, string $name, $value, array &$metadata) : void { + private function parseMetadata(int $i, string $name, $value, array &$metadata) : void + { if ($name == 'title') { // Get title of parent document if needed. if (empty(implode('', $value)) && $this->settings['getTitle'] && $this->document->getPartof()) { @@ -385,7 +386,7 @@ private function parseMetadata(int $i, string $name, $value, array &$metadata) : * * @return array metadata */ - private function getMetadata() + private function getMetadata(): array { $metadata = []; if ($this->settings['rootline'] < 2) { @@ -425,7 +426,7 @@ private function getMetadata() * * @return array metadata */ - private function getMetadataForIds($id, $metadata) + private function getMetadataForIds(array $id, array $metadata): array { $useOriginalIiifManifestMetadata = $this->settings['originalIiifMetadata'] == 1 && $this->currentDocument instanceof IiifManifest; foreach ($id as $sid) { @@ -452,7 +453,8 @@ private function getMetadataForIds($id, $metadata) * * @return void */ - private function setDefault($setting, $value) { + private function setDefault(string $setting, int $value): void + { if (!isset($this->settings[$setting])) { $this->settings[$setting] = $value; } diff --git a/Classes/Controller/NavigationController.php b/Classes/Controller/NavigationController.php index 2f95d75763..19b8737202 100644 --- a/Classes/Controller/NavigationController.php +++ b/Classes/Controller/NavigationController.php @@ -33,7 +33,8 @@ class NavigationController extends AbstractController * * @return void */ - public function pageSelectAction(PageSelectForm $pageSelectForm = NULL) { + public function pageSelectAction(PageSelectForm $pageSelectForm = NULL): void + { if ($pageSelectForm) { $uri = $this->uriBuilder->reset() ->setArguments( @@ -57,7 +58,7 @@ public function pageSelectAction(PageSelectForm $pageSelectForm = NULL) { * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); diff --git a/Classes/Controller/PageGridController.php b/Classes/Controller/PageGridController.php index 63265cf162..e0b864b1dd 100644 --- a/Classes/Controller/PageGridController.php +++ b/Classes/Controller/PageGridController.php @@ -11,10 +11,8 @@ namespace Kitodo\Dlf\Controller; -use TYPO3\CMS\Core\Pagination\ArrayPaginator; use Kitodo\Dlf\Pagination\PageGridPagination; use Kitodo\Dlf\Pagination\PageGridPaginator; -use TYPO3\CMS\Core\Pagination\SimplePagination; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -34,7 +32,7 @@ class PageGridController extends AbstractController * * @return void */ - public function mainAction() + public function mainAction(): void { $this->loadDocument(); if ( @@ -85,7 +83,7 @@ public function mainAction() * * @return array The rendered entry ready for fluid */ - protected function getEntry($number, $fileGrpThumbs) + protected function getEntry(int $number, string $fileGrpThumbs): array { // Set pagination. $entry['pagination'] = htmlspecialchars($this->document->getCurrentDocument()->physicalStructureInfo[$this->document->getCurrentDocument()->physicalStructure[$number]]['orderlabel']); diff --git a/Classes/Controller/PageViewController.php b/Classes/Controller/PageViewController.php index cd469d6c03..dc7d0089bd 100644 --- a/Classes/Controller/PageViewController.php +++ b/Classes/Controller/PageViewController.php @@ -31,19 +31,19 @@ class PageViewController extends AbstractController * @access protected * @var array Holds the controls to add to the map */ - protected $controls = []; + protected array $controls = []; /** * @access protected * @var array Holds the current images' URLs and MIME types */ - protected $images = []; + protected array $images = []; /** * @access protected * @var array Holds the current full texts' URLs */ - protected $fulltexts = []; + protected array $fulltexts = []; /** * Holds the current AnnotationLists / AnnotationPages @@ -51,7 +51,7 @@ class PageViewController extends AbstractController * @access protected * @var array Holds the current AnnotationLists / AnnotationPages */ - protected $annotationContainers = []; + protected array $annotationContainers = []; /** * The main method of the plugin @@ -60,7 +60,7 @@ class PageViewController extends AbstractController * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); @@ -102,7 +102,7 @@ public function mainAction() * * @return array URL and MIME type of fulltext file */ - protected function getFulltext($page) + protected function getFulltext(int $page): array { $fulltext = []; // Get fulltext link. @@ -135,7 +135,7 @@ protected function getFulltext($page) * * @return void */ - protected function addViewerJS() + protected function addViewerJS(): void { // Viewer configuration. $viewerConfiguration = '$(document).ready(function() { @@ -162,7 +162,7 @@ protected function addViewerJS() * @param int $page Page number * @return array An array containing the IRIs of the AnnotationLists / AnnotationPages as well as some information about the canvas. */ - protected function getAnnotationContainers($page) + protected function getAnnotationContainers(int $page): array { if ($this->document->getCurrentDocument() instanceof IiifManifest) { $canvasId = $this->document->getCurrentDocument()->physicalStructure[$page]; @@ -219,7 +219,7 @@ protected function getAnnotationContainers($page) * * @return array URL and MIME type of image file */ - protected function getImage($page) + protected function getImage(int $page): array { $image = []; // Get @USE value of METS fileGrp. diff --git a/Classes/Controller/SearchController.php b/Classes/Controller/SearchController.php index 7006f13ddb..d6b508a62f 100644 --- a/Classes/Controller/SearchController.php +++ b/Classes/Controller/SearchController.php @@ -15,11 +15,13 @@ use Kitodo\Dlf\Common\Helper; use Kitodo\Dlf\Common\Indexer; use Kitodo\Dlf\Common\Solr\Solr; +use Kitodo\Dlf\Domain\Model\Collection; +use Kitodo\Dlf\Domain\Repository\CollectionRepository; +use Kitodo\Dlf\Domain\Repository\MetadataRepository; +use Solarium\Component\Result\FacetSet; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Utility\GeneralUtility; -use Kitodo\Dlf\Domain\Repository\CollectionRepository; -use Kitodo\Dlf\Domain\Repository\MetadataRepository; /** * Controller class for the plugin 'Search'. @@ -35,7 +37,7 @@ class SearchController extends AbstractController * @access protected * @var CollectionRepository */ - protected $collectionRepository; + protected CollectionRepository $collectionRepository; /** * @access public @@ -44,7 +46,7 @@ class SearchController extends AbstractController * * @return void */ - public function injectCollectionRepository(CollectionRepository $collectionRepository) + public function injectCollectionRepository(CollectionRepository $collectionRepository): void { $this->collectionRepository = $collectionRepository; } @@ -53,7 +55,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * @access protected * @var MetadataRepository */ - protected $metadataRepository; + protected MetadataRepository $metadataRepository; /** * @access public @@ -62,7 +64,7 @@ public function injectCollectionRepository(CollectionRepository $collectionRepos * * @return void */ - public function injectMetadataRepository(MetadataRepository $metadataRepository) + public function injectMetadataRepository(MetadataRepository $metadataRepository): void { $this->metadataRepository = $metadataRepository; } @@ -71,7 +73,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * @access protected * @var array The current search parameter */ - protected $searchParams; + protected ?array $searchParams; /** * Search Action @@ -80,7 +82,7 @@ public function injectMetadataRepository(MetadataRepository $metadataRepository) * * @return void */ - public function searchAction() + public function searchAction(): void { // if search was triggered, get search parameters from POST variables $this->searchParams = $this->getParametersSafely('searchParameter'); @@ -98,7 +100,7 @@ public function searchAction() * * @return void */ - public function mainAction() + public function mainAction(): void { $listViewSearch = false; // Quit without doing anything if required variables are not set. @@ -198,10 +200,8 @@ public function mainAction() * Adds the facets menu to the search form * * @access protected - * - * @return string HTML output of facets menu */ - protected function addFacetsMenu() + protected function addFacetsMenu(): void { // Quit without doing anything if no facets are configured. if (empty($this->settings['facets']) && empty($this->settings['facetCollections'])) { @@ -226,7 +226,7 @@ protected function addFacetsMenu() * * @return array HMENU array */ - public function makeFacetsMenuArray($facets) + public function makeFacetsMenuArray(array $facets): array { // Set default value for facet search. $search = [ @@ -367,7 +367,8 @@ public function makeFacetsMenuArray($facets) * * @return string The collection query string */ - private function addCollectionsQuery($query) { + private function addCollectionsQuery(string $query): string + { // if collections are given, we prepare the collections query string // extract collections from collection parameter $collections = null; @@ -421,7 +422,7 @@ private function addCollectionsQuery($query) { * * @return array The array for the facet's menu entry */ - private function getFacetsMenuEntry($field, $value, $count, $search, &$state) + private function getFacetsMenuEntry(string $field, string $value, int $count, array $search, string &$state): array { $entryArray = []; $entryArray['title'] = $this->translateValue($field, $value); @@ -456,13 +457,14 @@ private function getFacetsMenuEntry($field, $value, $count, $search, &$state) * * @access private * - * @param array $facet + * @param FacetSet|null $facet * @param array $facetCollectionArray * @param array $search * * @return array menu array */ - private function processResults($facet, $facetCollectionArray, $search) { + private function processResults($facet, array $facetCollectionArray, array $search): array + { $menuArray = []; if ($facet) { @@ -510,7 +512,7 @@ private function processResults($facet, $facetCollectionArray, $search) { * * @return string */ - private function translateValue($field, $value) + private function translateValue(string $field, string $value): string { switch ($field) { case 'owner_faceting': @@ -535,16 +537,16 @@ private function translateValue($field, $value) * * @access private * - * @return string The extended search form or an empty string + * @return void */ - private function addExtendedSearch() + private function addExtendedSearch(): void { // Quit without doing anything if no fields for extended search are selected. if ( empty($this->settings['extendedSlotCount']) || empty($this->settings['extendedFields']) ) { - return ''; + return; } // Get field selector options. diff --git a/Classes/Controller/StatisticsController.php b/Classes/Controller/StatisticsController.php index 336caeab34..779648e6e8 100644 --- a/Classes/Controller/StatisticsController.php +++ b/Classes/Controller/StatisticsController.php @@ -30,7 +30,7 @@ class StatisticsController extends AbstractController * * @return void */ - public function mainAction() + public function mainAction(): void { $foundNumbers = $this->documentRepository->getStatisticsForSelectedCollection($this->settings); diff --git a/Classes/Controller/TableOfContentsController.php b/Classes/Controller/TableOfContentsController.php index 209c4b7da9..e15428d9a7 100644 --- a/Classes/Controller/TableOfContentsController.php +++ b/Classes/Controller/TableOfContentsController.php @@ -31,7 +31,7 @@ class TableOfContentsController extends AbstractController * @access protected * @var array This holds the active entries according to the currently selected page */ - protected $activeEntries = []; + protected array $activeEntries = []; /** * The main method of the plugin @@ -40,7 +40,7 @@ class TableOfContentsController extends AbstractController * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); @@ -61,7 +61,7 @@ public function mainAction() * * @return array HMENU array */ - private function makeMenuArray() + private function makeMenuArray(): array { $menuArray = []; // Does the document have physical elements or is it an external file? @@ -115,7 +115,7 @@ private function makeMenuArray() * * @return array HMENU array for menu entry */ - private function getMenuEntry(array $entry, $recursive = false) + private function getMenuEntry(array $entry, bool $recursive = false): array { $entry = $this->resolveMenuEntry($entry); @@ -215,7 +215,7 @@ private function getMenuEntry(array $entry, $recursive = false) * * @return array */ - private function resolveMenuEntry($entry) + private function resolveMenuEntry(array $entry): array { // If the menu entry points to the parent document, // resolve to the parent UID set on indexation. @@ -239,7 +239,8 @@ private function resolveMenuEntry($entry) * * @return void */ - private function getAllLogicalUnits() { + private function getAllLogicalUnits(): void + { if ( !empty($this->requestData['page']) && !empty($this->document->getCurrentDocument()->physicalStructure) @@ -265,7 +266,8 @@ private function getAllLogicalUnits() { * * @return string */ - private function getTranslatedType($type) { + private function getTranslatedType(string $type): string + { return Helper::translate($type, 'tx_dlf_structures', $this->settings['storagePid']); } @@ -285,7 +287,8 @@ private function getTranslatedType($type) { * * @return bool */ - private function isMultiElement($type) { + private function isMultiElement(string $type): bool + { return $type === 'multivolume_work' || $type === 'multipart_manuscript'; } /** @@ -297,7 +300,8 @@ private function isMultiElement($type) { * * @return string */ - private function setTitle($entry) { + private function setTitle(array $entry): string + { if (empty($entry['label']) && empty($entry['orderlabel'])) { foreach ($this->settings['titleReplacements'] as $titleReplacement) { if ($entry['type'] == $titleReplacement['type']) { @@ -327,7 +331,8 @@ private function setTitle($entry) { * * @return void */ - private function sortMenu(&$menu) { + private function sortMenu(array &$menu): void + { if ($menu[0]['type'] == $this->getTranslatedType("newspaper")) { $this->sortSubMenu($menu); } @@ -345,7 +350,8 @@ private function sortMenu(&$menu) { * * @return void */ - private function sortSubMenu(&$menu) { + private function sortSubMenu(array &$menu): void + { usort($menu[0]['_SUB_MENU'], function ($firstElement, $secondElement) { if (!empty($firstElement['orderlabel'])) { return $firstElement['orderlabel'] <=> $secondElement['orderlabel']; diff --git a/Classes/Controller/ToolboxController.php b/Classes/Controller/ToolboxController.php index 8b090c8201..6f51c377d3 100644 --- a/Classes/Controller/ToolboxController.php +++ b/Classes/Controller/ToolboxController.php @@ -11,6 +11,7 @@ namespace Kitodo\Dlf\Controller; +use Kitodo\Dlf\Common\AbstractDocument; use Kitodo\Dlf\Common\Helper; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; @@ -28,9 +29,9 @@ class ToolboxController extends AbstractController /** * @access private - * @var \Kitodo\Dlf\Common\AbstractDocument This holds the current document + * @var AbstractDocument This holds the current document */ - private $doc; + private AbstractDocument $currentDocument; /** * The main method of the plugin @@ -39,7 +40,7 @@ class ToolboxController extends AbstractController * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); @@ -47,7 +48,7 @@ public function mainAction() $this->view->assign('double', $this->requestData['double']); if (!$this->isDocMissingOrEmpty()) { - $this->doc = $this->document->getCurrentDocument(); + $this->currentDocument = $this->document->getCurrentDocument(); } $this->renderTool(); @@ -61,7 +62,8 @@ public function mainAction() * * @return void */ - private function renderTool() { + private function renderTool(): void + { if (!empty($this->settings['tool'])) { switch ($this->settings['tool']) { case 'tx_dlf_annotationtool': @@ -107,7 +109,8 @@ private function renderTool() { * * @return void */ - private function renderToolByName(string $tool) { + private function renderToolByName(string $tool): void + { $this->$tool(); $this->view->assign($tool, true); } @@ -119,7 +122,7 @@ private function renderToolByName(string $tool) { * * @return void */ - private function renderAnnotationTool() + private function renderAnnotationTool(): void { if ($this->isDocMissingOrEmpty()) { // Quit without doing anything if required variables are not set. @@ -128,7 +131,7 @@ private function renderAnnotationTool() $this->setPage(); - $annotationContainers = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->requestData['page']]]['annotationContainers']; + $annotationContainers = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$this->requestData['page']]]['annotationContainers']; if ( $annotationContainers != null && sizeof($annotationContainers) > 0 @@ -146,7 +149,7 @@ private function renderAnnotationTool() * * @return void */ - private function renderFulltextDownloadTool() + private function renderFulltextDownloadTool(): void { if ( $this->isDocMissingOrEmpty() @@ -169,7 +172,7 @@ private function renderFulltextDownloadTool() * * @return void */ - private function renderFulltextTool() + private function renderFulltextTool(): void { if ( $this->isDocMissingOrEmpty() @@ -196,7 +199,7 @@ private function renderFulltextTool() * * @return void */ - private function renderImageDownloadTool() + private function renderImageDownloadTool(): void { if ( $this->isDocMissingOrEmpty() @@ -226,18 +229,18 @@ private function renderImageDownloadTool() * * @return array Array of image links and image format information */ - private function getImage($page) + private function getImage(int $page): array { $image = []; // Get @USE value of METS fileGrp. $fileGrps = GeneralUtility::trimExplode(',', $this->settings['fileGrpsImageDownload']); while ($fileGrp = @array_pop($fileGrps)) { // Get image link. - $physicalStructureInfo = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$page]]; + $physicalStructureInfo = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$page]]; $fileId = $physicalStructureInfo['files'][$fileGrp]; - if (!empty($fileGroup)) { - $image['url'] = $this->doc->getDownloadLocation($fileId); - $image['mimetype'] = $this->doc->getFileMimeType($fileId); + if (!empty($fileId)) { + $image['url'] = $this->currentDocument->getDownloadLocation($fileId); + $image['mimetype'] = $this->currentDocument->getFileMimeType($fileId); switch ($image['mimetype']) { case 'image/jpeg': $image['mimetypeLabel'] = ' (JPG)'; @@ -263,7 +266,7 @@ private function getImage($page) * * @return void */ - private function renderImageManipulationTool() + private function renderImageManipulationTool(): void { // Set parent element for initialization. $parentContainer = !empty($this->settings['parentContainer']) ? $this->settings['parentContainer'] : '.tx-dlf-imagemanipulationtool'; @@ -279,7 +282,7 @@ private function renderImageManipulationTool() * * @return void */ - private function renderPdfDownloadTool() + private function renderPdfDownloadTool(): void { if ( $this->isDocMissingOrEmpty() @@ -304,7 +307,7 @@ private function renderPdfDownloadTool() * * @return array Link to downloadable page */ - private function getPageLink() + private function getPageLink(): array { $firstPageLink = ''; $secondPageLink = ''; @@ -313,17 +316,17 @@ private function getPageLink() $fileGrpsDownload = GeneralUtility::trimExplode(',', $this->extConf['fileGrpDownload']); // Get image link. while ($fileGrpDownload = array_shift($fileGrpsDownload)) { - $firstFileGroupDownload = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber]]['files'][$fileGrpDownload]; + $firstFileGroupDownload = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$pageNumber]]['files'][$fileGrpDownload]; if (!empty($firstFileGroupDownload)) { - $firstPageLink = $this->doc->getFileLocation($firstFileGroupDownload); + $firstPageLink = $this->currentDocument->getFileLocation($firstFileGroupDownload); // Get second page, too, if double page view is activated. - $secondFileGroupDownload = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$pageNumber + 1]]['files'][$fileGrpDownload]; + $secondFileGroupDownload = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$pageNumber + 1]]['files'][$fileGrpDownload]; if ( $this->requestData['double'] - && $pageNumber < $this->doc->numPages + && $pageNumber < $this->currentDocument->numPages && !empty($secondFileGroupDownload) ) { - $secondPageLink = $this->doc->getFileLocation($secondFileGroupDownload); + $secondPageLink = $this->currentDocument->getFileLocation($secondFileGroupDownload); } break; } @@ -351,20 +354,20 @@ private function getPageLink() * * @return string Link to downloadable work */ - private function getWorkLink() + private function getWorkLink(): string { $workLink = ''; $fileGrpsDownload = GeneralUtility::trimExplode(',', $this->extConf['fileGrpDownload']); // Get work link. while ($fileGrpDownload = array_shift($fileGrpsDownload)) { - $fileGroupDownload = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[0]]['files'][$fileGrpDownload]; + $fileGroupDownload = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[0]]['files'][$fileGrpDownload]; if (!empty($fileGroupDownload)) { - $workLink = $this->doc->getFileLocation($fileGroupDownload); + $workLink = $this->currentDocument->getFileLocation($fileGroupDownload); break; } else { - $details = $this->doc->getLogicalStructure($this->doc->toplevelId); + $details = $this->currentDocument->getLogicalStructure($this->currentDocument->toplevelId); if (!empty($details['files'][$fileGrpDownload])) { - $workLink = $this->doc->getFileLocation($details['files'][$fileGrpDownload]); + $workLink = $this->currentDocument->getFileLocation($details['files'][$fileGrpDownload]); break; } } @@ -382,7 +385,7 @@ private function getWorkLink() * * @return void */ - private function renderSearchInDocumentTool() + private function renderSearchInDocumentTool(): void { if ( $this->isDocMissingOrEmpty() @@ -425,7 +428,7 @@ private function renderSearchInDocumentTool() * * @return string with current document id */ - private function getCurrentDocumentId() + private function getCurrentDocumentId(): string { $id = $this->document->getUid(); @@ -461,7 +464,7 @@ private function getCurrentDocumentId() * * @return string with encrypted core name */ - private function getEncryptedCoreName() + private function getEncryptedCoreName(): string { // Get core name. $name = Helper::getIndexNameFromUid($this->settings['solrcore'], 'tx_dlf_solrcores'); @@ -479,10 +482,11 @@ private function getEncryptedCoreName() * * @return bool true if empty, false otherwise */ - private function isFullTextEmpty() { + private function isFullTextEmpty(): bool + { $fileGrpsFulltext = GeneralUtility::trimExplode(',', $this->extConf['fileGrpFulltext']); while ($fileGrpFulltext = array_shift($fileGrpsFulltext)) { - $fullTextFile = $this->doc->physicalStructureInfo[$this->doc->physicalStructure[$this->requestData['page']]]['files'][$fileGrpFulltext]; + $fullTextFile = $this->currentDocument->physicalStructureInfo[$this->currentDocument->physicalStructure[$this->requestData['page']]]['files'][$fileGrpFulltext]; if (!empty($fullTextFile)) { break; } diff --git a/Classes/Controller/View3DController.php b/Classes/Controller/View3DController.php index 3c8fae78f7..ba9f1c5be0 100644 --- a/Classes/Controller/View3DController.php +++ b/Classes/Controller/View3DController.php @@ -26,7 +26,7 @@ class View3DController extends AbstractController * * @return void */ - public function mainAction() + public function mainAction(): void { // Load current document. $this->loadDocument(); diff --git a/Classes/Domain/Model/Document.php b/Classes/Domain/Model/Document.php index 1737c393d7..8533f54754 100644 --- a/Classes/Domain/Model/Document.php +++ b/Classes/Domain/Model/Document.php @@ -638,9 +638,9 @@ public function addCollection(Collection $collection): void * * @param Collection $collection * - * @return ObjectStorage collections + * @return void */ - public function removeCollection(Collection $collection) + public function removeCollection(Collection $collection): void { $this->collections->detach($collection); } diff --git a/Classes/Domain/Model/Metadata.php b/Classes/Domain/Model/Metadata.php index 1e2eeb4e3f..74910e0d6e 100644 --- a/Classes/Domain/Model/Metadata.php +++ b/Classes/Domain/Model/Metadata.php @@ -52,7 +52,7 @@ class Metadata extends AbstractEntity /** * @access protected - * @var ObjectStorage The formats that encode this metadatum (local IRRE field to ``tx_dlf_metadataformat``). + * @var ObjectStorage The formats that encode this metadata (local IRRE field to ``tx_dlf_metadataformat``). * * @Extbase\ORM\Lazy * @Extbase\ORM\Cascade("remove") diff --git a/Classes/Domain/Repository/CollectionRepository.php b/Classes/Domain/Repository/CollectionRepository.php index b6c373788a..6774f00d0e 100644 --- a/Classes/Domain/Repository/CollectionRepository.php +++ b/Classes/Domain/Repository/CollectionRepository.php @@ -12,6 +12,7 @@ namespace Kitodo\Dlf\Domain\Repository; +use Doctrine\DBAL\ForwardCompatibility\Result; use Kitodo\Dlf\Common\Helper; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -42,11 +43,11 @@ class CollectionRepository extends Repository * * @access public * - * @param string $uids separated by comma + * @param array $uids * * @return QueryResultInterface */ - public function findAllByUids($uids) + public function findAllByUids(array $uids): QueryResultInterface { $query = $this->createQuery(); @@ -69,7 +70,7 @@ public function findAllByUids($uids) * * @return QueryResultInterface */ - public function getCollectionForMetadata($pages) + public function getCollectionForMetadata(string $pages): QueryResultInterface { // Get list of collections to show. $query = $this->createQuery(); @@ -86,9 +87,9 @@ public function getCollectionForMetadata($pages) * * @param array $settings * - * @return array|QueryResultInterface + * @return QueryResultInterface */ - public function findCollectionsBySettings($settings = []) + public function findCollectionsBySettings(array $settings = []): QueryResultInterface { $query = $this->createQuery(); @@ -134,9 +135,9 @@ public function findCollectionsBySettings($settings = []) * @param array $settings * @param mixed $set * - * @return array|QueryResultInterface + * @return Result */ - public function getIndexNameForSolr($settings, $set) + public function getIndexNameForSolr(array $settings, $set): Result { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('tx_dlf_collections'); @@ -161,10 +162,9 @@ public function getIndexNameForSolr($settings, $set) $where, Helper::whereExpression('tx_dlf_collections') ) - ->setMaxResults(1) - ->execute(); + ->setMaxResults(1); - return $result; + return $result->execute(); } } diff --git a/Classes/Domain/Repository/MailRepository.php b/Classes/Domain/Repository/MailRepository.php index 31c6665494..e17a9ca221 100644 --- a/Classes/Domain/Repository/MailRepository.php +++ b/Classes/Domain/Repository/MailRepository.php @@ -15,6 +15,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; use TYPO3\CMS\Extbase\Persistence\Repository; +use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; /** * Mail repository. @@ -32,11 +33,11 @@ class MailRepository extends Repository * * @access public * - * @param int @pid + * @param int $pid * - * @return array|\TYPO3\CMS\Extbase\Persistence\QueryResultInterface + * @return array|QueryResultInterface */ - public function findAllWithPid($pid) + public function findAllWithPid(int $pid) { /** @var Typo3QuerySettings $querySettings */ $querySettings = GeneralUtility::makeInstance(Typo3QuerySettings::class); diff --git a/Classes/Domain/Repository/MetadataRepository.php b/Classes/Domain/Repository/MetadataRepository.php index e5beecc9bc..dc38aa20b8 100644 --- a/Classes/Domain/Repository/MetadataRepository.php +++ b/Classes/Domain/Repository/MetadataRepository.php @@ -33,9 +33,9 @@ class MetadataRepository extends Repository * * @param array $settings * - * @return array|QueryResultInterface + * @return QueryResultInterface */ - public function findBySettings($settings = []) + public function findBySettings(array $settings = []): QueryResultInterface { $query = $this->createQuery(); diff --git a/Classes/Domain/Repository/TokenRepository.php b/Classes/Domain/Repository/TokenRepository.php index b8799baa50..fcc1fc194d 100644 --- a/Classes/Domain/Repository/TokenRepository.php +++ b/Classes/Domain/Repository/TokenRepository.php @@ -33,7 +33,7 @@ class TokenRepository extends Repository * * @return void */ - public function deleteExpiredTokens($expireTime) + public function deleteExpiredTokens(int $expireTime): void { $query = $this->createQuery();