diff --git a/typo3/sysext/linkvalidator/Classes/LinkAnalyzer.php b/typo3/sysext/linkvalidator/Classes/LinkAnalyzer.php index 891fa8128a50..562430f4e4ce 100644 --- a/typo3/sysext/linkvalidator/Classes/LinkAnalyzer.php +++ b/typo3/sysext/linkvalidator/Classes/LinkAnalyzer.php @@ -449,7 +449,7 @@ protected function analyzeTypoLinks(SoftReferenceParserResult $parserResult, arr * * @return array array with the number of links found */ - public function getLinkCounts() + public function getLinkCounts(): array { return $this->brokenLinkRepository->getNumberOfBrokenLinksForRecordsOnPages($this->pids, $this->searchFields); } diff --git a/typo3/sysext/linkvalidator/Classes/Result/LinkAnalyzerResult.php b/typo3/sysext/linkvalidator/Classes/Result/LinkAnalyzerResult.php index 7f423053aa46..e89a39d55380 100644 --- a/typo3/sysext/linkvalidator/Classes/Result/LinkAnalyzerResult.php +++ b/typo3/sysext/linkvalidator/Classes/Result/LinkAnalyzerResult.php @@ -36,77 +36,28 @@ */ class LinkAnalyzerResult { - /** - * @var LinkAnalyzer - */ - protected $linkAnalyzer; - - /** - * @var BrokenLinkRepository - */ - protected $brokenLinkRepository; - - /** - * @var PagesRepository - */ - protected $pagesRepository; - - /** - * @var ConnectionPool - */ - protected $connectionPool; - - /** - * @var array - */ - protected $brokenLinks = []; - - /** - * @var array - */ - protected $newBrokenLinkCounts = []; - - /** - * @var array - */ - protected $oldBrokenLinkCounts = []; - - /** - * @var bool - */ - protected $differentToLastResult = false; + protected array $brokenLinks = []; + protected array $newBrokenLinkCounts = []; + protected array $oldBrokenLinkCounts = []; + protected bool $differentToLastResult = false; /** * Save localized pages to reduce database requests * * @var array */ - protected $localizedPages = []; + protected array $localizedPages = []; public function __construct( - LinkAnalyzer $linkAnalyzer, - BrokenLinkRepository $brokenLinkRepository, - ConnectionPool $connectionPool, - PagesRepository $pagesRepository + private readonly LinkAnalyzer $linkAnalyzer, + private readonly BrokenLinkRepository $brokenLinkRepository, + private readonly ConnectionPool $connectionPool, + private readonly PagesRepository $pagesRepository ) { - $this->linkAnalyzer = $linkAnalyzer; - $this->brokenLinkRepository = $brokenLinkRepository; - $this->connectionPool = $connectionPool; - $this->pagesRepository = $pagesRepository; } /** * Call LinkAnalyzer with provided task configuration and process result values - * - * @param int $page - * @param int $depth - * @param array $pageRow - * @param array $modTSconfig - * @param array $searchFields - * @param array $linkTypes - * @param string $languages - * - * @return $this */ public function getResultForTask( int $page, @@ -213,7 +164,6 @@ public function isDifferentToLastResult(): bool * Process the link counts (old and new) and ensures that all link types are available in the array * * @param array $linkTypes list of link types - * @return LinkAnalyzerResult */ protected function processLinkCounts(array $linkTypes): self { @@ -236,12 +186,10 @@ protected function processLinkCounts(array $linkTypes): self * Process broken link values and assign them to new variables which are used in the templates * shipped by the core but can also be used in custom templates. The raw data is untouched and * can also still be used in custom templates. - * - * @return LinkAnalyzerResult */ protected function processBrokenLinks(): self { - foreach ($this->brokenLinks as $key => &$brokenLink) { + foreach ($this->brokenLinks as &$brokenLink) { $fullRecord = BackendUtility::getRecord($brokenLink['table_name'], $brokenLink['record_uid']); if ($fullRecord !== null) { @@ -274,10 +222,6 @@ protected function processBrokenLinks(): self /** * Get localized page id and store it in the local property localizedPages - * - * @param int $parentId - * @param int $languageId - * @return int */ protected function getLocalizedPageId(int $parentId, int $languageId): int { diff --git a/typo3/sysext/linkvalidator/Classes/Task/ValidatorTask.php b/typo3/sysext/linkvalidator/Classes/Task/ValidatorTask.php index 56af6dcd4ad1..62d1bc0aa581 100644 --- a/typo3/sysext/linkvalidator/Classes/Task/ValidatorTask.php +++ b/typo3/sysext/linkvalidator/Classes/Task/ValidatorTask.php @@ -134,7 +134,6 @@ public function getEmail(): string * Set the value of the private property email. * * @param string $email Email address to which an email report is sent - * @return ValidatorTask */ public function setEmail(string $email): self { @@ -156,7 +155,6 @@ public function getEmailOnBrokenLinkOnly(): bool * Set the value of the private property emailOnBrokenLinkOnly * * @param bool $emailOnBrokenLinkOnly Only send an email, if new broken links were found - * @return ValidatorTask */ public function setEmailOnBrokenLinkOnly(bool $emailOnBrokenLinkOnly): self { @@ -178,7 +176,6 @@ public function getPage(): int * Set the value of the private property page * * @param int $page UID of the start page for this task. - * @return ValidatorTask */ public function setPage(int $page): self { @@ -200,7 +197,6 @@ public function getLanguages(): string * Set the value of the private property languages * * @param string $languages Languages to fetch broken links - * @return ValidatorTask */ public function setLanguages(string $languages): self { @@ -222,7 +218,6 @@ public function getDepth(): int * Set the value of the private property depth * * @param int $depth Level of pages the task should check - * @return ValidatorTask */ public function setDepth(int $depth): self { @@ -244,7 +239,6 @@ public function getEmailTemplateName(): string * Set the value of the private property emailTemplateName * * @param string $emailTemplateName Template name to be used for the email - * @return ValidatorTask */ public function setEmailTemplateName(string $emailTemplateName): self { @@ -266,7 +260,6 @@ public function getConfiguration(): string * Set the value of the private property configuration * * @param string $configuration specific TSconfig for this task - * @return ValidatorTask */ public function setConfiguration(string $configuration): self { @@ -285,9 +278,7 @@ public function execute(): bool return false; } - $this - ->setCliArguments() - ->loadModTSconfig(); + $this->setCliArguments()->loadModTSconfig(); $successfullyExecuted = true; $linkAnalyzerResult = $this->getLinkAnalyzerResult(); @@ -309,8 +300,6 @@ public function execute(): bool /** * Validate all broken links for pages set in the task configuration * and return the analyzers result as object. - * - * @return LinkAnalyzerResult */ protected function getLinkAnalyzerResult(): LinkAnalyzerResult { @@ -336,10 +325,8 @@ protected function getLinkAnalyzerResult(): LinkAnalyzerResult /** * Load and merge linkvalidator TSconfig from task configuration with page TSconfig - * - * @return ValidatorTask */ - protected function loadModTSconfig(): self + protected function loadModTSconfig(): void { $parseObj = GeneralUtility::makeInstance(TypoScriptParser::class); $parseObj->parse($this->configuration); @@ -355,6 +342,7 @@ protected function loadModTSconfig(): self if (is_array($overrideTs) && $overrideTs !== []) { ArrayUtility::mergeRecursiveWithOverrule($modTs, $overrideTs); } + if (empty($modTs['mail.']['fromemail'])) { $modTs['mail.']['fromemail'] = MailUtility::getSystemFromAddress(); } @@ -363,8 +351,6 @@ protected function loadModTSconfig(): self } $this->modTSconfig = $modTs; - - return $this; } /** @@ -404,8 +390,7 @@ protected function getLinkTypes(): array /** * Build and send report email when broken links were found * - * @param LinkAnalyzerResult $linkAnalyzerResult - * @return bool TRUE if mail was sent, FALSE if or not + * @return bool TRUE if mail was sent, FALSE if not */ protected function reportEmail(LinkAnalyzerResult $linkAnalyzerResult): bool { @@ -478,8 +463,6 @@ protected function reportEmail(LinkAnalyzerResult $linkAnalyzerResult): bool /** * Returns the most important properties of the LinkValidator task as a * comma separated string that will be displayed in the scheduler module. - * - * @return string */ public function getAdditionalInformation(): string { @@ -505,8 +488,6 @@ public function getAdditionalInformation(): string /** * Simulate cli call with setting the required options to the $_SERVER['argv'] - * - * @return ValidatorTask */ protected function setCliArguments(): self { @@ -528,8 +509,6 @@ protected function setCliArguments(): self /** * Get FluidEmail with template from the task configuration - * - * @return FluidEmail */ protected function getFluidEmail(): FluidEmail { @@ -557,9 +536,6 @@ protected function getFluidEmail(): FluidEmail /** * Check if both template files (html and txt) exist under at least one template path - * - * @param array $templatePaths - * @return bool */ protected function templateFilesExist(array $templatePaths): bool {