From 5b18f7314eb00351387268cc84a2288e723ae94d Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Sun, 9 Feb 2025 22:37:32 +0100 Subject: [PATCH] assert phpstan rules --- src/LoggerFactory.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/LoggerFactory.php b/src/LoggerFactory.php index 228885c..ed4a1b6 100644 --- a/src/LoggerFactory.php +++ b/src/LoggerFactory.php @@ -51,6 +51,12 @@ class LoggerFactory } /** + * @param string $loggerName + * @param string $filePath + * @param int $logLevel + * @param int|null $maxFiles + * @param array> $specialHandlers + * @return Logger * @throws Exception */ public function getFileLogger( @@ -79,11 +85,19 @@ class LoggerFactory ?int $maxFiles = null ): AbstractProcessingHandler { return is_null($maxFiles) ? + /** @phpstan-ignore argument.type */ new StreamHandler($filePath, $logLevel) : + /** @phpstan-ignore argument.type */ new RotatingFileHandler($filePath, $maxFiles, $logLevel); } /** + * @param string $loggerName + * @param string $filePath + * @param int $logLevel + * @param int|null $maxFiles + * @param array> $specialHandlers + * @return Logger * @throws Exception */ public function getCombinedOxidAndFileLogger( @@ -123,6 +137,11 @@ class LoggerFactory return OX_BASE_PATH . '/log' . DIRECTORY_SEPARATOR . $fileName; } + /** + * @param AbstractProcessingHandler $handler + * @param array> $specialHandlers + * @return HandlerInterface + */ public function applySpecialHandlers( AbstractProcessingHandler $handler, array $specialHandlers = [] @@ -133,7 +152,9 @@ class LoggerFactory $options = $specialHandlers[self::SPECIAL_HANDLERS_BUFFERING]; $handler = $this->setBuffering( $handler, + /** @phpstan-ignore argument.type */ $options[self::BUFFERING_OPTION_LIMIT] ?? 0, + /** @phpstan-ignore argument.type */ $options[self::BUFFERING_OPTION_LEVEL] ?? Logger::DEBUG ); } @@ -144,17 +165,22 @@ class LoggerFactory $options = $specialHandlers[self::SPECIAL_HANDLERS_LOG_ON_ERROR_ONLY]; $handler = $this->setLogItemsOnErrorOnly( $handler, + /** @phpstan-ignore argument.type */ $options[self::LOGONERRORONLY_LEVEL] ?? Logger::ERROR ); } if (in_array(self::SPECIAL_HANDLERS_MAKE_UNIQUE, $specialHandlers, true)) { + /** @phpstan-ignore argument.type */ $handler = $this->makeUnique($handler); } elseif (in_array(self::SPECIAL_HANDLERS_MAKE_UNIQUE, array_keys($specialHandlers), true)) { $options = $specialHandlers[self::SPECIAL_HANDLERS_MAKE_UNIQUE]; $handler = $this->makeUnique( + /** @phpstan-ignore argument.type */ $handler, + /** @phpstan-ignore argument.type */ $options[self::MAKEUNIQUE_OPTION_LEVEL] ?? Logger::ERROR, + /** @phpstan-ignore argument.type */ $options[self::MAKEUNIQUE_OPTION_TIME] ?? 60 ); } @@ -167,6 +193,7 @@ class LoggerFactory int $bufferLimit = 0, int $loglevel = Logger::DEBUG ): BufferHandler { + /** @phpstan-ignore argument.type */ return new BufferHandler($handler, $bufferLimit, $loglevel); } @@ -176,6 +203,7 @@ class LoggerFactory ): FingersCrossedHandler { return new FingersCrossedHandler( $handler, + /** @phpstan-ignore argument.type */ new ErrorLevelActivationStrategy($activationLevel) ); } @@ -185,6 +213,7 @@ class LoggerFactory int $deduplicationLevel = Logger::ERROR, int $time = 60 ): DeduplicationHandler { + /** @phpstan-ignore argument.type */ return new DeduplicationHandler($handler, null, $deduplicationLevel, $time); } }