From d868873cab2e71b80973c6b86861f3f584b7a773 Mon Sep 17 00:00:00 2001
From: Torben Hansen <derhansen@gmail.com>
Date: Sat, 20 Aug 2022 13:54:29 +0200
Subject: [PATCH] [TASK] Modernize ext:belog

* Use strict function argument and return types where possible
* Removed superfluous argument and return type doc comments
* Replaced deprecated strftime usage
* Removed invalid extension key for LocalizationUtility usage
* Replaced switch statement with match expression
* Removed superfluous type casts

Resolves: #98184
Releases: main
Change-Id: If2f4060f80f26c2116eb668220d009b7ae4281b1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75527
Tested-by: core-ci <typo3@b13.com>
Tested-by: Susanne Moog <look@susi.dev>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benni Mack <benni@typo3.org>
---
 .../Controller/BackendLogController.php       |  49 ++--
 .../SystemInformationController.php           |   9 +-
 .../belog/Classes/Domain/Model/Constraint.php | 186 +++----------
 .../belog/Classes/Domain/Model/LogEntry.php   | 253 ++++--------------
 .../Domain/Repository/LogEntryRepository.php  |  22 +-
 .../ViewHelpers/FormatDetailsViewHelper.php   |   2 +-
 .../ViewHelpers/UsernameViewHelper.php        |   4 +-
 .../Tests/Unit/Domain/Model/LogEntryTest.php  |  32 +++
 8 files changed, 134 insertions(+), 423 deletions(-)

