From 381cf7064fa564583859a25608d8228adadce8a3 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Tue, 23 Jun 2026 13:09:17 +0200 Subject: [PATCH 1/2] [MAINTENANCE] Bump phpstan/phpstan to ^2.2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 61fd8aa70..a9dccf31e 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "require-dev": { "fluidtypo3/vhs": "^7.2", "friendsofphp/php-cs-fixer": "^3.95", - "phpstan/phpstan": "^1.12", + "phpstan/phpstan": "^2.2", "phpunit/phpunit": "^10.5", "spatie/phpunit-watcher": "^1.24", "typo3/cms-backend": "^12.4|^13.4", From b0b13d03803dcb7c437ac27374a5121267f8fc79 Mon Sep 17 00:00:00 2001 From: Beatrycze Volk Date: Tue, 28 Jul 2026 14:27:51 +0200 Subject: [PATCH 2/2] [MAINTENANCE] Adjust code to be compatible with new version of PHPStan --- .github/phpstan_12.4.neon | 21 ++++++----- .github/phpstan_13.4.neon | 13 ++++--- Classes/Command/BaseCommand.php | 2 +- Classes/Command/DatabaseDocs/Generator.php | 11 ++---- Classes/Common/AbstractDocument.php | 25 +++++++------ Classes/Common/IiifManifest.php | 37 +++++++++---------- Classes/Common/MetsDocument.php | 38 ++++++++++---------- Classes/Common/Solr/SolrSearch.php | 6 ++-- Classes/Controller/CalendarController.php | 2 +- Classes/Controller/ToolboxController.php | 27 +++++++------- Classes/Hooks/DataHandler.php | 4 +-- Classes/Task/BaseAdditionalFieldProvider.php | 4 +-- Classes/Updates/MigrateSettings.php | 2 +- 13 files changed, 94 insertions(+), 98 deletions(-) diff --git a/.github/phpstan_12.4.neon b/.github/phpstan_12.4.neon index dc1b6fb6e..6e3e162a3 100644 --- a/.github/phpstan_12.4.neon +++ b/.github/phpstan_12.4.neon @@ -1,17 +1,9 @@ parameters: ignoreErrors: - '#Call to an undefined method Psr\\Http\\Message\\RequestFactoryInterface::request\(\)\.#' - - '#Call to an undefined method Ubl\\Iiif\\Presentation\\Common\\Model\\Resources\\ManifestInterface::getOriginalJsonArray\(\)\.#' - - '#Call to an undefined method Ubl\\Iiif\\Presentation\\Common\\Model\\Resources\\RangeInterface::getMemberRangesAndRanges\(\)\.#' - - message: '#Class TYPO3\\CMS\\Core\\Database\\Schema\\Parser\\Lexer constructor invoked with 0 parameters, 1 required\.#' - path: ../Classes/Command/DatabaseDocs/Generator.php - - - message: '#Parameter \#1 \$statement of class TYPO3\\CMS\\Core\\Database\\Schema\\Parser\\Parser constructor expects string, TYPO3\\CMS\\Core\\Database\\Schema\\Parser\\Lexer given\.#' - path: ../Classes/Command/DatabaseDocs/Generator.php - - - message: '#Method TYPO3\\CMS\\Core\\Database\\Schema\\Parser\\Parser::parse\(\) invoked with 1 parameter, 0 required\.#' - path: ../Classes/Command/DatabaseDocs/Generator.php + message: '#Call to an undefined method DOMXPath|SimpleXMLElement::getName\(\)\.#' + path: ../Classes/Common/MetsDocument.php - message: '#Class TYPO3\\CMS\\Core\\TypoScript\\FrontendTypoScriptFactory not found\.#' path: ../Classes/Common/TypoScriptHelper.php @@ -21,6 +13,9 @@ parameters: - message: '#Call to method createSetupConfigOrFullSetup\(\) on an unknown class TYPO3\\CMS\\Core\\TypoScript\\FrontendTypoScriptFactory\.#' path: ../Classes/Common/TypoScriptHelper.php + - + message: '#Parameter \#1 \$separator of function explode expects non-empty-string, string given\.#' + path: ../Classes/Controller/ToolboxController.php - message: '#PHPDoc tag @var for variable \$action contains unknown class TYPO3\\CMS\\Scheduler\\SchedulerManagementAction\.#' path: ../Classes/Task/BaseAdditionalFieldProvider.php @@ -30,10 +25,14 @@ parameters: - message: '#Cannot call method getFirst\(\) on iterable|TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface\.#' path: ../Classes/Controller/Backend/NewTenantController.php + - + message: '#PHPDoc tag \@var with type TYPO3\\CMS\\Scheduler\\SchedulerManagementAction is not subtype of native type TYPO3\\CMS\\Scheduler\\Task\\Enumeration\\Action\.#' + path: ../Classes/Task/BaseAdditionalFieldProvider.php level: 7 paths: - ../Classes/ excludePaths: + - ../Classes/Common/IiifManifest.php - ../Classes/Controller/OaiPmhController.php - - ../Classes/Command/DbDocs/Generator.php # dbdocs command is not supported in Typo3 v12 + - ../Classes/Command/DatabaseDocs/Generator.php # dbdocs command is not supported in Typo3 v12 treatPhpDocTypesAsCertain: false diff --git a/.github/phpstan_13.4.neon b/.github/phpstan_13.4.neon index 8713d8982..523826916 100644 --- a/.github/phpstan_13.4.neon +++ b/.github/phpstan_13.4.neon @@ -1,17 +1,18 @@ parameters: ignoreErrors: - '#Call to an undefined method Psr\\Http\\Message\\RequestFactoryInterface::request\(\)\.#' - - '#Call to an undefined method Ubl\\Iiif\\Presentation\\Common\\Model\\Resources\\ManifestInterface::getOriginalJsonArray\(\)\.#' - - '#Call to an undefined method Ubl\\Iiif\\Presentation\\Common\\Model\\Resources\\RangeInterface::getMemberRangesAndRanges\(\)\.#' - - message: '#Method TYPO3\\CMS\\Core\\Database\\Schema\\Parser\\Parser::parse\(\) invoked with 0 parameters, 1 required\.#' - path: ../Classes/Command/DatabaseDocs/Generator.php + message: '#Call to an undefined method DOMXPath|SimpleXMLElement::getName\(\)\.#' + path: ../Classes/Common/MetsDocument.php - message: '#Call to an undefined method TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController::getFromCache\(\)\.#' path: ../Classes/Common/TypoScriptHelper.php - message: '#Call to an undefined method TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController::releaseLocks\(\)\.#' path: ../Classes/Common/TypoScriptHelper.php + - + message: '#Parameter \#1 \$separator of function explode expects non-empty-string, string given\.#' + path: ../Classes/Controller/ToolboxController.php - message: '#PHPDoc tag @var for variable \$action contains unknown class TYPO3\\CMS\\Scheduler\\Task\\Enumeration\\Action\.#' path: ../Classes/Task/BaseAdditionalFieldProvider.php @@ -21,8 +22,12 @@ parameters: - message: '#Call to method equals\(\) on an unknown class TYPO3\\CMS\\Scheduler\\Task\\Enumeration\\Action\.#' path: ../Classes/Task/BaseAdditionalFieldProvider.php + - + message: '#PHPDoc tag \@var with type TYPO3\\CMS\\Scheduler\\Task\\Enumeration\\Action is not subtype of native type TYPO3\\CMS\\Scheduler\\SchedulerManagementAction\.#' + path: ../Classes/Task/BaseAdditionalFieldProvider.php level: 7 paths: - ../Classes excludePaths: + - ../Classes/Common/IiifManifest.php treatPhpDocTypesAsCertain: false diff --git a/Classes/Command/BaseCommand.php b/Classes/Command/BaseCommand.php index 2178164f5..556fbba67 100644 --- a/Classes/Command/BaseCommand.php +++ b/Classes/Command/BaseCommand.php @@ -138,7 +138,7 @@ protected function getSolrCoreUid(array $solrCores, bool|string|null $inputSolrI { if (MathUtility::canBeInterpretedAsInteger($inputSolrId)) { return MathUtility::forceIntegerInRange((int) $inputSolrId, 0); - } elseif (is_string($inputSolrId) && array_key_exists($inputSolrId, $solrCores)) { + } else if (is_string($inputSolrId) && array_key_exists($inputSolrId, $solrCores)) { return $solrCores[$inputSolrId]; } return null; diff --git a/Classes/Command/DatabaseDocs/Generator.php b/Classes/Command/DatabaseDocs/Generator.php index 1fbb7d54c..d30555ed3 100644 --- a/Classes/Command/DatabaseDocs/Generator.php +++ b/Classes/Command/DatabaseDocs/Generator.php @@ -18,7 +18,6 @@ use TYPO3\CMS\Core\Database\Schema\Parser\Lexer; use TYPO3\CMS\Core\Database\Schema\Parser\Parser; use TYPO3\CMS\Core\Database\Schema\SqlReader; -use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Localization\LanguageServiceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -104,14 +103,8 @@ public function collectTables(): array $result = []; foreach ($createTableStatements as $statement) { - $typo3Version = (new Typo3Version())->getMajorVersion(); - if ($typo3Version >= 13) { - $parser = new Parser(new Lexer()); - list($table) = $parser->parse($statement); - } else { - $parser = new Parser($statement); - list($table) = $parser->parse(); - } + $parser = new Parser(new Lexer()); + list($table) = $parser->parse($statement); $tableName = $table->getName(); if (!str_starts_with($tableName, 'tx_dlf_')) { diff --git a/Classes/Common/AbstractDocument.php b/Classes/Common/AbstractDocument.php index 47df3c781..3051a4eed 100644 --- a/Classes/Common/AbstractDocument.php +++ b/Classes/Common/AbstractDocument.php @@ -17,7 +17,6 @@ use Kitodo\Dlf\Domain\Repository\DocumentRepository; use Kitodo\Dlf\Domain\Repository\FormatRepository; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; -use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Log\Logger; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; @@ -36,24 +35,24 @@ * @abstract * * @property int $configPid this holds the PID for the configuration - * @property-read array $formats this holds the configuration for all supported metadata encodings + * @property-read array> $formats this holds the configuration for all supported metadata encodings * @property bool $formatsLoaded flag with information if the available metadata formats are loaded * @property-read bool $hasFulltext flag with information if there are any fulltext files available - * @property array $lastSearchedPhysicalPage the last searched logical and physical page - * @property array $logicalUnits this holds the logical units - * @property-read array $metadataArray this holds the documents' parsed metadata array + * @property array $lastSearchedPhysicalPage the last searched logical and physical page + * @property mixed[] $logicalUnits this holds the logical units + * @property-read mixed[] $metadataArray this holds the documents' parsed metadata array * @property bool $metadataArrayLoaded flag with information if the metadata array is loaded * @property-read int $numPages the holds the total number of pages * @property-read int $parentId this holds the UID of the parent document or zero if not multi-volumed - * @property-read array $physicalStructure this holds the physical structure - * @property-read array $physicalStructureInfo this holds the physical structure metadata + * @property-read mixed[] $physicalStructure this holds the physical structure + * @property-read mixed[] $physicalStructureInfo this holds the physical structure metadata * @property bool $physicalStructureLoaded flag with information if the physical structure is loaded - * @property array $rawTextArray this holds the documents' raw text pages with their corresponding structMap//div's ID (METS) or Range / Manifest / Sequence ID (IIIF) as array key + * @property array $rawTextArray this holds the documents' raw text pages with their corresponding structMap//div's ID (METS) or Range / Manifest / Sequence ID (IIIF) as array key * @property-read string $recordId the METS file's / IIIF manifest's record identifier * @property-read int $rootId this holds the UID of the root document or zero if not multi-volumed - * @property-read array $smLinks this holds the smLinks between logical and physical structMap + * @property-read array $smLinks this holds the smLinks between logical and physical structMap * @property bool $smLinksLoaded flag with information if the smLinks are loaded - * @property-read array $tableOfContents this holds the logical structure + * @property-read array $tableOfContents this holds the logical structure * @property bool $tableOfContentsLoaded flag with information if the table of contents is loaded * @property-read string $thumbnail this holds the document's thumbnail location * @property bool $thumbnailLoaded flag with information if the thumbnail is loaded @@ -88,7 +87,7 @@ abstract class AbstractDocument /** * @access protected - * @var mixed[] Additional information about files (e.g., ADMID), indexed by ID. + * @var array> Additional information about files (e.g., ADMID), indexed by ID. */ protected array $fileInfos = []; @@ -319,7 +318,7 @@ abstract public function getDownloadLocation(string $id): string; * * @param string $id The "@ID" attribute of the file node (METS) or the "@id" property of the IIIF resource * - * @return mixed[]|null The set of file information + * @return array|null The set of file information */ abstract public function getFileInfo(string $id): ?array; @@ -852,7 +851,7 @@ protected function magicGetHasFulltext(): bool * * @access protected * - * @return array> Array of metadata with their corresponding logical structure node ID as key + * @return array>|int> Array of metadata with their corresponding logical structure node ID as key */ protected function magicGetMetadataArray(): array { diff --git a/Classes/Common/IiifManifest.php b/Classes/Common/IiifManifest.php index 1d484c050..0cd09cc4b 100644 --- a/Classes/Common/IiifManifest.php +++ b/Classes/Common/IiifManifest.php @@ -42,24 +42,24 @@ * @access public * * @property int $configPid this holds the PID for the configuration - * @property-read array $formats this holds the configuration for all supported metadata encodings + * @property-read array> $formats this holds the configuration for all supported metadata encodings * @property bool $formatsLoaded flag with information if the available metadata formats are loaded * @property-read bool $hasFulltext flag with information if there are any fulltext files available - * @property array $lastSearchedPhysicalPage the last searched logical and physical page - * @property array $logicalUnits this holds the logical units - * @property-read array $metadataArray this holds the documents' parsed metadata array + * @property array $lastSearchedPhysicalPage the last searched logical and physical page + * @property mixed[] $logicalUnits this holds the logical units + * @property-read mixed[] $metadataArray this holds the documents' parsed metadata array * @property bool $metadataArrayLoaded flag with information if the metadata array is loaded * @property-read int $numPages the holds the total number of pages * @property-read int $parentId this holds the UID of the parent document or zero if not multi-volumed - * @property-read array $physicalStructure this holds the physical structure - * @property-read array $physicalStructureInfo this holds the physical structure metadata + * @property-read mixed[] $physicalStructure this holds the physical structure + * @property-read mixed[] $physicalStructureInfo this holds the physical structure metadata * @property bool $physicalStructureLoaded flag with information if the physical structure is loaded - * @property array $rawTextArray this holds the documents' raw text pages with their corresponding structMap//div's ID (METS) or Range / Manifest / Sequence ID (IIIF) as array key + * @property array $rawTextArray this holds the documents' raw text pages with their corresponding structMap//div's ID (METS) or Range / Manifest / Sequence ID (IIIF) as array key * @property-read string $recordId the METS file's / IIIF manifest's record identifier * @property-read int $rootId this holds the UID of the root document or zero if not multi-volumed - * @property-read array $smLinks this holds the smLinks between logical and physical structMap + * @property-read array $smLinks this holds the smLinks between logical and physical structMap * @property bool $smLinksLoaded flag with information if the smLinks are loaded - * @property-read array $tableOfContents this holds the logical structure + * @property-read array $tableOfContents this holds the logical structure * @property bool $tableOfContentsLoaded flag with information if the table of contents is loaded * @property-read string $thumbnail this holds the document's thumbnail location * @property bool $thumbnailLoaded flag with information if the thumbnail is loaded @@ -68,8 +68,8 @@ * @property ManifestInterface $iiif a PHP object representation of a IIIF manifest * @property string $iiifVersion 'IIIF1', 'IIIF2' or 'IIIF3', depending on the API $this->iiif conforms to * @property bool $hasFulltextSet flag if document has already been analyzed for presence of the fulltext for the Solr index - * @property array $originalMetadataArray this holds the original manifest's parsed metadata array with their corresponding resource (Manifest / Sequence / Range) ID as array key - * @property array $mimeTypes this holds the mime types of linked resources in the manifest (extracted during parsing) for later us + * @property mixed[] $originalMetadataArray this holds the original manifest's parsed metadata array with their corresponding resource (Manifest / Sequence / Range) ID as array key + * @property mixed[] $mimeTypes this holds the mime types of linked resources in the manifest (extracted during parsing) for later us * */ final class IiifManifest extends AbstractDocument @@ -385,14 +385,15 @@ public function getLogicalStructure(string $id, bool $recursive = false): array } if (!empty($logUnits[0])) { + /** @var IiifResourceInterface[] $logUnits */ if (!$recursive) { - $details = $this->getLogicalStructureInfo($logUnits[0]); // @phpstan-ignore-line + $details = $this->getLogicalStructureInfo($logUnits[0]); } else { // cache the ranges - they might occur multiple times in the structures "tree" - with full data as well as referenced as id $processedStructures = []; foreach ($logUnits as $logUnit) { - if (!array_search($logUnit->getId(), $processedStructures)) { // @phpstan-ignore-line - $this->tableOfContents[] = $this->getLogicalStructureInfo($logUnit, true, $processedStructures); // @phpstan-ignore-line + if (!array_search($logUnit->getId(), $processedStructures)) { + $this->tableOfContents[] = $this->getLogicalStructureInfo($logUnit, true, $processedStructures); } } } @@ -409,7 +410,7 @@ public function getLogicalStructure(string $id, bool $recursive = false): array * @param bool $recursive Whether to include the child elements * @param mixed[] $processedStructures IIIF resources that already have been processed * - * @return array Logical structure array + * @return array Logical structure array */ protected function getLogicalStructureInfo(IiifResourceInterface $resource, bool $recursive = false, array &$processedStructures = []): array { @@ -462,7 +463,7 @@ protected function getLogicalStructureInfo(IiifResourceInterface $resource, bool * * @access private * - * @param array $details Logical structure array to which the start canvas info should be applied + * @param array $details Logical structure array to which the start canvas info should be applied * @param IiifResourceInterface $resource IIIF resource, either a manifest or range, for which the start canvas info should be applied * * @return void @@ -486,7 +487,7 @@ private function applyStartCanvasInfo(array &$details, IiifResourceInterface $re * * @access private * - * @param array $details Logical structure array to which the children should be added + * @param array $details Logical structure array to which the children should be added * @param ManifestInterface $resource IIIF manifest resource for which the children should be added * @param mixed[] $processedStructures IIIF resources that already have been processed * @@ -520,7 +521,7 @@ private function addChildrenFromManifest(array &$details, ManifestInterface $res * * @access private * - * @param array $details Logical structure array to which the children should be added + * @param array $details Logical structure array to which the children should be added * @param RangeInterface $resource IIIF range resource for which the children should be added * @param mixed[] $processedStructures IIIF resources that already have been processed * diff --git a/Classes/Common/MetsDocument.php b/Classes/Common/MetsDocument.php index fa57eac39..a367c79e4 100644 --- a/Classes/Common/MetsDocument.php +++ b/Classes/Common/MetsDocument.php @@ -37,37 +37,37 @@ * @access public * * @property int $configPid this holds the PID for the configuration - * @property-read array $formats this holds the configuration for all supported metadata encodings + * @property-read array> $formats this holds the configuration for all supported metadata encodings * @property bool $formatsLoaded flag with information if the available metadata formats are loaded * @property-read bool $hasFulltext flag with information if there are any fulltext files available - * @property array $lastSearchedPhysicalPage the last searched logical and physical page - * @property array $logicalUnits this holds the logical units - * @property-read array $metadataArray this holds the documents' parsed metadata array + * @property array $lastSearchedPhysicalPage the last searched logical and physical page + * @property mixed[] $logicalUnits this holds the logical units + * @property-read mixed[] $metadataArray this holds the documents' parsed metadata array * @property bool $metadataArrayLoaded flag with information if the metadata array is loaded * @property-read int $numPages the holds the total number of pages * @property-read int $numMeasures This holds the total number of measures * @property-read int $parentId this holds the UID of the parent document or zero if not multi-volumed - * @property-read array $physicalStructure this holds the physical structure - * @property-read array $physicalStructureInfo this holds the physical structure metadata - * @property-read array $musicalStructure This holds the musical structure - * @property-read array $musicalStructureInfo This holds the musical structure metadata + * @property-read mixed[] $physicalStructure this holds the physical structure + * @property-read mixed[] $physicalStructureInfo this holds the physical structure metadata + * @property-read mixed[] $musicalStructure This holds the musical structure + * @property-read mixed[] $musicalStructureInfo This holds the musical structure metadata * @property bool $physicalStructureLoaded flag with information if the physical structure is loaded - * @property array $rawTextArray this holds the documents' raw text pages with their corresponding structMap//div's ID (METS) or Range / Manifest / Sequence ID (IIIF) as array key + * @property array $rawTextArray this holds the documents' raw text pages with their corresponding structMap//div's ID (METS) or Range / Manifest / Sequence ID (IIIF) as array key * @property-read string $recordId the METS file's / IIIF manifest's record identifier * @property-read int $rootId this holds the UID of the root document or zero if not multi-volumed - * @property-read array $smLinks this holds the smLinks between logical and physical structMap + * @property-read array $smLinks this holds the smLinks between logical and physical structMap * @property bool $smLinksLoaded flag with information if the smLinks are loaded - * @property-read array $tableOfContents this holds the logical structure + * @property-read array $tableOfContents this holds the logical structure * @property bool $tableOfContentsLoaded flag with information if the table of contents is loaded * @property-read string $thumbnail this holds the document's thumbnail location * @property bool $thumbnailLoaded flag with information if the thumbnail is loaded * @property SimpleXMLElement $xml this holds the whole XML file as SimpleXMLElement object - * @property-read array $mdSec associative array of METS metadata sections indexed by their IDs. + * @property-read array $mdSec associative array of METS metadata sections indexed by their IDs. * @property bool $mdSecLoaded flag with information if the array of METS metadata sections is loaded - * @property-read array $dmdSec subset of `$mdSec` storing only the dmdSec entries; kept for compatibility. - * @property-read array $fileGrps this holds the file ID -> USE concordance + * @property-read array $dmdSec subset of `$mdSec` storing only the dmdSec entries; kept for compatibility. + * @property-read array $fileGrps this holds the file ID -> USE concordance * @property bool $fileGrpsLoaded flag with information if file groups array is loaded - * @property-read array $fileInfos additional information about files (e.g., ADMID), indexed by ID. + * @property-read array> $fileInfos additional information about files (e.g., ADMID), indexed by ID. * @property-read SimpleXMLElement $mets this holds the XML file's METS part as SimpleXMLElement object * @property-read string $parentHref URL of the parent document (determined via mptr element), or empty string if none is available */ @@ -855,7 +855,7 @@ private function extractAndProcessMetadata(string $dmdId, string $mdSectionType, $domXPath = new DOMXPath($domNode->ownerDocument); $this->registerNamespaces($domXPath); - $this->processAdditionalMetadata($additionalMetadata, $domXPath, $domNode, $metadata); + $this->processAdditionalMetadata($additionalMetadata, $domXPath, $domNode, $metadata); // phpstan-ignore-line return true; } @@ -922,7 +922,7 @@ private function setMetadataFieldValues(array $resArray, DOMXPath $domXPath, DOM if ($values instanceof DOMNodeList && $values->length > 0) { $metadata[$resArray['index_name']] = []; foreach ($values as $value) { - $subentries = $this->getSubentries($subentryResults, $resArray['index_name'], $value); + $subentries = $this->getSubentries($subentryResults, $resArray['index_name'], $value); // phpstan-ignore-line if ($subentries) { $metadata[$resArray['index_name']][] = $subentries; } else { @@ -1214,12 +1214,12 @@ protected function init(string $location, array $settings): void $this->structureRepository->useStoragePid($this->configPid); $this->settings = $settings; // Get METS node from XML file. - $this->registerNamespaces($this->xml); + $this->registerNamespaces($this->xml); // phpstan-ignore-line $mets = $this->xml->xpath('//mets:mets'); if (!empty($mets)) { $this->mets = $mets[0]; // Register namespaces. - $this->registerNamespaces($this->mets); + $this->registerNamespaces($this->mets); // phpstan-ignore-line } else { if (!empty($location)) { $this->logger->error('No METS part found in document with location "' . $location . '".'); diff --git a/Classes/Common/Solr/SolrSearch.php b/Classes/Common/Solr/SolrSearch.php index 630fa32f0..e333ac2f2 100644 --- a/Classes/Common/Solr/SolrSearch.php +++ b/Classes/Common/Solr/SolrSearch.php @@ -86,7 +86,7 @@ class SolrSearch implements \Countable, \Iterator, \ArrayAccess, QueryResultInte * @access private * @var mixed[]|null */ - private ?array $result; + private ?array $result = null; /** * @access private @@ -163,7 +163,7 @@ public function count(): int * * @return mixed[] */ - public function current(): array + public function current(): array // @phpstan-ignore-line { return $this[$this->position]; } @@ -280,7 +280,7 @@ public function offsetGet($offset) * * @throws \Exception */ - public function offsetSet($offset, $value): void + public function offsetSet($offset, $value): void // @phpstan-ignore-line { throw new \Exception("SolrSearch: Modifying result list is not supported"); } diff --git a/Classes/Controller/CalendarController.php b/Classes/Controller/CalendarController.php index 06fa392ea..0b6961c3f 100644 --- a/Classes/Controller/CalendarController.php +++ b/Classes/Controller/CalendarController.php @@ -121,7 +121,7 @@ public function calendarAction(): ResponseInterface $issueData[$dayTimestamp]['dateString'] = date('l, Y-m-d', $dayTimestamp); $issueData[$dayTimestamp]['items'] = []; foreach ($issues as $issue) { - $issueData[$dayTimestamp]['items'][] = $issue; + $issueData[$dayTimestamp]['items'][] = $issue; // @phpstan-ignore-line } } $this->view->assign('issueData', $issueData); diff --git a/Classes/Controller/ToolboxController.php b/Classes/Controller/ToolboxController.php index 279cc6379..b21358a2e 100644 --- a/Classes/Controller/ToolboxController.php +++ b/Classes/Controller/ToolboxController.php @@ -190,7 +190,7 @@ private function getImage(int $page): array /** * Renders the add document tool (used in template) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @SuppressWarnings("PHPMD.UnusedPrivateMethod") * * @access private * @@ -208,7 +208,7 @@ private function renderMultiViewAddSourceTool(): void /** * Renders the annotation tool (used in template) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @SuppressWarnings("PHPMD.UnusedPrivateMethod") * * @access private * @@ -236,7 +236,7 @@ private function renderAnnotationTool(): void /** * Renders the audio video tool (used in template) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @SuppressWarnings("PHPMD.UnusedPrivateMethod") * * @access private * @@ -264,7 +264,7 @@ private function renderAudioVideoTool(): void /** * Renders the fulltext download tool (used in template) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @SuppressWarnings("PHPMD.UnusedPrivateMethod") * * @access private * @@ -285,7 +285,7 @@ private function renderFulltextDownloadTool(): void /** * Renders the fulltext tool (used in template) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @SuppressWarnings("PHPMD.UnusedPrivateMethod") * * @access private * @@ -331,7 +331,7 @@ public function renderScoreTool() /** * Renders the image download tool (used in template) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @SuppressWarnings("PHPMD.UnusedPrivateMethod") * * @access private * @@ -401,7 +401,7 @@ private function getFile(int $page, array $fileGrps): array /** * Renders the image manipulation tool (used in template) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @SuppressWarnings("PHPMD.UnusedPrivateMethod") * * @access private * @@ -419,7 +419,7 @@ private function renderImageManipulationTool(): void /** * Renders the model download tool * Renders the model download tool (used in template) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @SuppressWarnings("PHPMD.UnusedPrivateMethod") * * @access private * @@ -439,7 +439,7 @@ private function renderModelDownloadTool(): void /** * Renders the viewer selection tool * Renders the viewer selection tool (used in template) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @SuppressWarnings("PHPMD.UnusedPrivateMethod") * * @access private * @@ -479,7 +479,7 @@ private function renderViewerSelectionTool(): void /** * Renders the PDF download tool (used in template) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @SuppressWarnings("PHPMD.UnusedPrivateMethod") * * @access private * @@ -593,7 +593,7 @@ private function getWorkLink(): string /** * Renders the searchInDocument tool (used in template) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @SuppressWarnings("PHPMD.UnusedPrivateMethod") * * @access private * @@ -660,7 +660,6 @@ private function getCurrentDocumentId(): string $arr = explode('*', $this->settings['documentIdUrlSchema']); if (count($arr) == 2) { - /** @var non-empty-string $arr[0] */ $id = explode($arr[0], $id)[0]; } elseif (count($arr) == 3) { $sub = substr($id, strpos($id, $arr[0]) + strlen($arr[0]), strlen($id)); @@ -711,7 +710,7 @@ private function isFullTextEmpty(): bool /** * Renders the rotation tool (used in template) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @SuppressWarnings("PHPMD.UnusedPrivateMethod") * * @access private * @@ -724,7 +723,7 @@ private function renderRotationTool(): void /** * Renders the zoom tool (used in template) - * @SuppressWarnings(PHPMD.UnusedPrivateMethod) + * @SuppressWarnings("PHPMD.UnusedPrivateMethod") * * @access private * diff --git a/Classes/Hooks/DataHandler.php b/Classes/Hooks/DataHandler.php index 448e2298c..b374ee4c0 100644 --- a/Classes/Hooks/DataHandler.php +++ b/Classes/Hooks/DataHandler.php @@ -136,7 +136,7 @@ public function processDatamap_postProcessFieldArray(string $status, string $tab $resArray = $result->fetchAssociative(); if (is_array($resArray)) { // Reset storing to current. - $fieldArray['index_stored'] = $resArray['is_listed']; + $fieldArray['index_stored'] = (int) $resArray['is_listed']; } } // Index field in index if it should be used for auto-completion. @@ -161,7 +161,7 @@ public function processDatamap_postProcessFieldArray(string $status, string $tab if ($resArray = $result->fetchAssociative()) { // Reset indexing to current. - $fieldArray['index_indexed'] = $resArray['index_autocomplete']; + $fieldArray['index_indexed'] = (int) $resArray['index_autocomplete']; } } } diff --git a/Classes/Task/BaseAdditionalFieldProvider.php b/Classes/Task/BaseAdditionalFieldProvider.php index 508e101b1..b60d9d324 100644 --- a/Classes/Task/BaseAdditionalFieldProvider.php +++ b/Classes/Task/BaseAdditionalFieldProvider.php @@ -366,11 +366,11 @@ protected function isEditAction(SchedulerModuleController $schedulerModule): boo { $typo3Version = (new Typo3Version())->getMajorVersion(); if ($typo3Version == 12) { - /** @var \TYPO3\CMS\Scheduler\Task\Enumeration\Action $action */ + /** @var Action $action */ $action = $schedulerModule->getCurrentAction(); return $action->equals(Action::EDIT); } else { - /** @var \TYPO3\CMS\Scheduler\SchedulerManagementAction $action */ + /** @var SchedulerManagementAction $action */ $action = $schedulerModule->getCurrentAction(); return $action === SchedulerManagementAction::EDIT; } diff --git a/Classes/Updates/MigrateSettings.php b/Classes/Updates/MigrateSettings.php index 8c0e5b28d..ecb94ef6b 100644 --- a/Classes/Updates/MigrateSettings.php +++ b/Classes/Updates/MigrateSettings.php @@ -179,7 +179,7 @@ protected function migrateFlexFormSettings(string $oldValue): string foreach ($fields as $field) { // change the index attribute if it doesn't start with 'settings.' yet if (!str_contains($field['index'], 'settings.')) { - $field['index'] = 'settings.' . $field['index']; // @phpstan-ignore-line + $field['index'] = 'settings.' . $field['index']; } } }