diff --git a/typo3/sysext/belog/Classes/Controller/BackendLogController.php b/typo3/sysext/belog/Classes/Controller/BackendLogController.php
index 86e73e8daf72..c8b902bb33fd 100644
--- a/typo3/sysext/belog/Classes/Controller/BackendLogController.php
+++ b/typo3/sysext/belog/Classes/Controller/BackendLogController.php
@@ -67,10 +67,6 @@ class BackendLogController extends ActionController
 
     /**
      * Show general information and the installed modules
-     *
-     * @param Constraint|null $constraint
-     * @param string $operation
-     * @return ResponseInterface
      */
     public function listAction(Constraint $constraint = null, string $operation = ''): ResponseInterface
     {
@@ -134,8 +130,6 @@ class BackendLogController extends ActionController
     /**
      * Delete all log entries that share the same message with the log entry given
      * in $errorUid
-     *
-     * @param int $errorUid
      */
     public function deleteMessageAction(int $errorUid): ResponseInterface
     {
@@ -152,10 +146,8 @@ class BackendLogController extends ActionController
 
     /**
      * Get module states (the constraint object) from user data
-     *
-     * @return Constraint
      */
-    protected function getConstraintFromBeUserData()
+    protected function getConstraintFromBeUserData(): Constraint
     {
         $serializedConstraint = $this->request->getAttribute('moduleData')->get('constraint');
         $constraint = null;
@@ -167,8 +159,6 @@ class BackendLogController extends ActionController
 
     /**
      * Save current constraint object in be user settings (uC)
-     *
-     * @param Constraint $constraint
      */
     protected function persistConstraintInBeUserData(Constraint $constraint): void
     {
@@ -182,7 +172,7 @@ class BackendLogController extends ActionController
      * (memory exhaustion in php), reset the constraints in be user settings, so
      * the belog can be accessed again in the next call.
      */
-    protected function resetConstraintsOnMemoryExhaustionError()
+    protected function resetConstraintsOnMemoryExhaustionError(): void
     {
         $reservedMemory = new \SplFixedArray(187500); // 3M
         register_shutdown_function(function () use (&$reservedMemory): void {
@@ -202,9 +192,6 @@ class BackendLogController extends ActionController
      * '12345' is a sub array to split entries by day, number is first second of day
      *
      * [pid][dayTimestamp][items]
-     *
-     * @param QueryResultInterface $logEntries
-     * @return array
      */
     protected function groupLogEntriesDay(QueryResultInterface $logEntries): array
     {
@@ -217,8 +204,8 @@ class BackendLogController extends ActionController
                 $targetStructure[-1] = [];
             }
             // Get day timestamp of log entry and create sub array if needed
-            // @todo Replace deprecated strftime in php 8.1. Suppress warning in v11.
-            $timestampDay = strtotime(@strftime('%d.%m.%Y', $entry->getTstamp()) ?: '');
+            $entryTimestamp = \DateTimeImmutable::createFromFormat('U', (string)$entry->getTstamp());
+            $timestampDay = strtotime($entryTimestamp->format('d.m.Y'));
             if (!is_array($targetStructure[$pid][$timestampDay] ?? false)) {
                 $targetStructure[$pid][$timestampDay] = [];
             }
@@ -232,11 +219,11 @@ class BackendLogController extends ActionController
     /**
      * Create options for the user / group drop down.
      * This is not moved to a repository by intention to not mix up this 'meta' data
-     * with real repository work
+     * with real repository work.
      *
      * @return array Key is the option name, value its label
      */
-    protected function createUserAndGroupListForSelectOptions()
+    protected function createUserAndGroupListForSelectOptions(): array
     {
         $userGroupArray = [];
         // Two meta entries: 'all' and 'self'
@@ -275,7 +262,7 @@ class BackendLogController extends ActionController
      *
      * @return array Key is uid of workspace, value its label
      */
-    protected function createWorkspaceListForSelectOptions()
+    protected function createWorkspaceListForSelectOptions(): array
     {
         if (!ExtensionManagementUtility::isLoaded('workspaces')) {
             return [];
@@ -314,29 +301,25 @@ class BackendLogController extends ActionController
 
     /**
      * Create options for the 'depth of page levels' selector.
-     * This is shown if the module is displayed in page -> info
      *
      * @return array Key is depth identifier (1 = One level), value the localized select option label
      */
-    protected function createPageDepthOptions()
+    protected function createPageDepthOptions(): array
     {
-        $options = [
-            0 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_0', 'lang'),
-            1 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_1', 'lang'),
-            2 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_2', 'lang'),
-            3 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_3', 'lang'),
-            4 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_4', 'lang'),
-            999 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_infi', 'lang'),
+        return [
+            0 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_0'),
+            1 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_1'),
+            2 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_2'),
+            3 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_3'),
+            4 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_4'),
+            999 => LocalizationUtility::translate('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.depth_infi'),
         ];
-        return $options;
     }
 
     /**
      * Calculate the start- and end timestamp
-     *
-     * @param Constraint $constraint
      */
-    protected function setStartAndEndTimeFromTimeSelector(Constraint $constraint)
+    protected function setStartAndEndTimeFromTimeSelector(Constraint $constraint): void
     {
         $startTime = $constraint->getManualDateStart() ? $constraint->getManualDateStart()->getTimestamp() : 0;
         $endTime = $constraint->getManualDateStop() ? $constraint->getManualDateStop()->getTimestamp() : 0;
diff --git a/typo3/sysext/belog/Classes/Controller/SystemInformationController.php b/typo3/sysext/belog/Classes/Controller/SystemInformationController.php
index 4abad0a300ee..ff688166a6bf 100644
--- a/typo3/sysext/belog/Classes/Controller/SystemInformationController.php
+++ b/typo3/sysext/belog/Classes/Controller/SystemInformationController.php
@@ -18,6 +18,7 @@ declare(strict_types=1);
 namespace TYPO3\CMS\Belog\Controller;
 
 use TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent;
+use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
 use TYPO3\CMS\Backend\Routing\UriBuilder;
 use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus;
 use TYPO3\CMS\Core\Database\Connection;
@@ -32,10 +33,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  */
 final class SystemInformationController
 {
-    /**
-     * @var array
-     */
-    protected $backendUserConfiguration;
+    protected array $backendUserConfiguration;
 
     public function __construct(array $backendUserConfiguration = null)
     {
@@ -44,8 +42,7 @@ final class SystemInformationController
 
     /**
      * Modifies the SystemInformation toolbar to inject a new message
-     * @param SystemInformationToolbarCollectorEvent $event
-     * @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException
+     * @throws RouteNotFoundException
      */
     public function appendMessage(SystemInformationToolbarCollectorEvent $event): void
     {
diff --git a/typo3/sysext/belog/Classes/Domain/Model/Constraint.php b/typo3/sysext/belog/Classes/Domain/Model/Constraint.php
index 0db757d71b81..ac575893182c 100644
--- a/typo3/sysext/belog/Classes/Domain/Model/Constraint.php
+++ b/typo3/sysext/belog/Classes/Domain/Model/Constraint.php
@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 /*
  * This file is part of the TYPO3 CMS project.
  *
@@ -25,287 +27,165 @@ class Constraint
 {
     /**
      * Selected user/group; possible values are "gr-<uid>" for a group, "us-<uid>" for a user or -1 for "all users"
-     *
-     * @var string
      */
-    protected $userOrGroup = '0';
+    protected string $userOrGroup = '0';
 
     /**
      * Number of log rows to show
-     *
-     * @var int
      */
-    protected $number = 20;
+    protected int $number = 20;
 
     /**
      * UID of selected workspace
-     *
-     * @var int
      */
-    protected $workspaceUid = -99;
+    protected int $workspaceUid = -99;
 
     /**
      * Selected channel
-     *
-     * @var string
      */
     protected string $channel = '';
 
     /**
      * Selected level
-     *
-     * @var string
      */
     protected string $level = LogLevel::DEBUG;
 
     /**
      * Calculated start timestamp
-     *
-     * @var int
      */
-    protected $startTimestamp = 0;
+    protected int $startTimestamp = 0;
 
     /**
      * Calculated end timestamp
-     *
-     * @var int
      */
-    protected $endTimestamp = 0;
+    protected int $endTimestamp = 0;
 
     /**
      * Manual date start
-     * @var \DateTime|null
      */
-    protected $manualDateStart;
+    protected ?\DateTime $manualDateStart = null;
 
     /**
      * Manual date stop
-     * @var \DateTime|null
      */
-    protected $manualDateStop;
+    protected ?\DateTime $manualDateStop = null;
 
     /**
      * Selected page ID in page context
-     *
-     * @var int
      */
-    protected $pageId = 0;
+    protected int $pageId = 0;
 
     /**
      * Page level depth
-     *
-     * @var int
      */
-    protected $depth = 0;
+    protected int $depth = 0;
 
-    /**
-     * Set user
-     *
-     * @param string $user
-     */
-    public function setUserOrGroup($user)
+    public function setUserOrGroup(string $user): void
     {
         $this->userOrGroup = $user;
     }
 
-    /**
-     * Get user
-     *
-     * @return string
-     */
-    public function getUserOrGroup()
+    public function getUserOrGroup(): string
     {
         return $this->userOrGroup;
     }
 
-    /**
-     * Set number of log rows to show
-     *
-     * @param int $number
-     */
-    public function setNumber($number)
+    public function setNumber(int $number): void
     {
         $this->number = (int)$number;
     }
 
-    /**
-     * Get number of log entries to show
-     *
-     * @return int
-     */
-    public function getNumber()
+    public function getNumber(): int
     {
         return $this->number;
     }
 
-    /**
-     * Set workspace
-     *
-     * @param int $workspace
-     */
-    public function setWorkspaceUid($workspace)
+    public function setWorkspaceUid(int $workspace): void
     {
         $this->workspaceUid = $workspace;
     }
 
-    /**
-     * Get workspace
-     *
-     * @return int
-     */
-    public function getWorkspaceUid()
+    public function getWorkspaceUid(): int
     {
         return $this->workspaceUid;
     }
 
-    /**
-     * Set channel
-     */
     public function setChannel(string $channel): void
     {
         $this->channel = $channel;
     }
 
-    /**
-     * Get channel
-     */
     public function getChannel(): string
     {
         return $this->channel;
     }
 
-    /**
-     * Set level
-     */
     public function setLevel(string $level): void
     {
         $this->level = $level;
     }
 
-    /**
-     * Get level
-     */
     public function getLevel(): string
     {
         return $this->level;
     }
 
-    /**
-     * Set calculated start timestamp from query constraints
-     *
-     * @param int $timestamp
-     */
-    public function setStartTimestamp($timestamp)
+    public function setStartTimestamp(int $timestamp): void
     {
-        $this->startTimestamp = (int)$timestamp;
+        $this->startTimestamp = $timestamp;
     }
 
-    /**
-     * Get calculated start timestamp from query constraints
-     *
-     * @return int
-     */
-    public function getStartTimestamp()
+    public function getStartTimestamp(): int
     {
         return $this->startTimestamp;
     }
 
-    /**
-     * Set calculated end timestamp from query constraints
-     *
-     * @param int $timestamp
-     */
-    public function setEndTimestamp($timestamp)
+    public function setEndTimestamp(int $timestamp): void
     {
-        $this->endTimestamp = (int)$timestamp;
+        $this->endTimestamp = $timestamp;
     }
 
-    /**
-     * Get calculated end timestamp from query constraints
-     *
-     * @return int
-     */
-    public function getEndTimestamp()
+    public function getEndTimestamp(): int
     {
         return $this->endTimestamp;
     }
 
-    /**
-     * Set page id
-     *
-     * @param int $id
-     */
-    public function setPageId($id)
+    public function setPageId(int $id): void
     {
-        $this->pageId = (int)$id;
+        $this->pageId = $id;
     }
 
-    /**
-     * Get page id
-     *
-     * @return int
-     */
-    public function getPageId()
+    public function getPageId(): int
     {
         return $this->pageId;
     }
 
-    /**
-     * Set page level depth
-     *
-     * @param int $depth
-     */
-    public function setDepth($depth)
+    public function setDepth(int $depth): void
     {
         $this->depth = $depth;
     }
 
-    /**
-     * Get page level depth
-     *
-     * @return int
-     */
-    public function getDepth()
+    public function getDepth(): int
     {
-        return (int)$this->depth;
+        return $this->depth;
     }
 
-    /**
-     * Set manual date start
-     *
-     * @param \DateTime $manualDateStart
-     */
-    public function setManualDateStart(\DateTime $manualDateStart = null)
+    public function setManualDateStart(?\DateTime $manualDateStart = null): void
     {
         $this->manualDateStart = $manualDateStart;
     }
 
-    /**
-     * Get manual date start
-     *
-     * @return \DateTime|null
-     */
-    public function getManualDateStart()
+    public function getManualDateStart(): ?\DateTime
     {
         return $this->manualDateStart;
     }
 
-    /**
-     * Set manual date stop
-     *
-     * @param \DateTime $manualDateStop
-     */
-    public function setManualDateStop(\DateTime $manualDateStop = null)
+    public function setManualDateStop(?\DateTime $manualDateStop = null): void
     {
         $this->manualDateStop = $manualDateStop;
     }
 
-    /**
-     * Get manual date stop
-     *
-     * @return \DateTime|null
-     */
-    public function getManualDateStop()
+    public function getManualDateStop(): ?\DateTime
     {
         return $this->manualDateStop;
     }
diff --git a/typo3/sysext/belog/Classes/Domain/Model/LogEntry.php b/typo3/sysext/belog/Classes/Domain/Model/LogEntry.php
index b989e4c238b6..c030e492f689 100644
--- a/typo3/sysext/belog/Classes/Domain/Model/LogEntry.php
+++ b/typo3/sysext/belog/Classes/Domain/Model/LogEntry.php
@@ -1,5 +1,7 @@
 <?php
 
+declare(strict_types=1);
+
 /*
  * This file is part of the TYPO3 CMS project.
  *
@@ -87,7 +89,7 @@ class LogEntry extends AbstractEntity
     /**
      * Channel name.
      */
-    protected string $channel = 'narf';
+    protected string $channel = '';
 
     /**
      * Level.
@@ -123,164 +125,85 @@ class LogEntry extends AbstractEntity
      * New ID
      *
      * @var string
-     * @todo: should be string|int but extbase chokes on this while mapping
+     * @todo: should be string|int but extbase chokes on this while mapping - see #98132
      */
     protected $newId = 0;
 
-    /**
-     * Set backend user uid
-     *
-     * @param int $beUserUid
-     */
-    public function setBackendUserUid($beUserUid)
+    public function setBackendUserUid(int $beUserUid): void
     {
         $this->backendUserUid = $beUserUid;
     }
 
-    /**
-     * Get backend user id
-     *
-     * @return int
-     */
-    public function getBackendUserUid()
+    public function getBackendUserUid(): int
     {
         return $this->backendUserUid;
     }
 
-    /**
-     * Set action
-     *
-     * @param int $action
-     */
-    public function setAction($action)
+    public function setAction(int $action): void
     {
         $this->action = $action;
     }
 
-    /**
-     * Get action
-     *
-     * @return int
-     */
-    public function getAction()
+    public function getAction(): int
     {
-        return (int)$this->action;
+        return $this->action;
     }
 
-    /**
-     * Set record uid
-     *
-     * @param int $recordUid
-     */
-    public function setRecordUid($recordUid)
+    public function setRecordUid(int $recordUid): void
     {
         $this->recordUid = $recordUid;
     }
 
-    /**
-     * Get record uid
-     *
-     * @return int
-     */
-    public function getRecordUid()
+    public function getRecordUid(): int
     {
-        return (int)$this->recordUid;
+        return $this->recordUid;
     }
 
-    /**
-     * Set table name
-     *
-     * @param string $tableName
-     */
-    public function setTableName($tableName)
+    public function setTableName(string $tableName): void
     {
         $this->tableName = $tableName;
     }
 
-    /**
-     * Get table name
-     *
-     * @return string
-     */
-    public function getTableName()
+    public function getTableName(): string
     {
         return $this->tableName;
     }
 
-    /**
-     * Set record pid
-     *
-     * @param int $recordPid
-     */
-    public function setRecordPid($recordPid)
+    public function setRecordPid(int $recordPid): void
     {
         $this->recordPid = $recordPid;
     }
 
-    /**
-     * Get record pid
-     *
-     * @return int
-     */
-    public function getRecordPid()
+    public function getRecordPid(): int
     {
-        return (int)$this->recordPid;
+        return $this->recordPid;
     }
 
-    /**
-     * Set error
-     *
-     * @param int $error
-     */
-    public function setError($error)
+    public function setError(int $error): void
     {
         $this->error = $error;
     }
 
-    /**
-     * Get error
-     *
-     * @return int
-     */
-    public function getError()
+    public function getError(): int
     {
-        return (int)$this->error;
+        return $this->error;
     }
 
-    /**
-     * Get class name for the error code
-     *
-     * @return string
-     */
     public function getErrorIconClass(): string
     {
-        switch ($this->getError()) {
-            case 1:
-                return 'status-dialog-warning';
-            case 2:
-            case 3:
-                return 'status-dialog-error';
-            default:
-                return 'empty-empty';
-        }
+        return match ($this->getError()) {
+            1 => 'status-dialog-warning',
+            2, 3 => 'status-dialog-error',
+            default => 'empty-empty',
+        };
     }
 
-    /**
-     * Set details
-     *
-     * @param string $details
-     */
-    public function setDetails($details)
+    public function setDetails(string $details): void
     {
         $this->details = $details;
     }
 
-    /**
-     * Get details
-     *
-     * @return string
-     */
-    public function getDetails()
+    public function getDetails(): string
     {
         if ($this->type === 255) {
             return str_replace('###IP###', $this->ip, $this->details);
@@ -288,134 +211,72 @@ class LogEntry extends AbstractEntity
         return $this->details;
     }
 
-    /**
-     * Set tstamp
-     *
-     * @param int $tstamp
-     */
-    public function setTstamp($tstamp)
+    public function setTstamp(int $tstamp): void
     {
         $this->tstamp = $tstamp;
     }
 
-    /**
-     * Get tstamp
-     *
-     * @return int
-     */
-    public function getTstamp()
+    public function getTstamp(): int
     {
-        return (int)$this->tstamp;
+        return $this->tstamp;
     }
 
-    /**
-     * Set type
-     *
-     * @param int $type
-     */
-    public function setType($type)
+    public function setType(int $type): void
     {
         $this->type = $type;
     }
 
-    /**
-     * Get type
-     *
-     * @return int
-     */
-    public function getType()
+    public function getType(): int
     {
-        return (int)$this->type;
+        return $this->type;
     }
 
-    /**
-     * Set channel
-     */
     public function setChannel(string $channel): void
     {
         $this->channel = $channel;
     }
 
-    /**
-     * Get channel
-     */
     public function getChannel(): string
     {
         return $this->channel;
     }
 
-    /**
-     * Set level
-     */
     public function setLevel(string $level): void
     {
         $this->level = $level;
     }
 
-    /**
-     * Get level
-     */
     public function getLevel(): string
     {
         return $this->level;
     }
 
-    /**
-     * Set details number
-     *
-     * @param int $detailsNumber
-     */
-    public function setDetailsNumber($detailsNumber)
+    public function setDetailsNumber(int $detailsNumber): void
     {
         $this->detailsNumber = $detailsNumber;
     }
 
-    /**
-     * Get details number
-     *
-     * @return int
-     */
-    public function getDetailsNumber()
+    public function getDetailsNumber(): int
     {
-        return (int)$this->detailsNumber;
+        return $this->detailsNumber;
     }
 
-    /**
-     * Set ip
-     *
-     * @param string $ip
-     */
-    public function setIp($ip)
+    public function setIp(string $ip): void
     {
         $this->ip = $ip;
     }
 
-    /**
-     * Get ip
-     *
-     * @return string
-     */
-    public function getIp()
+    public function getIp(): string
     {
         return $this->ip;
     }
 
-    /**
-     * Set log data
-     *
-     * @param string $logData
-     */
-    public function setLogData($logData)
+    public function setLogData(string $logData): void
     {
         $this->logData = $logData;
     }
 
-    /**
-     * Get log data
-     *
-     * @return array
-     */
-    public function getLogData()
+    public function getLogData(): array
     {
         if ($this->logData === '') {
             return [];
@@ -424,44 +285,24 @@ class LogEntry extends AbstractEntity
         return $logData ?? [];
     }
 
-    /**
-     * Set event pid
-     *
-     * @param int $eventPid
-     */
-    public function setEventPid($eventPid)
+    public function setEventPid(int $eventPid): void
     {
         $this->eventPid = $eventPid;
     }
 
-    /**
-     * Get event pid
-     *
-     * @return int
-     */
-    public function getEventPid()
+    public function getEventPid(): int
     {
-        return (int)$this->eventPid;
+        return $this->eventPid;
     }
 
-    /**
-     * Set workspace uid
-     *
-     * @param int $workspaceUid
-     */
-    public function setWorkspaceUid($workspaceUid)
+    public function setWorkspaceUid(int $workspaceUid): void
     {
         $this->workspaceUid = $workspaceUid;
     }
 
-    /**
-     * Get workspace
-     *
-     * @return int
-     */
-    public function getWorkspaceUid()
+    public function getWorkspaceUid(): int
     {
-        return (int)$this->workspaceUid;
+        return $this->workspaceUid;
     }
 
     /**
@@ -469,7 +310,7 @@ class LogEntry extends AbstractEntity
      *
      * @param string $newId
      */
-    public function setNewId($newId)
+    public function setNewId($newId): void
     {
         $this->newId = $newId;
     }
diff --git a/typo3/sysext/belog/Classes/Domain/Repository/LogEntryRepository.php b/typo3/sysext/belog/Classes/Domain/Repository/LogEntryRepository.php
index 4f30b31a3f0a..4e799fdfb1e4 100644
--- a/typo3/sysext/belog/Classes/Domain/Repository/LogEntryRepository.php
+++ b/typo3/sysext/belog/Classes/Domain/Repository/LogEntryRepository.php
@@ -21,7 +21,6 @@ use Psr\Log\LogLevel;
 use TYPO3\CMS\Backend\Tree\View\PageTreeView;
 use TYPO3\CMS\Belog\Domain\Model\Constraint;
 use TYPO3\CMS\Belog\Domain\Model\LogEntry;
-use TYPO3\CMS\Belog\Domain\Model\Workspace;
 use TYPO3\CMS\Core\Authentication\GroupResolver;
 use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Log\LogLevel as Typo3LogLevel;
@@ -41,9 +40,6 @@ class LogEntryRepository extends Repository
 {
     public ?QuerySettingsInterface $querySettings = null;
 
-    /**
-     * @param QuerySettingsInterface $querySettings
-     */
     public function injectQuerySettings(QuerySettingsInterface $querySettings): void
     {
         $this->querySettings = $querySettings;
@@ -59,9 +55,6 @@ class LogEntryRepository extends Repository
 
     /**
      * Finds all log entries that match all given constraints.
-     *
-     * @param Constraint $constraint
-     * @return QueryResultInterface
      */
     public function findByConstraint(Constraint $constraint): QueryResultInterface
     {
@@ -80,8 +73,6 @@ class LogEntryRepository extends Repository
     /**
      * Create an array of query constraints from constraint object
      *
-     * @param QueryInterface $query
-     * @param Constraint $constraint
      * @return ConstraintInterface[]
      */
     protected function createQueryConstraints(QueryInterface $query, Constraint $constraint): array
@@ -90,7 +81,7 @@ class LogEntryRepository extends Repository
         // User / group handling
         $this->addUsersAndGroupsToQueryConstraints($constraint, $query, $queryConstraints);
         // Workspace
-        if ((int)$constraint->getWorkspaceUid() !== -99) {
+        if ($constraint->getWorkspaceUid() !== -99) {
             $queryConstraints[] = $query->equals('workspace', $constraint->getWorkspaceUid());
         }
         // Channel
@@ -113,10 +104,6 @@ class LogEntryRepository extends Repository
     /**
      * Adds constraints for the page(s) to the query; this could be one single page or a whole subtree beneath a given
      * page.
-     *
-     * @param Constraint $constraint
-     * @param QueryInterface $query
-     * @param array $queryConstraints the query constraints to add to, will be modified
      */
     protected function addPageTreeConstraintsToQuery(
         Constraint $constraint,
@@ -143,10 +130,6 @@ class LogEntryRepository extends Repository
 
     /**
      * Adds users and groups to the query constraints.
-     *
-     * @param Constraint $constraint
-     * @param QueryInterface $query
-     * @param array $queryConstraints the query constraints to add to, will be modified
      */
     protected function addUsersAndGroupsToQueryConstraints(
         Constraint $constraint,
@@ -179,9 +162,6 @@ class LogEntryRepository extends Repository
 
     /**
      * Deletes all messages which have the same message details
-     *
-     * @param LogEntry $logEntry
-     * @return int
      */
     public function deleteByMessageDetails(LogEntry $logEntry): int
     {
diff --git a/typo3/sysext/belog/Classes/ViewHelpers/FormatDetailsViewHelper.php b/typo3/sysext/belog/Classes/ViewHelpers/FormatDetailsViewHelper.php
index 55e58c0c24e0..e0c294f25d56 100644
--- a/typo3/sysext/belog/Classes/ViewHelpers/FormatDetailsViewHelper.php
+++ b/typo3/sysext/belog/Classes/ViewHelpers/FormatDetailsViewHelper.php
@@ -67,7 +67,7 @@ final class FormatDetailsViewHelper extends AbstractViewHelper
     protected static function stripPathFromFilenames(array $files = []): array
     {
         foreach ($files as $key => $file) {
-            $files[$key] = PathUtility::basename($file);
+            $files[$key] = PathUtility::basename((string)$file);
         }
         return $files;
     }
diff --git a/typo3/sysext/belog/Classes/ViewHelpers/UsernameViewHelper.php b/typo3/sysext/belog/Classes/ViewHelpers/UsernameViewHelper.php
index 971c89585a45..6cbd5c610377 100644
--- a/typo3/sysext/belog/Classes/ViewHelpers/UsernameViewHelper.php
+++ b/typo3/sysext/belog/Classes/ViewHelpers/UsernameViewHelper.php
@@ -33,10 +33,8 @@ final class UsernameViewHelper extends AbstractViewHelper
 
     /**
      * First level cache of user names
-     *
-     * @var array
      */
-    protected static $usernameRuntimeCache = [];
+    protected static array $usernameRuntimeCache = [];
 
     /**
      * Initializes the arguments
diff --git a/typo3/sysext/belog/Tests/Unit/Domain/Model/LogEntryTest.php b/typo3/sysext/belog/Tests/Unit/Domain/Model/LogEntryTest.php
index 7b6675d44988..814f15641491 100644
--- a/typo3/sysext/belog/Tests/Unit/Domain/Model/LogEntryTest.php
+++ b/typo3/sysext/belog/Tests/Unit/Domain/Model/LogEntryTest.php
@@ -77,4 +77,36 @@ class LogEntryTest extends UnitTestCase
         $this->subject->setLogData(serialize(new \stdClass()));
         self::assertSame([], $this->subject->getLogData());
     }
+
+    public function getErrorIconReturnsCorrespondingClassDataProvider(): array
+    {
+        return [
+            'empty' => [
+                0,
+                'empty-empty',
+            ],
+            'warning' => [
+                1,
+                'status-dialog-warning',
+            ],
+            'error 2' => [
+                2,
+                'status-dialog-error',
+            ],
+            'error 3' => [
+                3,
+                'status-dialog-error',
+            ],
+        ];
+    }
+
+    /**
+     * @test
+     * @dataProvider getErrorIconReturnsCorrespondingClassDataProvider
+     */
+    public function getErrorIconReturnsCorrespondingClass(int $error, string $expectedClass): void
+    {
+        $this->subject->setError($error);
+        self::assertSame($expectedClass, $this->subject->getErrorIconClass());
+    }
 }
-- 
GitLab